Example usage for org.apache.hadoop.yarn YarnUncaughtExceptionHandler YarnUncaughtExceptionHandler

List of usage examples for org.apache.hadoop.yarn YarnUncaughtExceptionHandler YarnUncaughtExceptionHandler

Introduction

In this page you can find the example usage for org.apache.hadoop.yarn YarnUncaughtExceptionHandler YarnUncaughtExceptionHandler.

Prototype

YarnUncaughtExceptionHandler

Source Link

Usage

From source file:org.apache.slider.core.main.ServiceLauncher.java

License:Apache License

/**
 * The real main function, which takes the arguments as a list
 * arg 0 must be the service classname//  www  .  j  a  va  2s  .c om
 * @param argsList the list of arguments
 */
public static void serviceMain(List<String> argsList) {
    if (argsList.isEmpty()) {
        exitWithMessage(EXIT_USAGE, USAGE_MESSAGE);
    } else {
        String serviceClassName = argsList.get(0);

        if (LOG.isDebugEnabled()) {
            LOG.debug(startupShutdownMessage(serviceClassName, argsList));
            StringBuilder builder = new StringBuilder();
            for (String arg : argsList) {
                builder.append('"').append(arg).append("\" ");
            }
            LOG.debug(builder.toString());
        }
        Thread.setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler());

        ServiceLauncher serviceLauncher = new ServiceLauncher<Service>(serviceClassName);
        serviceLauncher.launchServiceAndExit(argsList);
    }
}

From source file:org.apache.tez.dag.app.DAGAppMaster.java

License:Apache License

public static void main(String[] args) {
    try {//from   w  ww .ja va 2 s . c o  m
        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);
        String clientVersion = System.getenv(TezConstants.TEZ_CLIENT_VERSION_ENV);
        if (clientVersion == null) {
            clientVersion = VersionInfo.UNKNOWN;
        }

        // TODO Should this be defaulting to 1. Was there a version of YARN where this was not setup ?
        int maxAppAttempts = 1;
        String maxAppAttemptsEnv = System.getenv(ApplicationConstants.MAX_APP_ATTEMPTS_ENV);
        if (maxAppAttemptsEnv != null) {
            maxAppAttempts = Integer.valueOf(maxAppAttemptsEnv);
        }

        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);

        // TODO Does this really need to be a YarnConfiguration ?
        Configuration conf = new Configuration(new YarnConfiguration());
        TezUtilsInternal.addUserSpecifiedTezConfiguration(System.getenv(Environment.PWD.name()), conf);
        UserGroupInformation.setConfiguration(conf);
        Credentials credentials = UserGroupInformation.getCurrentUser().getCredentials();

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

        initAndStartAppMaster(appMaster, conf);

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

From source file:org.apache.tez.runtime.task.TezChild.java

License:Apache License

public static void main(String[] args) throws IOException, InterruptedException, TezException {

    final Configuration defaultConf = new Configuration();

    Thread.setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler());
    LOG.info("TezChild starting");

    assert args.length == 5;
    String host = args[0];/*from  w  w  w.  j a v  a2 s .  co  m*/
    int port = Integer.parseInt(args[1]);
    final String containerIdentifier = args[2];
    final String tokenIdentifier = args[3];
    final int attemptNumber = Integer.parseInt(args[4]);
    final String[] localDirs = TezCommonUtils.getTrimmedStrings(System.getenv(Environment.LOCAL_DIRS.name()));
    final String pid = System.getenv().get("JVM_PID");
    LOG.info("PID, containerIdentifier:  " + pid + ", " + containerIdentifier);
    if (LOG.isDebugEnabled()) {
        LOG.debug("Info from cmd line: AM-host: " + host + " AM-port: " + port + " containerIdentifier: "
                + containerIdentifier + " appAttemptNumber: " + attemptNumber + " tokenIdentifier: "
                + tokenIdentifier);
    }

    // Security framework already loaded the tokens into current ugi
    TezUtilsInternal.addUserSpecifiedTezConfiguration(System.getenv(Environment.PWD.name()), defaultConf);
    UserGroupInformation.setConfiguration(defaultConf);
    Credentials credentials = UserGroupInformation.getCurrentUser().getCredentials();
    TezChild tezChild = newTezChild(defaultConf, host, port, containerIdentifier, tokenIdentifier,
            attemptNumber, localDirs, System.getenv(Environment.PWD.name()), System.getenv(), pid,
            new ExecutionContextImpl(System.getenv(Environment.NM_HOST.name())), credentials,
            Runtime.getRuntime().maxMemory(), System.getenv(ApplicationConstants.Environment.USER.toString()));
    tezChild.run();
}