Search in sources :

Example 1 with LaunchOfferRecommendation

use of com.mesosphere.sdk.offer.LaunchOfferRecommendation in project dcos-commons by mesosphere.

the class DeploymentStepTest method getStartingStep.

private DeploymentStep getStartingStep() {
    DeploymentStep step = getPendingStep();
    LaunchOfferRecommendation launchRec = new LaunchOfferRecommendation(OfferTestUtils.getEmptyOfferBuilder().build(), Protos.TaskInfo.newBuilder().setTaskId(taskID).setName(taskName).setSlaveId(TestConstants.AGENT_ID).build(), Protos.ExecutorInfo.newBuilder().setExecutorId(Protos.ExecutorID.newBuilder().setValue("executor")).build(), true, true);
    step.updateOfferStatus(Arrays.asList(launchRec));
    return step;
}
Also used : LaunchOfferRecommendation(com.mesosphere.sdk.offer.LaunchOfferRecommendation)

Example 2 with LaunchOfferRecommendation

use of com.mesosphere.sdk.offer.LaunchOfferRecommendation in project dcos-commons by mesosphere.

the class MetricsTest method taskLaunches.

@Test
public void taskLaunches() throws Exception {
    OfferRecommendation realRecommendation = getRecommendation(true);
    Assert.assertTrue(((LaunchOfferRecommendation) realRecommendation).shouldLaunch());
    OfferRecommendation suppressedRecommendation = getRecommendation(false);
    Assert.assertFalse(((LaunchOfferRecommendation) suppressedRecommendation).shouldLaunch());
    Counter launchCounter = Metrics.getRegistry().counter("operation.launch_group");
    long val = launchCounter.getCount();
    Metrics.OperationsCounter.getInstance().record(realRecommendation);
    Metrics.OperationsCounter.getInstance().record(realRecommendation);
    Metrics.OperationsCounter.getInstance().record(realRecommendation);
    Assert.assertEquals(3, launchCounter.getCount() - val);
    val = launchCounter.getCount();
    Metrics.OperationsCounter.getInstance().record(suppressedRecommendation);
    Metrics.OperationsCounter.getInstance().record(suppressedRecommendation);
    Assert.assertEquals(0, launchCounter.getCount() - val);
}
Also used : Counter(com.codahale.metrics.Counter) OfferRecommendation(com.mesosphere.sdk.offer.OfferRecommendation) LaunchOfferRecommendation(com.mesosphere.sdk.offer.LaunchOfferRecommendation) Test(org.junit.Test)

Example 3 with LaunchOfferRecommendation

use of com.mesosphere.sdk.offer.LaunchOfferRecommendation in project dcos-commons by mesosphere.

the class LaunchEvaluationStage method evaluate.

@Override
public EvaluationOutcome evaluate(MesosResourcePool mesosResourcePool, PodInfoBuilder podInfoBuilder) {
    Protos.ExecutorInfo.Builder executorBuilder = podInfoBuilder.getExecutorBuilder().get();
    Protos.Offer offer = mesosResourcePool.getOffer();
    Protos.TaskInfo.Builder taskBuilder = podInfoBuilder.getTaskBuilder(taskName);
    taskBuilder.setTaskId(CommonIdUtils.toTaskId(serviceName, taskBuilder.getName()));
    // Store metadata in the TaskInfo for later access by placement constraints:
    TaskLabelWriter writer = new TaskLabelWriter(taskBuilder);
    writer.setOfferAttributes(offer).setType(podInfoBuilder.getType()).setIndex(podInfoBuilder.getIndex()).setHostname(offer);
    if (offer.hasDomain() && offer.getDomain().hasFaultDomain()) {
        writer.setRegion(offer.getDomain().getFaultDomain().getRegion());
        writer.setZone(offer.getDomain().getFaultDomain().getZone());
    }
    taskBuilder.setLabels(writer.toProto());
    updateFaultDomainEnv(taskBuilder, offer);
    if (!useDefaultExecutor) {
        taskBuilder.setExecutor(executorBuilder);
    }
    return pass(this, Arrays.asList(new LaunchOfferRecommendation(offer, taskBuilder.build(), executorBuilder.build(), shouldLaunch, useDefaultExecutor)), "Added launch information to offer requirement").build();
}
Also used : LaunchOfferRecommendation(com.mesosphere.sdk.offer.LaunchOfferRecommendation) Protos(org.apache.mesos.Protos) TaskLabelWriter(com.mesosphere.sdk.offer.taskdata.TaskLabelWriter)

