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;
}
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);
}
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();
}
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());
}
Aggregations