org.apache.hadoop.yarn.YarnUncaughtExceptionHandler Java Examples

The following examples show how to use org.apache.hadoop.yarn.YarnUncaughtExceptionHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JobHistoryServer.java    From XLearning with Apache License 2.0 6 votes vote down vote up
static JobHistoryServer launchJobHistoryServer(String[] args) {
  Thread.
      setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler());
  StringUtils.startupShutdownMessage(JobHistoryServer.class, args, LOG);
  JobHistoryServer jobHistoryServer = null;
  try {
    jobHistoryServer = new JobHistoryServer();
    ShutdownHookManager.get().addShutdownHook(
        new CompositeServiceShutdownHook(jobHistoryServer),
        SHUTDOWN_HOOK_PRIORITY);
    YarnConfiguration conf = new YarnConfiguration(new JobConf());
    new GenericOptionsParser(conf, args);
    jobHistoryServer.init(conf);
    jobHistoryServer.start();
  } catch (Throwable t) {
    LOG.fatal("Error starting JobHistoryServer", t);
    ExitUtil.terminate(-1, "Error starting JobHistoryServer");
  }
  return jobHistoryServer;
}
 
Example #2
Source File: JobHistoryServer.java    From big-c with Apache License 2.0 6 votes vote down vote up
static JobHistoryServer launchJobHistoryServer(String[] args) {
  Thread.
      setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler());
  StringUtils.startupShutdownMessage(JobHistoryServer.class, args, LOG);
  JobHistoryServer jobHistoryServer = null;
  try {
    jobHistoryServer = new JobHistoryServer();
    ShutdownHookManager.get().addShutdownHook(
        new CompositeServiceShutdownHook(jobHistoryServer),
        SHUTDOWN_HOOK_PRIORITY);
    YarnConfiguration conf = new YarnConfiguration(new JobConf());
    new GenericOptionsParser(conf, args);
    jobHistoryServer.init(conf);
    jobHistoryServer.start();
  } catch (Throwable t) {
    LOG.fatal("Error starting JobHistoryServer", t);
    ExitUtil.terminate(-1, "Error starting JobHistoryServer");
  }
  return jobHistoryServer;
}
 
Example #3
Source File: SharedCacheManager.java    From hadoop with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
  Thread.setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler());
  StringUtils.startupShutdownMessage(SharedCacheManager.class, args, LOG);
  try {
    Configuration conf = new YarnConfiguration();
    SharedCacheManager sharedCacheManager = new SharedCacheManager();
    ShutdownHookManager.get().addShutdownHook(
        new CompositeServiceShutdownHook(sharedCacheManager),
        SHUTDOWN_HOOK_PRIORITY);
    sharedCacheManager.init(conf);
    sharedCacheManager.start();
  } catch (Throwable t) {
    LOG.fatal("Error starting SharedCacheManager", t);
    System.exit(-1);
  }
}
 
Example #4
Source File: ApplicationHistoryServer.java    From big-c with Apache License 2.0 6 votes vote down vote up
static ApplicationHistoryServer launchAppHistoryServer(String[] args) {
  Thread
    .setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler());
  StringUtils.startupShutdownMessage(ApplicationHistoryServer.class, args,
    LOG);
  ApplicationHistoryServer appHistoryServer = null;
  try {
    appHistoryServer = new ApplicationHistoryServer();
    ShutdownHookManager.get().addShutdownHook(
      new CompositeServiceShutdownHook(appHistoryServer),
      SHUTDOWN_HOOK_PRIORITY);
    YarnConfiguration conf = new YarnConfiguration();
    new GenericOptionsParser(conf, args);
    appHistoryServer.init(conf);
    appHistoryServer.start();
  } catch (Throwable t) {
    LOG.fatal("Error starting ApplicationHistoryServer", t);
    ExitUtil.terminate(-1, "Error starting ApplicationHistoryServer");
  }
  return appHistoryServer;
}
 
