public int execute(Executor executor) throws CommandFailedException { Preconditions.checkNotNull(executor, "executor is null"); Preconditions.checkNotNull(command, "command is null"); ProcessCallable processCallable = new ProcessCallable(this, executor); Future<Integer> future = submit(executor, processCallable); try { Integer result = future.get((long) timeLimit.toMillis(), TimeUnit.MILLISECONDS); return result; } catch (ExecutionException e) { Throwables.propagateIfPossible(e.getCause(), CommandFailedException.class); Throwable cause = e.getCause(); if (cause == null) { cause = e; } throw new CommandFailedException(this, "unexpected exception", cause); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new CommandFailedException(this, "interrupted", e); } catch (TimeoutException e) { future.cancel(true); throw new CommandTimeoutException(this); } }
@Override public SlotLifecycleState stop(Deployment deployment) { updateNodeConfig(deployment); try { createCommand("stop", deployment, stopTimeout).execute(executor); return STOPPED; } catch (CommandFailedException e) { throw new RuntimeException("stop failed: " + e.getMessage()); } }
@Override public SlotLifecycleState restart(Deployment deployment) { updateNodeConfig(deployment); try { Command command = createCommand("restart", deployment, stopTimeout); command.execute(executor); return RUNNING; } catch (CommandFailedException e) { throw new RuntimeException("restart failed: " + e.getMessage()); } }
throw new CommandFailedException(command, "failed to start", e); throw new CommandFailedException(command, exitCode, out);
@Override public SlotLifecycleState start(Deployment deployment) { updateNodeConfig(deployment); Command command = createCommand("start", deployment, launcherTimeout); try { command.execute(executor); return RUNNING; } catch (CommandFailedException e) { log.error("ENVIRONMENT:\n %s", Joiner.on("\n ").withKeyValueSeparator("=").join(command.getEnvironment())); throw new RuntimeException("start failed: " + e.getMessage()); } }
throw new RuntimeException("Unable to extract tar file " + assignment.getBinary() + ": " + e.getMessage());