Search in sources :

Example 1 with Status

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);
}
Also used : Status(com.mesosphere.sdk.scheduler.plan.Status) JsonProperty(com.fasterxml.jackson.annotation.JsonProperty) List(java.util.List) ReflectionToStringBuilder(org.apache.commons.lang3.builder.ReflectionToStringBuilder) Phase(com.mesosphere.sdk.scheduler.plan.Phase) Status(com.mesosphere.sdk.scheduler.plan.Status) HashCodeBuilder(org.apache.commons.lang3.builder.HashCodeBuilder) Step(com.mesosphere.sdk.scheduler.plan.Step) Collectors(java.util.stream.Collectors) EqualsBuilder(org.apache.commons.lang3.builder.EqualsBuilder)

Example 2 with Status

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);
}
Also used : Status(com.mesosphere.sdk.scheduler.plan.Status) JsonProperty(com.fasterxml.jackson.annotation.JsonProperty) List(java.util.List) ReflectionToStringBuilder(org.apache.commons.lang3.builder.ReflectionToStringBuilder) Phase(com.mesosphere.sdk.scheduler.plan.Phase) Plan(com.mesosphere.sdk.scheduler.plan.Plan) Status(com.mesosphere.sdk.scheduler.plan.Status) HashCodeBuilder(org.apache.commons.lang3.builder.HashCodeBuilder) Collectors(java.util.stream.Collectors) EqualsBuilder(org.apache.commons.lang3.builder.EqualsBuilder)

Example 3 with Status

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);
}
Also used : Status(com.mesosphere.sdk.scheduler.plan.Status) ArrayList(java.util.ArrayList)

Aggregations

Status (com.mesosphere.sdk.scheduler.plan.Status)3 JsonProperty (com.fasterxml.jackson.annotation.JsonProperty)2 Phase (com.mesosphere.sdk.scheduler.plan.Phase)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 EqualsBuilder (org.apache.commons.lang3.builder.EqualsBuilder)2 HashCodeBuilder (org.apache.commons.lang3.builder.HashCodeBuilder)2 ReflectionToStringBuilder (org.apache.commons.lang3.builder.ReflectionToStringBuilder)2 Plan (com.mesosphere.sdk.scheduler.plan.Plan)1 Step (com.mesosphere.sdk.scheduler.plan.Step)1 ArrayList (java.util.ArrayList)1