Example #5
Source File: ResourceManager.java    From big-c with Apache License 2.0 6 votes vote down vote up
public static void main(String argv[]) {

   Thread.setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler());
   StringUtils.startupShutdownMessage(ResourceManager.class, argv, LOG);
   try {

     Configuration conf = new YarnConfiguration();
     GenericOptionsParser hParser = new GenericOptionsParser(conf, argv);
     argv = hParser.getRemainingArgs();
     // If -format-state-store, then delete RMStateStore; else startup normally
     if (argv.length == 1 && argv[0].equals("-format-state-store")) {
       deleteRMStateStore(conf);
     } else {
       ResourceManager resourceManager = new ResourceManager();
       ShutdownHookManager.get().addShutdownHook(
         new CompositeServiceShutdownHook(resourceManager),
         SHUTDOWN_HOOK_PRIORITY);
       resourceManager.init(conf);
       resourceManager.start();
     }
   } catch (Throwable t) {
     LOG.fatal("Error starting ResourceManager", t);
     System.exit(-1);
   }
   
 }
 
Example #6
Source File: ResourceManager.java    From hadoop with Apache License 2.0 6 votes vote down vote up
public static void main(String argv[]) {
  Thread.setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler());
  StringUtils.startupShutdownMessage(ResourceManager.class, argv, LOG);
  try {
    Configuration conf = new YarnConfiguration();
    GenericOptionsParser hParser = new GenericOptionsParser(conf, argv);
    argv = hParser.getRemainingArgs();
    // If -format-state-store, then delete RMStateStore; else startup normally
    if (argv.length == 1 && argv[0].equals("-format-state-store")) {
      deleteRMStateStore(conf);
    } else {
      ResourceManager resourceManager = new ResourceManager();
      ShutdownHookManager.get().addShutdownHook(
        new CompositeServiceShutdownHook(resourceManager),
        SHUTDOWN_HOOK_PRIORITY);
      resourceManager.init(conf);
      resourceManager.start();
    }
  } catch (Throwable t) {
    LOG.fatal("Error starting ResourceManager", t);
    System.exit(-1);
  }
}
 
Example #7
Source File: ApplicationHistoryServer.java    From hadoop with Apache License 2.0 6 votes vote down vote up
static ApplicationHistoryServer launchAppHistoryServer(String[] args) {
  Thread
    .setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler());
  StringUtils.startupShutdownMessage(ApplicationHistoryServer.class, args,
    LOG);
  ApplicationHistoryServer appHistoryServer = null;
  try {
    appHistoryServer = new ApplicationHistoryServer();
    ShutdownHookManager.get().addShutdownHook(
      new CompositeServiceShutdownHook(appHistoryServer),
      SHUTDOWN_HOOK_PRIORITY);
    YarnConfiguration conf = new YarnConfiguration();
    new GenericOptionsParser(conf, args);
    appHistoryServer.init(conf);
    appHistoryServer.start();
  } catch (Throwable t) {
    LOG.fatal("Error starting ApplicationHistoryServer", t);
    ExitUtil.terminate(-1, "Error starting ApplicationHistoryServer");
  }
  return appHistoryServer;
}
 
Example #8
Source File: JobHistoryServer.java    From hadoop with Apache License 2.0 6 votes vote down vote up
static JobHistoryServer launchJobHistoryServer(String[] args) {
  Thread.
      setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler());
  StringUtils.startupShutdownMessage(JobHistoryServer.class, args, LOG);
  JobHistoryServer jobHistoryServer = null;
  try {
    jobHistoryServer = new JobHistoryServer();
    ShutdownHookManager.get().addShutdownHook(
        new CompositeServiceShutdownHook(jobHistoryServer),
        SHUTDOWN_HOOK_PRIORITY);
    YarnConfiguration conf = new YarnConfiguration(new JobConf());
    new GenericOptionsParser(conf, args);
    jobHistoryServer.init(conf);
    jobHistoryServer.start();
  } catch (Throwable t) {
    LOG.fatal("Error starting JobHistoryServer", t);
    ExitUtil.terminate(-1, "Error starting JobHistoryServer");
  }
  return jobHistoryServer;
}
 
Example #9
Source File: AMSApplicationServer.java    From ambari-metrics with Apache License 2.0 6 votes vote down vote up
static AMSApplicationServer launchAMSApplicationServer(String[] args) {
  Thread.setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler());
  StringUtils.startupShutdownMessage(AMSApplicationServer.class, args, LOG);
  AMSApplicationServer amsApplicationServer = null;
  try {
    amsApplicationServer = new AMSApplicationServer();
    ShutdownHookManager.get().addShutdownHook(
      new CompositeServiceShutdownHook(amsApplicationServer),
      SHUTDOWN_HOOK_PRIORITY);
    YarnConfiguration conf = new YarnConfiguration();
    amsApplicationServer.init(conf);
    amsApplicationServer.start();
  } catch (Throwable t) {
    LOG.fatal("Error starting AMSApplicationServer", t);
    ExitUtil.terminate(-1, "Error starting AMSApplicationServer");
  }
  return amsApplicationServer;
}
 
