Exemplo n.º 1
0
def wait_for_server_start(pidFile, scmStatus):
    properties = get_ambari_properties()
    if properties == -1:
        err = "Error getting ambari properties"
        raise FatalException(-1, err)

    #wait for server process for SERVER_START_TIMEOUT seconds
    sys.stdout.write('Waiting for server start...')
    sys.stdout.flush()

    pids = looking_for_pid(SERVER_SEARCH_PATTERN, SERVER_INIT_TIMEOUT)
    found_pids = wait_for_pid(pids, SERVER_INIT_TIMEOUT, SERVER_START_TIMEOUT,
                              WEB_UI_INIT_TIME, properties)

    sys.stdout.write('\n')
    sys.stdout.flush()

    if found_pids <= 0:
        exitcode = check_exitcode(
            os.path.join(configDefaults.PID_DIR, EXITCODE_NAME))
        raise FatalException(
            -1,
            AMBARI_SERVER_DIE_MSG.format(exitcode,
                                         configDefaults.SERVER_OUT_FILE))
    else:
        save_main_pid_ex(
            pids, pidFile,
            locate_all_file_paths('sh', '/bin') +
            locate_all_file_paths('bash', '/bin') +
            locate_all_file_paths('dash', '/bin'), True, IS_FOREGROUND)
Exemplo n.º 2
0
def wait_for_server_start(pidFile, scmStatus):
    properties = get_ambari_properties()
    if properties == -1:
        err = "Error getting ambari properties"
        raise FatalException(-1, err)

    #wait for server process for SERVER_START_TIMEOUT seconds
    sys.stdout.write('Waiting for server start...')
    sys.stdout.flush()
    pids = []
    server_started = False
    # looking_for_pid() might return partrial pid list on slow hardware
    for i in range(1, SERVER_START_RETRIES):
        pids = looking_for_pid(SERVER_SEARCH_PATTERN, SERVER_START_TIMEOUT)

        sys.stdout.write('\n')
        sys.stdout.flush()

        if save_main_pid_ex(
                pids, pidFile,
                locate_all_file_paths('sh', '/bin') +
                locate_all_file_paths('bash', '/bin') +
                locate_all_file_paths('dash', '/bin'), IS_FOREGROUND):
            server_started = True
            break
        else:
            sys.stdout.write("Unable to determine server PID. Retrying...\n")
            sys.stdout.flush()

    exception = None
    if server_started:
        ambari_server_ui_port = get_ambari_server_ui_port(properties)
        if not wait_for_ui_start(int(ambari_server_ui_port), WEB_UI_INIT_TIME):
            exception = FatalException(1, "Server not yet listening on http port " + ambari_server_ui_port + \
                                       " after " + str(WEB_UI_INIT_TIME) + " seconds. Exiting.")
    elif get_live_pids_count(pids) <= 0:
        exitcode = check_exitcode(
            os.path.join(configDefaults.PID_DIR, EXITCODE_NAME))
        exception = FatalException(
            -1,
            AMBARI_SERVER_DIE_MSG.format(exitcode,
                                         configDefaults.SERVER_OUT_FILE))
    else:
        exception = FatalException(-1, AMBARI_SERVER_NOT_STARTED_MSG)

    if 'Database consistency check: failed' in open(
            configDefaults.SERVER_OUT_FILE).read():
        print "DB configs consistency check failed. Run \"ambari-server start --skip-database-check\" to skip. " \
        "You may try --auto-fix-database flag to attempt to fix issues automatically. " \
              "If you use this \"--skip-database-check\" option, do not make any changes to your cluster topology " \
              "or perform a cluster upgrade until you correct the database consistency issues. See " + \
              configDefaults.DB_CHECK_LOG + " for more details on the consistency issues."
    elif 'Database consistency check: warning' in open(
            configDefaults.SERVER_OUT_FILE).read():
        print "DB configs consistency check found warnings. See " + configDefaults.DB_CHECK_LOG + " for more details."
    else:
        print "DB configs consistency check: no errors and warnings were found."

    if exception:
        raise exception
Exemplo n.º 3
0
def wait_for_server_start(pidFile, scmStatus):
  #wait for server process for SERVER_START_TIMEOUT seconds
  sys.stdout.write('Waiting for server start...')
  sys.stdout.flush()

  pids = looking_for_pid(SERVER_SEARCH_PATTERN, SERVER_INIT_TIMEOUT)
  found_pids = wait_for_pid(pids, SERVER_START_TIMEOUT)

  sys.stdout.write('\n')
  sys.stdout.flush()

  if found_pids <= 0:
    exitcode = check_exitcode(os.path.join(configDefaults.PID_DIR, EXITCODE_NAME))
    raise FatalException(-1, AMBARI_SERVER_DIE_MSG.format(exitcode, configDefaults.SERVER_OUT_FILE))
  else:
    save_main_pid_ex(pids, pidFile, [locate_file('sh', '/bin'),
                                     locate_file('bash', '/bin'),
                                     locate_file('dash', '/bin')], True)
