Integer.toString(Commands.SIGNAL_CONTAINER.getValue()), pid, Integer.toString(signal.getValue()) }; ShellCommandExecutor shExec = new ShellCommandExecutor(command); if (LOG.isDebugEnabled()) {
String user = container.getUser(); Signal signal = translateCommandToSignal(command); if (signal.equals(Signal.NULL)) { LOG.info("ignore signal command " + command); return;
String stopSignal = ContainerExecutor.Signal.TERM.toString(); char delimiter = ','; DockerInspectCommand inspectCommand =
String user = container.getUser(); Signal signal = translateCommandToSignal(command); if (signal.equals(Signal.NULL)) { LOG.info("ignore signal command " + command); return;
if (DockerCommandExecutor.isKillable(containerStatus)) { DockerKillCommand dockerKillCommand = new DockerKillCommand(containerId).setSignal(signal.name()); DockerCommandExecutor.executeDockerCommand(dockerKillCommand, containerId, env, privilegedOperationExecutor, false, nmContext); .SIGNAL_CONTAINER.getValue()), ctx.getExecutionAttribute(PID), Integer.toString(ctx.getExecutionAttribute(SIGNAL).getValue())); privOp.disableFailureLogging(); try { + "signal: " + signal.name(), e .getExitCode(), e.getOutput(), e.getErrorOutput());
ctx.getContainer().getLaunchContext().getEnvironment(); try { if (ContainerExecutor.Signal.NULL.equals(signal)) { executeLivelinessCheck(ctx); } else if (ContainerExecutor.Signal.TERM.equals(signal)) { ContainerId containerId = ctx.getContainer().getContainerId(); handleContainerStop(containerId, env);
/** * Retrun true if we are trying to signal the same process. * @param obj compare to this object * @return whether we try to signal the same process id */ @Override public boolean equals(Object obj) { if (obj instanceof ContainerSignalContext) { ContainerSignalContext other = (ContainerSignalContext)obj; boolean ret = (other.getPid() == null && getPid() == null) || (other.getPid() != null && getPid() != null && other.getPid().equals(getPid())); ret = ret && (other.getSignal() == null && getSignal() == null) || (other.getSignal() != null && getSignal() != null && other.getSignal().equals(getSignal())); ret = ret && (other.getContainer() == null && getContainer() == null) || (other.getContainer() != null && getContainer() != null && other.getContainer().equals(getContainer())); ret = ret && (other.getUser() == null && getUser() == null) || (other.getUser() != null && getUser() != null && other.getUser().equals(getUser())); return ret; } return super.equals(obj); }
Integer.toString(Commands.SIGNAL_CONTAINER.getValue()), pid, Integer.toString(signal.getValue()) }; ShellCommandExecutor shExec = new ShellCommandExecutor(command); if (LOG.isDebugEnabled()) {
@Override public void signalContainer(ContainerRuntimeContext ctx) throws ContainerExecutionException { Container container = ctx.getContainer(); PrivilegedOperation signalOp = new PrivilegedOperation( PrivilegedOperation.OperationType.SIGNAL_CONTAINER); signalOp.appendArgs(ctx.getExecutionAttribute(RUN_AS_USER), ctx.getExecutionAttribute(USER), Integer.toString(PrivilegedOperation.RunAsUserCommand .SIGNAL_CONTAINER.getValue()), ctx.getExecutionAttribute(PID), Integer.toString(ctx.getExecutionAttribute(SIGNAL).getValue())); //Some failures here are acceptable. Let the calling executor decide. signalOp.disableFailureLogging(); try { PrivilegedOperationExecutor executor = PrivilegedOperationExecutor .getInstance(conf); executor.executePrivilegedOperation(null, signalOp, null, container.getLaunchContext().getEnvironment(), false, true); } catch (PrivilegedOperationException e) { //Don't log the failure here. Some kinds of signaling failures are // acceptable. Let the calling executor decide what to do. throw new ContainerExecutionException("Signal container failed", e .getExitCode(), e.getOutput(), e.getErrorOutput()); } }
@Override public void signalContainer(ContainerRuntimeContext ctx) throws ContainerExecutionException { PrivilegedOperation signalOp = new PrivilegedOperation( PrivilegedOperation.OperationType.SIGNAL_CONTAINER); signalOp.appendArgs(ctx.getExecutionAttribute(RUN_AS_USER), ctx.getExecutionAttribute(USER), Integer.toString(PrivilegedOperation.RunAsUserCommand .SIGNAL_CONTAINER.getValue()), ctx.getExecutionAttribute(PID), Integer.toString(ctx.getExecutionAttribute(SIGNAL).getValue())); //Some failures here are acceptable. Let the calling executor decide. signalOp.disableFailureLogging(); try { PrivilegedOperationExecutor executor = PrivilegedOperationExecutor .getInstance(conf); executor.executePrivilegedOperation(null, signalOp, null, null, false, false); } catch (PrivilegedOperationException e) { //Don't log the failure here. Some kinds of signaling failures are // acceptable. Let the calling executor decide what to do. throw new ContainerExecutionException("Signal container failed", e .getExitCode(), e.getOutput(), e.getErrorOutput()); } }
@Override public void signalContainer(ContainerRuntimeContext ctx) throws ContainerExecutionException { Container container = ctx.getContainer(); PrivilegedOperation signalOp = new PrivilegedOperation( PrivilegedOperation.OperationType.SIGNAL_CONTAINER); signalOp.appendArgs(ctx.getExecutionAttribute(RUN_AS_USER), ctx.getExecutionAttribute(USER), Integer.toString(PrivilegedOperation .RunAsUserCommand.SIGNAL_CONTAINER.getValue()), ctx.getExecutionAttribute(PID), Integer.toString(ctx.getExecutionAttribute(SIGNAL).getValue())); try { PrivilegedOperationExecutor executor = PrivilegedOperationExecutor .getInstance(conf); executor.executePrivilegedOperation(null, signalOp, null, container.getLaunchContext().getEnvironment(), false, true); } catch (PrivilegedOperationException e) { LOG.warn("Signal container failed. Exception: ", e); throw new ContainerExecutionException("Signal container failed", e .getExitCode(), e.getOutput(), e.getErrorOutput()); } }
@Override public boolean signalContainer(ContainerSignalContext ctx) throws IOException { String user = ctx.getUser(); String pid = ctx.getPid(); Signal signal = ctx.getSignal(); if (LOG.isDebugEnabled()) { LOG.debug("Sending signal " + signal.getValue() + " to pid " + pid + " as user " + user); } if (!containerIsAlive(pid)) { return false; } try { killContainer(pid, signal); } catch (IOException e) { if (!containerIsAlive(pid)) { return false; } throw e; } return true; }
@Override public boolean signalContainer(ContainerSignalContext ctx) throws IOException { String user = ctx.getUser(); String pid = ctx.getPid(); Signal signal = ctx.getSignal(); if (LOG.isDebugEnabled()) { LOG.debug("Sending signal " + signal.getValue() + " to pid " + pid + " as user " + user); } if (!containerIsAlive(pid)) { return false; } try { killContainer(pid, signal); } catch (IOException e) { if (!containerIsAlive(pid)) { return false; } throw e; } return true; }
@Override public boolean signalContainer(String user, String pid, Signal signal) throws IOException { if (LOG.isDebugEnabled()) { LOG.debug("Sending signal " + signal.getValue() + " to pid " + pid + " as user " + user); } if (!containerIsAlive(pid)) { return false; } try { killContainer(pid, signal); } catch (IOException e) { if (!containerIsAlive(pid)) { return false; } throw e; } return true; }
@Override public boolean signalContainer(ContainerSignalContext ctx) throws IOException { String user = ctx.getUser(); String pid = ctx.getPid(); Signal signal = ctx.getSignal(); LOG.debug("Sending signal " + signal.getValue() + " to pid " + pid + " as user " + user); if (!containerIsAlive(pid)) { return false; } try { killContainer(pid, signal); } catch (IOException e) { if (!containerIsAlive(pid)) { return false; } throw e; } return true; }
@Override public boolean signalContainer(String user, String pid, Signal signal) throws IOException { LOG.debug("Sending signal " + signal.getValue() + " to pid " + pid + " as user " + user); if (!containerIsAlive(pid)) { return false; } try { killContainer(pid, signal); } catch (IOException e) { if (!containerIsAlive(pid)) { return false; } throw e; } return true; }
@Override public boolean signalContainer(String user, String pid, Signal signal) throws IOException { if (LOG.isDebugEnabled()) { LOG.debug("Sending signal " + signal.getValue() + " to pid " + pid + " as user " + user); } if (!containerIsAlive(pid)) { return false; } try { killContainer(pid, signal); } catch (IOException e) { if (!containerIsAlive(pid)) { return false; } throw e; } return true; }
@Override public boolean signalContainer(String user, String pid, Signal signal) throws IOException { LOG.debug("Sending signal " + signal.getValue() + " to pid " + pid + " as user " + user); if (!containerIsAlive(pid)) { return false; } try { killContainer(pid, signal); } catch (IOException e) { if (!containerIsAlive(pid)) { return false; } throw e; } return true; }
/** * Send a specified signal to the specified pid * * @param pid the pid of the process [group] to signal. * @param signal signal to send * (for logging). */ protected void killContainer(String pid, Signal signal) throws IOException { new ShellCommandExecutor(Shell.getSignalKillCommand(signal.getValue(), pid)) .execute(); }
/** * Send a specified signal to the specified pid * * @param pid the pid of the process [group] to signal. * @param signal signal to send * @throws IOException if the command to kill the process fails */ protected void killContainer(String pid, Signal signal) throws IOException { new ShellCommandExecutor(Shell.getSignalKillCommand(signal.getValue(), pid)) .execute(); }