Example #10
Source File: SharedCacheManager.java    From big-c with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
  Thread.setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler());
  StringUtils.startupShutdownMessage(SharedCacheManager.class, args, LOG);
  try {
    Configuration conf = new YarnConfiguration();
    SharedCacheManager sharedCacheManager = new SharedCacheManager();
    ShutdownHookManager.get().addShutdownHook(
        new CompositeServiceShutdownHook(sharedCacheManager),
        SHUTDOWN_HOOK_PRIORITY);
    sharedCacheManager.init(conf);
    sharedCacheManager.start();
  } catch (Throwable t) {
    LOG.fatal("Error starting SharedCacheManager", t);
    System.exit(-1);
  }
}
 
Example #11
Source File: WebAppProxyServer.java    From big-c with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
  Thread.setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler());
  StringUtils.startupShutdownMessage(WebAppProxyServer.class, args, LOG);
  try {
    YarnConfiguration configuration = new YarnConfiguration();
    new GenericOptionsParser(configuration, args);
    WebAppProxyServer proxyServer = startServer(configuration);
    proxyServer.proxy.join();
  } catch (Throwable t) {
    ExitUtil.terminate(-1, t);
  }
}
 
Example #12
Source File: NodeManager.java    From big-c with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws IOException {
  Thread.setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler());
  StringUtils.startupShutdownMessage(NodeManager.class, args, LOG);
  NodeManager nodeManager = new NodeManager();
  Configuration conf = new YarnConfiguration();
  new GenericOptionsParser(conf, args);
  nodeManager.initAndStartNodeManager(conf, false);
}
 
Example #13
Source File: NodeManager.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws IOException {
  Thread.setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler());
  StringUtils.startupShutdownMessage(NodeManager.class, args, LOG);
  NodeManager nodeManager = new NodeManager();
  Configuration conf = new YarnConfiguration();
  new GenericOptionsParser(conf, args);
  nodeManager.initAndStartNodeManager(conf, false);
}
 
Example #14
Source File: WebAppProxyServer.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
  Thread.setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler());
  StringUtils.startupShutdownMessage(WebAppProxyServer.class, args, LOG);
  try {
    YarnConfiguration configuration = new YarnConfiguration();
    new GenericOptionsParser(configuration, args);
    WebAppProxyServer proxyServer = startServer(configuration);
    proxyServer.proxy.join();
  } catch (Throwable t) {
    ExitUtil.terminate(-1, t);
  }
}
 
Example #15
Source File: ContainerLocalizer.java    From big-c with Apache License 2.0 4 votes vote down vote up
public static void main(String[] argv) throws Throwable {
  Thread.setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler());
  // usage: $0 user appId locId host port app_log_dir user_dir [user_dir]*
  // let $x = $x/usercache for $local.dir
  // MKDIR $x/$user/appcache/$appid
  // MKDIR $x/$user/appcache/$appid/output
  // MKDIR $x/$user/appcache/$appid/filecache
  // LOAD $x/$user/appcache/$appid/appTokens
  try {
    String user = argv[0];
    String appId = argv[1];
    String locId = argv[2];
    InetSocketAddress nmAddr =
        new InetSocketAddress(argv[3], Integer.parseInt(argv[4]));
    String[] sLocaldirs = Arrays.copyOfRange(argv, 5, argv.length);
    ArrayList<Path> localDirs = new ArrayList<Path>(sLocaldirs.length);
    for (String sLocaldir : sLocaldirs) {
      localDirs.add(new Path(sLocaldir));
    }

    final String uid =
        UserGroupInformation.getCurrentUser().getShortUserName();
    if (!user.equals(uid)) {
      // TODO: fail localization
      LOG.warn("Localization running as " + uid + " not " + user);
    }

    ContainerLocalizer localizer =
        new ContainerLocalizer(FileContext.getLocalFSFileContext(), user,
            appId, locId, localDirs,
            RecordFactoryProvider.getRecordFactory(null));
    int nRet = localizer.runLocalization(nmAddr);
    if (LOG.isDebugEnabled()) {
      LOG.debug(String.format("nRet: %d", nRet));
    }
    System.exit(nRet);
  } catch (Throwable e) {
    // Print error to stdout so that LCE can use it.
    e.printStackTrace(System.out);
    LOG.error("Exception in main:", e);
    throw e;
  }
}
 
