use of com.mesosphere.sdk.scheduler.plan.Step in project dcos-commons by mesosphere.
the class CanaryStrategy method proceed.
@Override
public void proceed() {
Step canaryStep = getNextCanaryStep();
if (canaryStep != null) {
canaryStep.proceed();
return;
}
strategy.proceed();
}
use of com.mesosphere.sdk.scheduler.plan.Step in project dcos-commons by mesosphere.
the class PhaseInfo method forPhase.
public static PhaseInfo forPhase(final Phase phase) {
// Calculate the status of the phase based on the steps, THEN generate the StepInfos for those steps.
// This ordering is a workaround for potential inconsistency when step statuses change while we're rendering the
// plan. By fetching step statuses after the phase status, inconsistencies should typically appear as e.g. a
// phase that's IN_PROGRESS when the steps are COMPLETE. If we did the phase status last, then we'd risk getting
// the opposite of that, which is less intuitive to an end user.
// phase status first ...
Status phaseStatus = phase.getStatus();
List<StepInfo> stepInfos = // ... then steps
phase.getChildren().stream().map(step -> StepInfo.forStep(step)).collect(Collectors.toList());
return new PhaseInfo(phase.getId().toString(), phase.getName(), stepInfos, phase.getStrategy().getName(), phaseStatus);
}
use of com.mesosphere.sdk.scheduler.plan.Step in project dcos-commons by mesosphere.
the class ParallelStrategyTest method testProceedInterrupt.
@Test
public void testProceedInterrupt() {
TestStep step0 = new TestStep();
TestStep step1 = new TestStep();
List<Step> steps = Arrays.asList(step0, step1);
Collection<Step> candidates = getCandidates(strategy, steps);
Assert.assertEquals(2, candidates.size());
Assert.assertEquals(new HashSet<>(steps), new HashSet<>(candidates));
strategy.interrupt();
Assert.assertTrue(getCandidates(strategy, steps).isEmpty());
strategy.proceed();
candidates = getCandidates(strategy, steps);
Assert.assertEquals(2, candidates.size());
Assert.assertEquals(new HashSet<>(steps), new HashSet<>(candidates));
step0.setStatus(Status.COMPLETE);
Assert.assertEquals(step1, getCandidates(strategy, steps).iterator().next());
strategy.interrupt();
Assert.assertTrue(getCandidates(strategy, steps).isEmpty());
strategy.proceed();
Assert.assertEquals(step1, getCandidates(strategy, steps).iterator().next());
step1.setStatus(Status.COMPLETE);
Assert.assertTrue(getCandidates(strategy, steps).isEmpty());
strategy.interrupt();
Assert.assertTrue(getCandidates(strategy, steps).isEmpty());
}
use of com.mesosphere.sdk.scheduler.plan.Step in project dcos-commons by mesosphere.
the class CanaryStrategy method interrupt.
@Override
public void interrupt() {
Step canaryStep = getNextCanaryStep();
if (canaryStep != null) {
// Ignoring interrupt as we are still in canary and therefore already interrupted.
return;
}
strategy.interrupt();
}
use of com.mesosphere.sdk.scheduler.plan.Step in project dcos-commons by mesosphere.
the class Expect method stepStatus.
/**
* Verifies that the indicated plan.phase.step has the expected status.
*/
public static Expect stepStatus(String planName, String phaseName, String stepName, Status expectedStatus) {
return new Expect() {
@Override
public void expect(ClusterState state, SchedulerDriver mockDriver) {
Plan recoveryPlan = state.getPlans().stream().filter(plan -> plan.getName().equals(planName)).findAny().get();
Phase phase = recoveryPlan.getChildren().stream().filter(p -> p.getName().equals(phaseName)).findAny().get();
Step step = phase.getChildren().stream().filter(s -> s.getName().equals(stepName)).findAny().get();
Assert.assertEquals(expectedStatus, step.getStatus());
}
@Override
public String getDescription() {
return String.format("For Phase: %s, Step: %s, Status is %s", phaseName, stepName, expectedStatus);
}
};
}
Aggregations