def _build_master_java_args(username = None):
  hbase_home_dir = os.path.abspath(EMBEDDED_HBASE_SUBDIR)
  hbase_log_dir = os.path.join(os.sep, "var", "log", EMBEDDED_HBASE_MASTER_SERVICE)
  hbase_log_file = "hbase.log"
  hbase_user_id = username if username else "SYSTEM"
  java_library_path = os.path.join(hbase_home_dir, "bin")
  if not os.path.exists(hbase_log_dir):
    os.makedirs(hbase_log_dir)

  java_class_path = os.path.join(hbase_home_dir, "conf")
  java_class_path += os.pathsep + os.path.join(find_jdk(), "lib", "tools.jar")
  java_class_path += os.pathsep + hbase_home_dir
  java_class_path += os.pathsep + os.path.join(hbase_home_dir, "lib", "*")

  args = MASTER_JVM_ARGS.format(build_jvm_args(), hbase_home_dir, hbase_log_dir, hbase_log_file, hbase_user_id, java_class_path, java_library_path)

  return args
def _build_master_java_args(username=None):
    hbase_home_dir = os.path.abspath(EMBEDDED_HBASE_SUBDIR)
    hbase_log_dir = os.path.join(os.sep, "var", "log",
                                 EMBEDDED_HBASE_MASTER_SERVICE)
    hbase_log_file = "hbase.log"
    hbase_user_id = username if username else "SYSTEM"
    java_library_path = os.path.join(hbase_home_dir, "bin")
    if not os.path.exists(hbase_log_dir):
        os.makedirs(hbase_log_dir)

    java_class_path = os.path.join(hbase_home_dir, "conf")
    java_class_path += os.pathsep + os.path.join(find_jdk(), "lib",
                                                 "tools.jar")
    java_class_path += os.pathsep + hbase_home_dir
    java_class_path += os.pathsep + os.path.join(hbase_home_dir, "lib", "*")

    args = MASTER_JVM_ARGS.format(build_jvm_args(), hbase_home_dir,
                                  hbase_log_dir, hbase_log_file, hbase_user_id,
                                  java_class_path, java_library_path)

    return args
Esempio n. 3
0
def server_process_main(options, scmStatus=None):
    if scmStatus is not None:
        scmStatus.reportStartPending()

    # debug mode
    try:
        global DEBUG_MODE
        DEBUG_MODE = options.debug
    except AttributeError:
        pass

    # stop Java process at startup?
    try:
        global SUSPEND_START_MODE
        SUSPEND_START_MODE = options.suspend_start
    except AttributeError:
        pass

    #options.conf_dir <= --config
    if not os.path.isdir(options.conf_dir):
        err = 'ERROR: Cannot find configuration directory "{0}"'.format(
            options.conf_dir)
        raise FatalException(1, err)

    #execute ams-env.cmd
    exec_ams_env_cmd(options)

    #Ensure the 3 Hadoop services required are started on the local machine
    if not options.no_embedded_hbase:
        from amc_service import ensure_hadoop_service_soft_dependencies
        ensure_hadoop_service_soft_dependencies()

    if scmStatus is not None:
        scmStatus.reportStartPending()

    java_exe = get_java_exe_path()
    java_class_path = get_java_cp()
    java_heap_max = build_jvm_args()
    command_base = SERVER_START_CMD_DEBUG if (
        DEBUG_MODE or SERVER_START_DEBUG) else SERVER_START_CMD
    suspend_mode = 'y' if SUSPEND_START_MODE else 'n'
    command = command_base.format(java_class_path, java_heap_max, suspend_mode)
    if not os.path.exists(PID_DIR):
        os.makedirs(PID_DIR, 0755)

    #Ignore the requirement to run as root. In Windows, by default the child process inherits the security context
    # and the environment from the parent process.
    param_list = java_exe + " " + command

    print_info_msg("Running server: " + str(param_list))
    procJava = subprocess32.Popen(param_list, env=os.environ)

    #wait for server process for SERVER_START_TIMEOUT seconds
    print "Waiting for server start..."

    pidJava = procJava.pid
    if pidJava <= 0:
        procJava.terminate()
        exitcode = procJava.returncode
        save_pid(exitcode, EXITCODE_OUT_FILE)

        if scmStatus is not None:
            scmStatus.reportStopPending()

        raise FatalException(-1, AMC_DIE_MSG.format(exitcode, SERVER_OUT_FILE))
    else:
        save_pid(pidJava, PID_OUT_FILE)
        print "Server PID at: " + PID_OUT_FILE
        print "Server out at: " + SERVER_OUT_FILE
        print "Server log at: " + SERVER_LOG_FILE

    if scmStatus is not None:
        scmStatus.reportStarted()

    return procJava
Esempio n. 4
0
def server_process_main(options, scmStatus=None):
  if scmStatus is not None:
    scmStatus.reportStartPending()

  # debug mode
  try:
    global DEBUG_MODE
    DEBUG_MODE = options.debug
  except AttributeError:
    pass

  # stop Java process at startup?
  try:
    global SUSPEND_START_MODE
    SUSPEND_START_MODE = options.suspend_start
  except AttributeError:
    pass

  #options.conf_dir <= --config
  if not os.path.isdir(options.conf_dir):
    err = 'ERROR: Cannot find configuration directory "{0}"'.format(options.conf_dir)
    raise FatalException(1, err)

  #execute ams-env.cmd
  exec_ams_env_cmd(options)

  #Ensure the 3 Hadoop services required are started on the local machine
  if not options.no_embedded_hbase:
    from amc_service import ensure_hdp_service_soft_dependencies
    ensure_hdp_service_soft_dependencies()

  if scmStatus is not None:
    scmStatus.reportStartPending()

  java_exe = get_java_exe_path()
  java_class_path = get_java_cp()
  java_heap_max = build_jvm_args()
  command_base = SERVER_START_CMD_DEBUG if (DEBUG_MODE or SERVER_START_DEBUG) else SERVER_START_CMD
  suspend_mode = 'y' if SUSPEND_START_MODE else 'n'
  command = command_base.format(java_class_path, java_heap_max, suspend_mode)
  if not os.path.exists(PID_DIR):
    os.makedirs(PID_DIR, 0755)

  #Ignore the requirement to run as root. In Windows, by default the child process inherits the security context
  # and the environment from the parent process.
  param_list = java_exe + " " + command

  print_info_msg("Running server: " + str(param_list))
  procJava = subprocess.Popen(param_list, env=os.environ)

  #wait for server process for SERVER_START_TIMEOUT seconds
  print "Waiting for server start..."

  pidJava = procJava.pid
  if pidJava <= 0:
    procJava.terminate()
    exitcode = procJava.returncode
    save_pid(exitcode, EXITCODE_OUT_FILE)

    if scmStatus is not None:
      scmStatus.reportStopPending()

    raise FatalException(-1, AMC_DIE_MSG.format(exitcode, SERVER_OUT_FILE))
  else:
    save_pid(pidJava, PID_OUT_FILE)
    print "Server PID at: " + PID_OUT_FILE
    print "Server out at: " + SERVER_OUT_FILE
    print "Server log at: " + SERVER_LOG_FILE

  if scmStatus is not None:
    scmStatus.reportStarted()

  return procJava