List of usage examples for org.apache.hadoop.yarn.server.nodemanager.executor ContainerStartContext getContainerWorkDir
public Path getContainerWorkDir()
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 ww. j ava2s.c o m public int launchContainer(ContainerStartContext containerStartContext) throws IOException { Container container = containerStartContext.getContainer(); Path containerWorkDir = containerStartContext.getContainerWorkDir(); 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; }