Example 4 with LaunchOfferRecommendation

use of com.mesosphere.sdk.offer.LaunchOfferRecommendation in project dcos-commons by mesosphere.

the class DeploymentStepTest method testStepStatusCoherence.

private void testStepStatusCoherence(Protos.TaskState updateState, Status expectedStatus) {
    String taskName0 = TASK_NAME_0;
    TaskSpec taskSpec0 = TestPodFactory.getTaskSpec(taskName0, TestConstants.RESOURCE_SET_ID + 0, TestConstants.TASK_DNS_PREFIX);
    String taskName1 = TASK_NAME_1;
    TaskSpec taskSpec1 = TestPodFactory.getTaskSpec(taskName1, TestConstants.RESOURCE_SET_ID + 1, TestConstants.TASK_DNS_PREFIX);
    PodSpec podSpec = DefaultPodSpec.newBuilder("").type(TestConstants.POD_TYPE).count(1).tasks(Arrays.asList(taskSpec0, taskSpec1)).build();
    PodInstance podInstance = new DefaultPodInstance(podSpec, 0);
    Protos.TaskID taskId0 = CommonIdUtils.toTaskId(TestConstants.SERVICE_NAME, TaskSpec.getInstanceName(podInstance, taskName0));
    Protos.TaskID taskId1 = CommonIdUtils.toTaskId(TestConstants.SERVICE_NAME, TaskSpec.getInstanceName(podInstance, taskName1));
    DeploymentStep step = new DeploymentStep(TEST_STEP_NAME, PodInstanceRequirement.newBuilder(podInstance, TaskUtils.getTaskNames(podInstance)).build(), mockStateStore);
    LaunchOfferRecommendation launchRec0 = new LaunchOfferRecommendation(OfferTestUtils.getEmptyOfferBuilder().build(), Protos.TaskInfo.newBuilder().setTaskId(taskId0).setName(taskName0).setSlaveId(TestConstants.AGENT_ID).build(), Protos.ExecutorInfo.newBuilder().setExecutorId(Protos.ExecutorID.newBuilder().setValue("executor")).build(), true, true);
    LaunchOfferRecommendation launchRec1 = new LaunchOfferRecommendation(OfferTestUtils.getEmptyOfferBuilder().build(), Protos.TaskInfo.newBuilder().setTaskId(taskId1).setName(taskName1).setSlaveId(TestConstants.AGENT_ID).build(), Protos.ExecutorInfo.newBuilder().setExecutorId(Protos.ExecutorID.newBuilder().setValue("executor")).build(), true, true);
    step.updateOfferStatus(Arrays.asList(launchRec0, launchRec1));
    Assert.assertEquals(Status.STARTING, step.getStatus());
    Assert.assertEquals(Status.STARTING.toString(), step.getDisplayStatus());
    step.update(Protos.TaskStatus.newBuilder().setTaskId(taskId0).setState(updateState).build());
    Assert.assertEquals(expectedStatus, step.getStatus());
    Assert.assertEquals(expectedStatus.toString(), step.getDisplayStatus());
}
Also used : LaunchOfferRecommendation(com.mesosphere.sdk.offer.LaunchOfferRecommendation) Protos(org.apache.mesos.Protos)

Aggregations

LaunchOfferRecommendation (com.mesosphere.sdk.offer.LaunchOfferRecommendation)4 Protos (org.apache.mesos.Protos)2 Counter (com.codahale.metrics.Counter)1 OfferRecommendation (com.mesosphere.sdk.offer.OfferRecommendation)1 TaskLabelWriter (com.mesosphere.sdk.offer.taskdata.TaskLabelWriter)1 Test (org.junit.Test)1