Exemplo n.º 4
0
def wait_for_server_start(pidFile, scmStatus):
  #wait for server process for SERVER_START_TIMEOUT seconds
  sys.stdout.write('Waiting for server start...')
  sys.stdout.flush()

  pids = looking_for_pid(SERVER_SEARCH_PATTERN, SERVER_INIT_TIMEOUT)
  found_pids = wait_for_pid(pids, SERVER_START_TIMEOUT)

  sys.stdout.write('\n')
  sys.stdout.flush()

  if found_pids <= 0:
    exitcode = check_exitcode(os.path.join(configDefaults.PID_DIR, EXITCODE_NAME))
    raise FatalException(-1, AMBARI_SERVER_DIE_MSG.format(exitcode, configDefaults.SERVER_OUT_FILE))
  else:
    save_main_pid_ex(pids, pidFile, [locate_file('sh', '/bin'),
                                     locate_file('bash', '/bin'),
                                     locate_file('dash', '/bin')], True)
Exemplo n.º 5
0
def wait_for_server_start(pidFile, scmStatus):
    properties = get_ambari_properties()
    if properties == -1:
        err = "Error getting ambari properties"
        raise FatalException(-1, err)

    #wait for server process for SERVER_START_TIMEOUT seconds
    sys.stdout.write('Waiting for server start...')
    sys.stdout.flush()
    pids = []
    pid = None
    # looking_for_pid() might return partrial pid list on slow hardware
    for i in range(1, SERVER_START_RETRIES):
        pids = looking_for_pid(SERVER_SEARCH_PATTERN, SERVER_START_TIMEOUT)
        pid = save_main_pid_ex(
            pids, pidFile,
            locate_all_file_paths('sh', '/bin') +
            locate_all_file_paths('bash', '/bin') +
            locate_all_file_paths('dash', '/bin'), IS_FOREGROUND)
        if pid:
            break
        else:
            sys.stdout.write("Unable to determine server PID. Retrying...\n")
            sys.stdout.flush()

    exception = None
    if pid:
        ambari_server_ui_port = get_ambari_server_ui_port(properties)
        web_server_startup_timeout = get_web_server_startup_timeout(properties)
        waitStart = time.time()
        if not wait_for_ui_start(int(ambari_server_ui_port), pid,
                                 web_server_startup_timeout):
            waitTime = int(time.time() - waitStart)
            # Java process stopped, due to a DB check or other startup issue
            if waitTime < web_server_startup_timeout:
                exception = FatalException(-1, AMBARI_SERVER_STOPPED)
            # UI didn't come up on time
            else:
                exception = FatalException(
                    1,
                    AMBARI_SERVER_UI_TIMEOUT.format(
                        ambari_server_ui_port, web_server_startup_timeout))
    elif get_live_pids_count(pids) <= 0:
        exitcode = check_exitcode(
            os.path.join(configDefaults.PID_DIR, EXITCODE_NAME))
        exception = FatalException(
            -1,
            AMBARI_SERVER_DIE_MSG.format(exitcode,
                                         configDefaults.SERVER_OUT_FILE))
    else:
        exception = FatalException(-1, AMBARI_SERVER_NOT_STARTED_MSG)

    if os.path.isfile(configDefaults.SERVER_OUT_FILE):
        if 'DB_CHECK_ERROR' in open(configDefaults.SERVER_OUT_FILE).read():
            print "\nDB configs consistency check failed. Run \"ambari-server start --skip-database-check\" to skip. " \
              "You may try --auto-fix-database flag to attempt to fix issues automatically. " \
              "If you use this \"--skip-database-check\" option, do not make any changes to your cluster topology " \
              "or perform a cluster upgrade until you correct the database consistency issues. See " + \
              configDefaults.DB_CHECK_LOG + " for more details on the consistency issues."
        elif 'DB_CHECK_WARNING' in open(configDefaults.SERVER_OUT_FILE).read():
            print "\nDB configs consistency check found warnings. See " + configDefaults.DB_CHECK_LOG + " for more details."
        # Only presume that DB check was successful if it explicitly appears in the log. An unexpected error may prevent
        # the consistency check from running at all, so missing error/warning message in the log cannot imply the check was
        # successful
        elif 'DB_CHECK_SUCCESS' in open(configDefaults.SERVER_OUT_FILE).read():
            print "\nDB configs consistency check: no errors and warnings were found."
    else:
        sys.stdout.write(configDefaults.SERVER_OUT_FILE + " does not exist")

    if exception:
        raise exception