protected void setContainerCompletedStatus(int exitCode) { ContainerId containerId = container.getContainerId(); completed.set(true); exec.deactivateContainer(containerId); try { if (!container.shouldRetry(exitCode)) { context.getNMStateStore().storeContainerCompleted(containerId, exitCode); } } catch (IOException e) { LOG.error("Unable to set exit code for container " + containerId); } }
LOG.debug("Deleting path: [" + subDir + "] as user: [" + user + "]"); if (baseDirs == null || baseDirs.size() == 0) { delService.exec.deleteAsUser(user, subDir, (Path[])null); } else { delService.exec.deleteAsUser(user, subDir, baseDirs.toArray(new Path[0]));
Path pidPath = getPidFilePath(containerId); if (pidPath == null) { LOG.warn(containerId + " is not active, returning terminated error"); while(isContainerProcessAlive(user, pid)) { Thread.sleep(1000); int msecLeft = 2000; while (!file.exists() && msecLeft >= 0) { if (!isContainerActive(containerId)) { LOG.info(containerId + " was deactivated"); return ExitCode.TERMINATED.getExitCode();
exec.writeLaunchEnv(containerScriptOutStream, environment, localResources, launchContext.getCommands()); exec.activateContainer(containerID, pidFilePath); ret = exec.launchContainer(container, nmPrivateContainerScriptPath, nmPrivateTokensPath, user, appIdStr, containerWorkDir, localDirs, logDirs); } finally { completed.set(true); exec.deactivateContainer(containerID); try { context.getNMStateStore().storeContainerCompleted(containerID, ret);
String pidPathStr = pidFile.getPath(); pidFilePath = new Path(pidPathStr); exec.activateContainer(containerId, pidFilePath); retCode = exec.reacquireContainer(container.getUser(), containerId); } else { LOG.warn("Unable to locate pid file for container " + containerIdStr); if (notInterrupted) { this.completed.set(true); exec.deactivateContainer(containerId); try { getContext().getNMStateStore().storeContainerCompleted(containerId,
String user = ctx.getUser(); ContainerId containerId = ctx.getContainerId(); Path pidPath = getPidFilePath(containerId); .build(); while (isContainerAlive(livenessContext)) { Thread.sleep(1000); if (!isContainerActive(containerId)) { LOG.info(containerId + " was deactivated");
exec.deactivateContainer(containerId); : Signal.KILL; boolean result = exec.signalContainer(user, processId, signal);
protected String[] getRunCommand(String command, String groupId, String userName, Path pidFile, Configuration conf) { return getRunCommand(command, groupId, userName, pidFile, conf, null); }
DefaultContainerExecutor.class, ContainerExecutor.class), conf); try { exec.init(); } catch (IOException e) { throw new YarnRuntimeException("Failed to initialize container executor", e);
newClassPath.toString(), jarDir, pwd, mergedEnv); Path localizedClassPathJar = exec.localizeClasspathJar( new Path(jarCp[0]), pwd, container.getUser()); String replacementClassPath = localizedClassPathJar.toString() + jarCp[1];
pId = containerExecutor.getProcessId(ptInfo.getContainerId()); if (pId != null) {
/** * Perform any cleanup before the next launch of the container. * @param container container */ public void cleanupBeforeRelaunch(Container container) throws IOException, InterruptedException { if (container.getLocalizedResources() != null) { Map<Path, Path> symLinks = resolveSymLinks( container.getLocalizedResources(), container.getUser()); for (Map.Entry<Path, Path> symLink : symLinks.entrySet()) { LOG.debug("{} deleting {}", container.getContainerId(), symLink.getValue()); deleteAsUser(new DeletionAsUserContext.Builder() .setUser(container.getUser()) .setSubDir(symLink.getValue()) .build()); } } }
pId = containerExecutor.getProcessId(ptInfo.getContainerId()); if (pId != null) { String[] ipAndHost = containerExecutor.getIpAndHost(container);
protected int launchContainer(ContainerStartContext ctx) throws IOException, ConfigurationException { int launchPrep = prepareForLaunch(ctx); if (launchPrep == 0) { launchLock.lock(); try { return exec.launchContainer(ctx); } finally { launchLock.unlock(); } } return launchPrep; }
protected int prepareForLaunch(ContainerStartContext ctx) throws IOException { ContainerId containerId = container.getContainerId(); if (container.isMarkedForKilling()) { LOG.info("Container " + containerId + " not launched as it has already " + "been marked for Killing"); this.killedBeforeStart = true; return ExitCode.TERMINATED.getExitCode(); } // LaunchContainer is a blocking call. We are here almost means the // container is launched, so send out the event. dispatcher.getEventHandler().handle(new ContainerEvent( containerId, ContainerEventType.CONTAINER_LAUNCHED)); context.getNMStateStore().storeContainerLaunched(containerId); // Check if the container is signalled to be killed. if (!containerAlreadyLaunched.compareAndSet(false, true)) { LOG.info("Container " + containerId + " not launched as " + "cleanup already called"); return ExitCode.TERMINATED.getExitCode(); } else { exec.activateContainer(containerId, pidFilePath); } return ExitCode.SUCCESS.getExitCode(); }
exec.writeLaunchEnv(containerScriptOutStream, environment, localResources, launchContext.getCommands()); exec.activateContainer(containerID, pidFilePath); ret = exec.launchContainer(container, nmPrivateContainerScriptPath, nmPrivateTokensPath, user, appIdStr, containerWorkDir, localDirs, logDirs); } finally { completed.set(true); exec.deactivateContainer(containerID); try { context.getNMStateStore().storeContainerCompleted(containerID, ret);
String pidPathStr = pidFile.getPath(); pidFilePath = new Path(pidPathStr); exec.activateContainer(containerId, pidFilePath); retCode = exec.reacquireContainer(container.getUser(), containerId); } else { LOG.warn("Unable to locate pid file for container " + containerIdStr); if (notInterrupted) { this.completed.set(true); exec.deactivateContainer(containerId); try { getContext().getNMStateStore().storeContainerCompleted(containerId,
Path pidPath = getPidFilePath(containerId); if (pidPath == null) { LOG.warn(containerId + " is not active, returning terminated error"); .setPid(pid) .build(); while(isContainerAlive(livenessContext)) { Thread.sleep(1000); int msecLeft = 2000; while (!file.exists() && msecLeft >= 0) { if (!isContainerActive(containerId)) { LOG.info(containerId + " was deactivated"); return ExitCode.TERMINATED.getExitCode();
exec.deactivateContainer(containerId); : Signal.KILL; boolean result = exec.signalContainer(user, processId, signal);
protected String[] getRunCommand(String command, String groupId, String userName, Path pidFile, Configuration conf) { return getRunCommand(command, groupId, userName, pidFile, conf, null); }