@Test public void verifySupervisorHandlesUndeployingOfNotRunningContainerWithGracePeriod() throws Exception { final int gracePeriod = 5; final Job job = JOB.toBuilder() .setGracePeriod(gracePeriod) .build(); final Supervisor sut = createSupervisor(job); sut.setGoal(Goal.UNDEPLOY); verify(model, timeout(30000)).setTaskStatus(eq(job.getId()), argThat(is(taskStatusWithState(TaskStatus.State.STOPPING)))); verify(model, timeout(30000)).setTaskStatus(eq(job.getId()), argThat(is(taskStatusWithState(TaskStatus.State.STOPPED)))); verify(sleeper, never()).sleep(gracePeriod * 1000); }
@SuppressWarnings("MissingSwitchDefault") public void setGoal(final Goal goal) { if (this.goal == goal) { return; } log.debug("Supervisor {}: setting goal: {}", job.getId(), goal); this.goal = goal; statusUpdater.setGoal(goal); switch (goal) { case START: currentCommand = new Start(); reactor.signal(); metrics.supervisorStarted(); break; case STOP: case UNDEPLOY: currentCommand = new Stop(); reactor.signal(); metrics.supervisorStopped(); break; } }
Supervisor { @SuppressWarnings("MissingSwitchDefault") public void setGoal(final Goal goal) { if (this.goal == goal) { return; } log.debug("Supervisor {}: setting goal: {}", job.getId(), goal); this.goal = goal; statusUpdater.setGoal(goal); switch (goal) { case START: currentCommand = new Start(); reactor.signal(); metrics.supervisorStarted(); break; case STOP: case UNDEPLOY: currentCommand = new Stop(); reactor.signal(); metrics.supervisorStopped(); break; } } }
Supervisor { @SuppressWarnings("MissingSwitchDefault") public void setGoal(final Goal goal) { if (this.goal == goal) { return; } log.debug("Supervisor {}: setting goal: {}", job.getId(), goal); this.goal = goal; statusUpdater.setGoal(goal); switch (goal) { case START: currentCommand = new Start(); reactor.signal(); metrics.supervisorStarted(); break; case STOP: case UNDEPLOY: currentCommand = new Stop(); reactor.signal(); metrics.supervisorStopped(); break; } } Supervisor(final Builder builder); }
Supervisor { @SuppressWarnings("MissingSwitchDefault") public void setGoal(final Goal goal) { if (this.goal == goal) { return; } log.debug("Supervisor {}: setting goal: {}", job.getId(), goal); this.goal = goal; statusUpdater.setGoal(goal); switch (goal) { case START: currentCommand = new Start(); reactor.signal(); metrics.supervisorStarted(); break; case STOP: case UNDEPLOY: currentCommand = new Stop(); reactor.signal(); metrics.supervisorStopped(); break; } } Supervisor(final Builder builder); @SuppressWarnings("MissingSwitchDefault") void setGoal(final Goal goal); void close(); void join(); boolean isStarting(); boolean isStopping(); boolean isDone(); String containerId(); static Builder newBuilder(); @Override String toString(); }
Supervisor { @SuppressWarnings("MissingSwitchDefault") public void setGoal(final Goal goal) { if (this.goal == goal) { return; } log.debug("Supervisor {}: setting goal: {}", job.getId(), goal); this.goal = goal; statusUpdater.setGoal(goal); switch (goal) { case START: currentCommand = new Start(); reactor.signal(); metrics.supervisorStarted(); break; case STOP: case UNDEPLOY: currentCommand = new Stop(); reactor.signal(); metrics.supervisorStopped(); break; } } Supervisor(final Builder builder); @SuppressWarnings("MissingSwitchDefault") void setGoal(final Goal goal); void close(); void join(); boolean isStarting(); boolean isStopping(); boolean isDone(); String containerId(); static Builder newBuilder(); @Override String toString();  }