Example #16
Source File: MRAppMaster.java    From hadoop with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {
  try {
    Thread.setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler());
    String containerIdStr =
        System.getenv(Environment.CONTAINER_ID.name());
    String nodeHostString = System.getenv(Environment.NM_HOST.name());
    String nodePortString = System.getenv(Environment.NM_PORT.name());
    String nodeHttpPortString =
        System.getenv(Environment.NM_HTTP_PORT.name());
    String appSubmitTimeStr =
        System.getenv(ApplicationConstants.APP_SUBMIT_TIME_ENV);
    
    validateInputParam(containerIdStr,
        Environment.CONTAINER_ID.name());
    validateInputParam(nodeHostString, Environment.NM_HOST.name());
    validateInputParam(nodePortString, Environment.NM_PORT.name());
    validateInputParam(nodeHttpPortString,
        Environment.NM_HTTP_PORT.name());
    validateInputParam(appSubmitTimeStr,
        ApplicationConstants.APP_SUBMIT_TIME_ENV);

    ContainerId containerId = ConverterUtils.toContainerId(containerIdStr);
    ApplicationAttemptId applicationAttemptId =
        containerId.getApplicationAttemptId();
    long appSubmitTime = Long.parseLong(appSubmitTimeStr);
    
    
    MRAppMaster appMaster =
        new MRAppMaster(applicationAttemptId, containerId, nodeHostString,
            Integer.parseInt(nodePortString),
            Integer.parseInt(nodeHttpPortString), appSubmitTime);
    ShutdownHookManager.get().addShutdownHook(
      new MRAppMasterShutdownHook(appMaster), SHUTDOWN_HOOK_PRIORITY);
    JobConf conf = new JobConf(new YarnConfiguration());
    conf.addResource(new Path(MRJobConfig.JOB_CONF_FILE));
    
    MRWebAppUtil.initialize(conf);
    String jobUserName = System
        .getenv(ApplicationConstants.Environment.USER.name());
    conf.set(MRJobConfig.USER_NAME, jobUserName);
    initAndStartAppMaster(appMaster, conf, jobUserName);
  } catch (Throwable t) {
    LOG.fatal("Error starting MRAppMaster", t);
    ExitUtil.terminate(1, t);
  }
}
 
Example #17
Source File: ContainerLocalizer.java    From hadoop with Apache License 2.0 4 votes vote down vote up
public static void main(String[] argv) throws Throwable {
  Thread.setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler());
  // usage: $0 user appId locId host port app_log_dir user_dir [user_dir]*
  // let $x = $x/usercache for $local.dir
  // MKDIR $x/$user/appcache/$appid
  // MKDIR $x/$user/appcache/$appid/output
  // MKDIR $x/$user/appcache/$appid/filecache
  // LOAD $x/$user/appcache/$appid/appTokens
  try {
    String user = argv[0];
    String appId = argv[1];
    String locId = argv[2];
    InetSocketAddress nmAddr =
        new InetSocketAddress(argv[3], Integer.parseInt(argv[4]));
    String[] sLocaldirs = Arrays.copyOfRange(argv, 5, argv.length);
    ArrayList<Path> localDirs = new ArrayList<Path>(sLocaldirs.length);
    for (String sLocaldir : sLocaldirs) {
      localDirs.add(new Path(sLocaldir));
    }

    final String uid =
        UserGroupInformation.getCurrentUser().getShortUserName();
    if (!user.equals(uid)) {
      // TODO: fail localization
      LOG.warn("Localization running as " + uid + " not " + user);
    }

    ContainerLocalizer localizer =
        new ContainerLocalizer(FileContext.getLocalFSFileContext(), user,
            appId, locId, localDirs,
            RecordFactoryProvider.getRecordFactory(null));
    int nRet = localizer.runLocalization(nmAddr);
    if (LOG.isDebugEnabled()) {
      LOG.debug(String.format("nRet: %d", nRet));
    }
    System.exit(nRet);
  } catch (Throwable e) {
    // Print error to stdout so that LCE can use it.
    e.printStackTrace(System.out);
    LOG.error("Exception in main:", e);
    throw e;
  }
}
 
