Search in sources :

Example 1 with Step

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

Example 2 with Step

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);
}
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 3 with Step

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());
}
Also used : TestStep(com.mesosphere.sdk.scheduler.plan.TestStep) Step(com.mesosphere.sdk.scheduler.plan.Step) TestStep(com.mesosphere.sdk.scheduler.plan.TestStep) Test(org.junit.Test)

Example 4 with Step

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

Example 5 with Step

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);
        }
    };
}
Also used : Phase(com.mesosphere.sdk.scheduler.plan.Phase) Step(com.mesosphere.sdk.scheduler.plan.Step) Plan(com.mesosphere.sdk.scheduler.plan.Plan) SchedulerDriver(org.apache.mesos.SchedulerDriver)

Aggregations

Step (com.mesosphere.sdk.scheduler.plan.Step)5 Phase (com.mesosphere.sdk.scheduler.plan.Phase)2 JsonProperty (com.fasterxml.jackson.annotation.JsonProperty)1 Plan (com.mesosphere.sdk.scheduler.plan.Plan)1 Status (com.mesosphere.sdk.scheduler.plan.Status)1 TestStep (com.mesosphere.sdk.scheduler.plan.TestStep)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 EqualsBuilder (org.apache.commons.lang3.builder.EqualsBuilder)1 HashCodeBuilder (org.apache.commons.lang3.builder.HashCodeBuilder)1 ReflectionToStringBuilder (org.apache.commons.lang3.builder.ReflectionToStringBuilder)1 SchedulerDriver (org.apache.mesos.SchedulerDriver)1 Test (org.junit.Test)1