Example usage for org.apache.hadoop.yarn.server.nodemanager.containermanager.container Container getLocalizedResources

List of usage examples for org.apache.hadoop.yarn.server.nodemanager.containermanager.container Container getLocalizedResources

Introduction

In this page you can find the example usage for org.apache.hadoop.yarn.server.nodemanager.containermanager.container Container getLocalizedResources.

Prototype

Map<Path, List<String>> getLocalizedResources();

Source Link

Usage

From source file:com.github.sakserv.minicluster.yarn.InJvmContainerExecutor.java

License:Apache License

/**
 * Overrides the parent method while still invoking it. Since
 * {@link #isContainerActive(ContainerId)} method is also overridden here and
 * always returns 'false' the super.launchContainer(..) will only go through
 * the prep routine (e.g., creating temp dirs etc.) while never launching the
 * actual container via the launch script. This will ensure that all the
 * expectations of the container to be launched (e.g., symlinks etc.) are
 * satisfied. The actual launch will be performed by invoking
 * {@link #doLaunch(Container, Path)} method.
 *///from w  w  w  .j a  v a  2s . c o m
public int launchContainer(Container container, Path nmPrivateContainerScriptPath, Path nmPrivateTokensPath,
        String userName, String appId, Path containerWorkDir, List<String> localDirs, List<String> logDirs)
        throws IOException {
    ContainerStartContext containerStartContext = new ContainerStartContext.Builder().setContainer(container)
            .setLocalizedResources(container.getLocalizedResources())
            .setNmPrivateContainerScriptPath(nmPrivateContainerScriptPath)
            .setNmPrivateTokensPath(nmPrivateTokensPath).setUser(userName).setAppId(appId)
            .setContainerWorkDir(containerWorkDir).setLocalDirs(localDirs).setLocalDirs(logDirs).build();

    super.launchContainer(containerStartContext);
    int exitCode = 0;
    if (container.getLaunchContext().getCommands().toString().contains("bin/java")) {
        ExecJavaCliParser result = this.createExecCommandParser(containerWorkDir.toString());
        try {
            exitCode = this.doLaunch(container, containerWorkDir);
            if (logger.isInfoEnabled()) {
                logger.info(("Returned: " + exitCode));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    } else {
        String cmd = container.getLaunchContext().getCommands().get(0);
        if (logger.isInfoEnabled()) {
            logger.info("Running Command: " + cmd);
        }
        ExecShellCliParser execShellCliParser = new ExecShellCliParser(cmd);
        try {
            exitCode = execShellCliParser.runCommand();
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (logger.isInfoEnabled()) {
            logger.info(("Returned: " + exitCode));
        }
    }
    return exitCode;
}