Example #18
Source File: MRAppMaster.java    From big-c with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {
  try {
    Thread.setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler());
    String containerIdStr =
        System.getenv(Environment.CONTAINER_ID.name());
    String nodeHostString = System.getenv(Environment.NM_HOST.name());
    String nodePortString = System.getenv(Environment.NM_PORT.name());
    String nodeHttpPortString =
        System.getenv(Environment.NM_HTTP_PORT.name());
    String appSubmitTimeStr =
        System.getenv(ApplicationConstants.APP_SUBMIT_TIME_ENV);
    
    validateInputParam(containerIdStr,
        Environment.CONTAINER_ID.name());
    validateInputParam(nodeHostString, Environment.NM_HOST.name());
    validateInputParam(nodePortString, Environment.NM_PORT.name());
    validateInputParam(nodeHttpPortString,
        Environment.NM_HTTP_PORT.name());
    validateInputParam(appSubmitTimeStr,
        ApplicationConstants.APP_SUBMIT_TIME_ENV);

    ContainerId containerId = ConverterUtils.toContainerId(containerIdStr);
    ApplicationAttemptId applicationAttemptId =
        containerId.getApplicationAttemptId();
    long appSubmitTime = Long.parseLong(appSubmitTimeStr);
    
    
    MRAppMaster appMaster =
        new MRAppMaster(applicationAttemptId, containerId, nodeHostString,
            Integer.parseInt(nodePortString),
            Integer.parseInt(nodeHttpPortString), appSubmitTime);
    ShutdownHookManager.get().addShutdownHook(
      new MRAppMasterShutdownHook(appMaster), SHUTDOWN_HOOK_PRIORITY);
    JobConf conf = new JobConf(new YarnConfiguration());
    conf.addResource(new Path(MRJobConfig.JOB_CONF_FILE));
    
    MRWebAppUtil.initialize(conf);
    String jobUserName = System
        .getenv(ApplicationConstants.Environment.USER.name());
    conf.set(MRJobConfig.USER_NAME, jobUserName);
    initAndStartAppMaster(appMaster, conf, jobUserName);
  } catch (Throwable t) {
    LOG.fatal("Error starting MRAppMaster", t);
    ExitUtil.terminate(1, t);
  }
}
 
Example #19
Source File: DAGAppMaster.java    From incubator-tez with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {
  try {
    Thread.setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler());
    String containerIdStr =
        System.getenv(Environment.CONTAINER_ID.name());
    String nodeHostString = System.getenv(Environment.NM_HOST.name());
    String nodePortString = System.getenv(Environment.NM_PORT.name());
    String nodeHttpPortString =
        System.getenv(Environment.NM_HTTP_PORT.name());
    String appSubmitTimeStr =
        System.getenv(ApplicationConstants.APP_SUBMIT_TIME_ENV);

    validateInputParam(appSubmitTimeStr,
        ApplicationConstants.APP_SUBMIT_TIME_ENV);

    ContainerId containerId = ConverterUtils.toContainerId(containerIdStr);
    ApplicationAttemptId applicationAttemptId =
        containerId.getApplicationAttemptId();

    long appSubmitTime = Long.parseLong(appSubmitTimeStr);

    final Configuration conf = new Configuration(new YarnConfiguration());
    TezUtils.addUserSpecifiedTezConfiguration(conf);

    String jobUserName = System
        .getenv(ApplicationConstants.Environment.USER.name());

    // Do not automatically close FileSystem objects so that in case of
    // SIGTERM I have a chance to write out the job history. I'll be closing
    // the objects myself.
    conf.setBoolean("fs.automatic.close", false);

    // Command line options
    Options opts = new Options();
    opts.addOption(TezConstants.TEZ_SESSION_MODE_CLI_OPTION,
        false, "Run Tez Application Master in Session mode");

    CommandLine cliParser = new GnuParser().parse(opts, args);

    DAGAppMaster appMaster =
        new DAGAppMaster(applicationAttemptId, containerId, nodeHostString,
            Integer.parseInt(nodePortString),
            Integer.parseInt(nodeHttpPortString), appSubmitTime,
            cliParser.hasOption(TezConstants.TEZ_SESSION_MODE_CLI_OPTION));
    ShutdownHookManager.get().addShutdownHook(
      new DAGAppMasterShutdownHook(appMaster), SHUTDOWN_HOOK_PRIORITY);

    Limits.setConfiguration(conf);
    initAndStartAppMaster(appMaster, conf,
        jobUserName);

  } catch (Throwable t) {
    LOG.fatal("Error starting DAGAppMaster", t);
    System.exit(1);
  }
}
 
