use of com.mesosphere.sdk.scheduler.plan.Status 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.Status in project dcos-commons by mesosphere.
the class PlanInfo method forPlan.
public static PlanInfo forPlan(final Plan plan) {
// Calculate the status of the plan based on the phases, THEN generate the PhaseInfos for those phases.
// This ordering is a workaround for potential inconsistency when step statuses change while we're rendering the
// plan. By fetching phase statuses after the plan status, inconsistencies should typically appear as e.g. a
// plan that's IN_PROGRESS when the steps or phases are COMPLETE. If we did the plan status last, then we'd risk
// getting the opposite of that, which is less intuitive to an end user.
// plan status first ...
Status planStatus = plan.getStatus();
List<PhaseInfo> phaseInfos = // ... then phases
plan.getChildren().stream().map(phase -> PhaseInfo.forPhase(phase)).collect(Collectors.toList());
return new PlanInfo(phaseInfos, plan.getStrategy().getName(), plan.getErrors(), planStatus);
}
use of com.mesosphere.sdk.scheduler.plan.Status in project dcos-commons by mesosphere.
the class SchedulerRestartServiceTest method testTaskWithReadinessCheckHasStatus.
private static void testTaskWithReadinessCheckHasStatus(int readinessCheckStatusCode, Status expectedStatus, boolean useDefaultExecutor) throws Exception {
Collection<SimulationTick> ticks = new ArrayList<>();
ticks.add(Send.register());
ticks.add(Expect.reconciledImplicitly());
ticks.add(Send.offerBuilder("hello").build());
ticks.add(Expect.launchedTasks("hello-0-server"));
ticks.add(Send.offerBuilder("world").build());
ticks.add(Expect.declinedLastOffer());
ticks.add(Send.taskStatus("hello-0-server", Protos.TaskState.TASK_RUNNING).build());
ticks.add(Send.offerBuilder("world").build());
ticks.add(Expect.launchedTasks("world-0-server"));
ticks.add(Expect.stepStatus("deploy", "world", "world-0:[server]", Status.STARTING));
ticks.add(Send.taskStatus("world-0-server", Protos.TaskState.TASK_RUNNING).setReadinessCheckExitCode(readinessCheckStatusCode).build());
Status postReadinessStatus;
if (readinessCheckStatusCode == 0) {
postReadinessStatus = Status.COMPLETE;
} else {
postReadinessStatus = Status.STARTED;
}
ticks.add(Expect.stepStatus("deploy", "world", "world-0:[server]", postReadinessStatus));
ticks.add(Send.offerBuilder("world").build());
ticks.add(Expect.declinedLastOffer());
ServiceTestRunner runner;
if (useDefaultExecutor) {
runner = new ServiceTestRunner();
} else {
runner = new ServiceTestRunner().setUseCustomExecutor();
}
ServiceTestResult result = runner.run(ticks);
// Start a new scheduler:
ticks.clear();
ticks.add(Send.register());
ticks.add(Expect.reconciledExplicitly(result.getPersister()));
ticks.add(Expect.stepStatus("deploy", "world", "world-0:[server]", expectedStatus));
new ServiceTestRunner().setState(result).run(ticks);
}
Aggregations