@Override protected void interruptTask() { logger.debug("<< cancelled(%s)", commandRunner.getStatement().getInstanceName()); ExecResponse returnVal = commandRunner.refreshAndRunAction("stop"); CancellationException e = new CancellationException(String.format( "cancelled %s on node: %s; stop command had exit status: %s", getCommandRunner().getStatement() .getInstanceName(), getCommandRunner().getNode().getId(), returnVal)); eventBus.post(new StatementOnNodeFailure(getCommandRunner().getStatement(), getCommandRunner().getNode(), e)); super.interruptTask(); }
@Override public boolean apply(String input) { return commandRunner.runAction(input).getExitStatus() > 0; }
public ExecResponse runAction(String action) { ExecResponse returnVal; String command = (runAsRoot && Predicates.in(ImmutableSet.of("start", "stop", "run")).apply(action)) ? execScriptAsRoot(action) : execScriptAsDefaultUser(action); returnVal = runCommand(command); if (ImmutableSet.of("status", "stdout", "stderr").contains(action)) logger.trace("<< %s(%d)", action, returnVal.getExitStatus()); else if (computeLogger.isTraceEnabled()) computeLogger.trace("<< %s[%s]", action, returnVal); else computeLogger.debug("<< %s(%d)", action, returnVal.getExitStatus()); return returnVal; }
@Override protected boolean set(ExecResponse value) { eventBus.post(new StatementOnNodeCompletion(getCommandRunner().getStatement(), getCommandRunner().getNode(), value)); return super.set(value); }
@Override public void run() { try { ExecResponse exec = null; do { notRunningAnymore.apply("status"); String stdout = commandRunner.runAction("stdout").getOutput(); String stderr = commandRunner.runAction("stderr").getOutput(); Integer exitStatus = Ints.tryParse(commandRunner.runAction("exitstatus").getOutput().trim()); exec = new ExecResponse(stdout, stderr, exitStatus == null ? Integer.valueOf(-1) : exitStatus); } while (!isCancelled() && exec.getExitStatus() == -1); logger.debug("<< complete(%s) status(%s)", commandRunner.getStatement().getInstanceName(), exec .getExitStatus()); set(exec); } catch (Exception e) { setException(e); } }
private void toStringExpectations(SudoAwareInitManager commandRunner, InitScript initScript) { expect(commandRunner.getStatement()).andReturn(initScript); expect(initScript.getInstanceName()).andReturn("init-script"); } }
@Override public RunScriptOnNodeAsInitScriptUsingSsh init() { super.init(); return this; }
@Override protected boolean set(ExecResponse value) { eventBus.post(new StatementOnNodeCompletion(getCommandRunner().getStatement(), getCommandRunner().getNode(), value)); return super.set(value); }
@Override public void run() { try { ExecResponse exec = null; do { notRunningAnymore.apply("status"); String stdout = commandRunner.runAction("stdout").getOutput(); String stderr = commandRunner.runAction("stderr").getOutput(); Integer exitStatus = Ints.tryParse(commandRunner.runAction("exitstatus").getOutput().trim()); exec = new ExecResponse(stdout, stderr, exitStatus == null ? -1 : exitStatus); } while (!isCancelled() && exec.getExitStatus() == -1); logger.debug("<< complete(%s) status(%s)", commandRunner.getStatement().getInstanceName(), exec .getExitStatus()); set(exec); } catch (Exception e) { setException(e); } }
private void toStringExpectations(SudoAwareInitManager commandRunner, InitScript initScript) { expect(commandRunner.getStatement()).andReturn(initScript); expect(initScript.getInstanceName()).andReturn("init-script"); } }
@Override public RunScriptOnNodeAsInitScriptUsingSsh init() { super.init(); return this; }
@Override protected void interruptTask() { logger.debug("<< cancelled(%s)", commandRunner.getStatement().getInstanceName()); ExecResponse returnVal = commandRunner.refreshAndRunAction("stop"); CancellationException e = new CancellationException(String.format( "cancelled %s on node: %s; stop command had exit status: %s", getCommandRunner().getStatement() .getInstanceName(), getCommandRunner().getNode().getId(), returnVal)); eventBus.post(new StatementOnNodeFailure(getCommandRunner().getStatement(), getCommandRunner().getNode(), e)); super.interruptTask(); }
@Override protected boolean set(ExecResponse value) { eventBus.post(new StatementOnNodeCompletion(getCommandRunner().getStatement(), getCommandRunner().getNode(), value)); return super.set(value); }
@Override public boolean apply(String input) { return commandRunner.runAction(input).getExitStatus() > 0; }
@Override public void run() { try { ExecResponse exec = null; do { notRunningAnymore.apply("status"); String stdout = commandRunner.runAction("stdout").getOutput(); String stderr = commandRunner.runAction("stderr").getOutput(); Integer exitStatus = Ints.tryParse(commandRunner.runAction("exitstatus").getOutput().trim()); exec = new ExecResponse(stdout, stderr, exitStatus == null ? -1 : exitStatus); } while (!isCancelled() && exec.getExitStatus() == -1); logger.debug("<< complete(%s) status(%s)", commandRunner.getStatement().getInstanceName(), exec .getExitStatus()); set(exec); } catch (Exception e) { setException(e); } }
public ExecResponse runAction(String action) { ExecResponse returnVal; String command = (runAsRoot && Predicates.in(ImmutableSet.of("start", "stop", "run")).apply(action)) ? execScriptAsRoot(action) : execScriptAsDefaultUser(action); returnVal = runCommand(command); if (ImmutableSet.of("status", "stdout", "stderr").contains(action)) logger.trace("<< %s(%d)", action, returnVal.getExitStatus()); else if (computeLogger.isTraceEnabled()) computeLogger.trace("<< %s[%s]", action, returnVal); else computeLogger.debug("<< %s(%d)", action, returnVal.getExitStatus()); return returnVal; }
@Override public RunScriptOnNodeAsInitScriptUsingSsh init() { super.init(); return this; }
@Override protected void interruptTask() { logger.debug("<< cancelled(%s)", commandRunner.getStatement().getInstanceName()); ExecResponse returnVal = commandRunner.refreshAndRunAction("stop"); CancellationException e = new CancellationException(String.format( "cancelled %s on node: %s; stop command had exit status: %s", getCommandRunner().getStatement() .getInstanceName(), getCommandRunner().getNode().getId(), returnVal)); eventBus.post(new StatementOnNodeFailure(getCommandRunner().getStatement(), getCommandRunner().getNode(), e)); super.interruptTask(); }
@Override protected boolean set(ExecResponse value) { eventBus.post(new StatementOnNodeCompletion(getCommandRunner().getStatement(), getCommandRunner().getNode(), value)); return super.set(value); }
@Override public boolean apply(String input) { return commandRunner.runAction(input).getExitStatus() > 0; }