Example #20
Source File: DAGAppMaster.java    From tez with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {
  try {
    Thread.setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler());
    final String pid = System.getenv().get("JVM_PID");
    String containerIdStr =
        System.getenv(Environment.CONTAINER_ID.name());
    String nodeHostString = System.getenv(Environment.NM_HOST.name());
    String nodePortString = System.getenv(Environment.NM_PORT.name());
    String nodeHttpPortString =
        System.getenv(Environment.NM_HTTP_PORT.name());
    String appSubmitTimeStr =
        System.getenv(ApplicationConstants.APP_SUBMIT_TIME_ENV);
    String clientVersion = System.getenv(TezConstants.TEZ_CLIENT_VERSION_ENV);
    if (clientVersion == null) {
      clientVersion = VersionInfo.UNKNOWN;
    }

    validateInputParam(appSubmitTimeStr,
        ApplicationConstants.APP_SUBMIT_TIME_ENV);

    ContainerId containerId = ConverterUtils.toContainerId(containerIdStr);
    ApplicationAttemptId applicationAttemptId =
        containerId.getApplicationAttemptId();

    long appSubmitTime = Long.parseLong(appSubmitTimeStr);

    String jobUserName = System
        .getenv(ApplicationConstants.Environment.USER.name());

    // Command line options
    Options opts = new Options();
    opts.addOption(TezConstants.TEZ_SESSION_MODE_CLI_OPTION,
        false, "Run Tez Application Master in Session mode");

    CommandLine cliParser = new GnuParser().parse(opts, args);
    boolean sessionModeCliOption = cliParser.hasOption(TezConstants.TEZ_SESSION_MODE_CLI_OPTION);

    LOG.info("Creating DAGAppMaster for "
        + "applicationId=" + applicationAttemptId.getApplicationId()
        + ", attemptNum=" + applicationAttemptId.getAttemptId()
        + ", AMContainerId=" + containerId
        + ", jvmPid=" + pid
        + ", userFromEnv=" + jobUserName
        + ", cliSessionOption=" + sessionModeCliOption
        + ", pwd=" + System.getenv(Environment.PWD.name())
        + ", localDirs=" + System.getenv(Environment.LOCAL_DIRS.name())
        + ", logDirs=" + System.getenv(Environment.LOG_DIRS.name()));

    // TODO Does this really need to be a YarnConfiguration ?
    Configuration conf = new Configuration(new YarnConfiguration());

    ConfigurationProto confProto =
        TezUtilsInternal.readUserSpecifiedTezConfiguration(System.getenv(Environment.PWD.name()));
    TezUtilsInternal.addUserSpecifiedTezConfiguration(conf, confProto.getConfKeyValuesList());

    AMPluginDescriptorProto amPluginDescriptorProto = null;
    if (confProto.hasAmPluginDescriptor()) {
      amPluginDescriptorProto = confProto.getAmPluginDescriptor();
    }

    UserGroupInformation.setConfiguration(conf);
    Credentials credentials = UserGroupInformation.getCurrentUser().getCredentials();

    TezUtilsInternal.setSecurityUtilConfigration(LOG, conf);

    DAGAppMaster appMaster =
        new DAGAppMaster(applicationAttemptId, containerId, nodeHostString,
            Integer.parseInt(nodePortString),
            Integer.parseInt(nodeHttpPortString), new SystemClock(), appSubmitTime,
            sessionModeCliOption,
            System.getenv(Environment.PWD.name()),
            TezCommonUtils.getTrimmedStrings(System.getenv(Environment.LOCAL_DIRS.name())),
            TezCommonUtils.getTrimmedStrings(System.getenv(Environment.LOG_DIRS.name())),
            clientVersion, credentials, jobUserName, amPluginDescriptorProto);
    ShutdownHookManager.get().addShutdownHook(
      new DAGAppMasterShutdownHook(appMaster), SHUTDOWN_HOOK_PRIORITY);

    // log the system properties
    if (LOG.isInfoEnabled()) {
      String systemPropsToLog = TezCommonUtils.getSystemPropertiesToLog(conf);
      if (systemPropsToLog != null) {
        LOG.info(systemPropsToLog);
      }
    }

    initAndStartAppMaster(appMaster, conf);

  } catch (Throwable t) {
    LOG.error("Error starting DAGAppMaster", t);
    System.exit(1);
  }
}