use of io.mantisrx.server.master.store.MantisStageMetadataWritable in project mantis by Netflix.
the class JobRouteTest method testJobClusterGetJobsList.
@Test(dependsOnMethods = { "testJobClusterGetJobIds" })
public void testJobClusterGetJobsList() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final CompletionStage<HttpResponse> responseFuture = http.singleRequest(HttpRequest.GET(jobAPIEndpoint("list")));
responseFuture.thenCompose(r -> processRespFut(r, Optional.of(200))).whenComplete((msg, t) -> {
String responseMessage = getResponseMessage(msg, t);
logger.info("got response---> {}", responseMessage);
List<MantisJobMetadataView> jobInfos = Collections.emptyList();
try {
jobInfos = Jackson.fromJSON(responseMessage, new TypeReference<List<MantisJobMetadataView>>() {
});
} catch (IOException e) {
logger.error("failed to deser json {}", responseMessage, e);
fail("job list deser failed");
}
logger.info("jobInfos---> {}", jobInfos);
assertEquals(1, jobInfos.size());
MantisJobMetadataView mjm = jobInfos.get(0);
assertEquals(mjm.getJobMetadata().getJobId(), "sine-function-1");
assertEquals(mjm.getJobMetadata().getName(), "sine-function");
assertTrue(mjm.getStageMetadataList().size() > 0);
MantisStageMetadataWritable msm = mjm.getStageMetadataList().get(0);
assertEquals(1, msm.getNumWorkers());
assertTrue(mjm.getWorkerMetadataList().size() > 0);
MantisWorkerMetadataWritable mwm = mjm.getWorkerMetadataList().get(0);
assertEquals("sine-function-1", mwm.getJobId());
assertEquals(false, mwm.getCluster().isPresent());
latch.countDown();
});
assertTrue(latch.await(2, TimeUnit.SECONDS));
}
use of io.mantisrx.server.master.store.MantisStageMetadataWritable in project mantis by Netflix.
the class JobRouteTest method testJobClusterGetJobDetail.
@Test(dependsOnMethods = { "testJobClusterGetJobsList" })
public void testJobClusterGetJobDetail() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final CompletionStage<HttpResponse> responseFuture = http.singleRequest(HttpRequest.GET(jobAPIEndpoint("list/sine-function-1")));
responseFuture.thenCompose(r -> processRespFut(r, Optional.of(200))).whenComplete((msg, t) -> {
String responseMessage = getResponseMessage(msg, t);
logger.info("got response---> {}", responseMessage);
MantisJobMetadataView mjm = null;
try {
mjm = Jackson.fromJSON(responseMessage, MantisJobMetadataView.class);
} catch (IOException e) {
logger.error("failed to deser json {}", responseMessage, e);
fail("job info deser failed");
}
logger.info("jobInfo---> {}", mjm);
assertNotNull(mjm);
assertEquals(mjm.getJobMetadata().getJobId(), "sine-function-1");
assertEquals(mjm.getJobMetadata().getName(), "sine-function");
assertTrue(mjm.getStageMetadataList().size() > 0);
MantisStageMetadataWritable msm = mjm.getStageMetadataList().get(0);
assertEquals(1, msm.getNumWorkers());
assertTrue(mjm.getWorkerMetadataList().size() > 0);
MantisWorkerMetadataWritable mwm = mjm.getWorkerMetadataList().get(0);
assertEquals("sine-function-1", mwm.getJobId());
assertEquals(false, mwm.getCluster().isPresent());
latch.countDown();
});
assertTrue(latch.await(2, TimeUnit.SECONDS));
}
use of io.mantisrx.server.master.store.MantisStageMetadataWritable in project mantis by Netflix.
the class DataFormatAdapterTest method convertMantisStageMetaTest.
@Test
public void convertMantisStageMetaTest() {
Map<StageScalingPolicy.ScalingReason, StageScalingPolicy.Strategy> smap = new HashMap<>();
smap.put(StageScalingPolicy.ScalingReason.CPU, new StageScalingPolicy.Strategy(StageScalingPolicy.ScalingReason.CPU, 0.5, 0.75, null));
smap.put(StageScalingPolicy.ScalingReason.DataDrop, new StageScalingPolicy.Strategy(StageScalingPolicy.ScalingReason.DataDrop, 0.0, 2.0, null));
int stageNo = 1;
int min = 3;
int max = 10;
int increment = 1;
int decrement = 1;
int coolDownSecs = 300;
StageScalingPolicy stageScalingPolicy = new StageScalingPolicy(stageNo, min, max, increment, decrement, coolDownSecs, smap);
List<JobConstraints> softConstraintsList = new ArrayList<>();
softConstraintsList.add(JobConstraints.ExclusiveHost);
List<JobConstraints> hardConstraintsList = new ArrayList<>();
hardConstraintsList.add(JobConstraints.M3Cluster);
JobId jobId = new JobId("cName", 1);
int numWorkers = 1;
int numStages = 2;
boolean isScalable = true;
IMantisStageMetadata stageMeta = new MantisStageMetadataImpl.Builder().withStageNum(stageNo).withScalingPolicy(stageScalingPolicy).withNumWorkers(numWorkers).withMachineDefinition(DEFAULT_MACHINE_DEFINITION).withNumStages(numStages).withSoftConstraints(softConstraintsList).withHardConstraints(hardConstraintsList).withJobId(jobId).isScalable(isScalable).build();
MantisStageMetadataWritable stageMetadataWritable = DataFormatAdapter.convertMantisStageMetadataToMantisStageMetadataWriteable(stageMeta);
assertEquals(jobId.getId(), stageMetadataWritable.getJobId());
assertEquals(JobConstraints.M3Cluster, stageMetadataWritable.getHardConstraints().get(0));
assertEquals(JobConstraints.ExclusiveHost, stageMetadataWritable.getSoftConstraints().get(0));
assertEquals(stageScalingPolicy, stageMetadataWritable.getScalingPolicy());
assertTrue(stageMetadataWritable.getScalable());
assertEquals(DEFAULT_MACHINE_DEFINITION, stageMetadataWritable.getMachineDefinition());
assertEquals(numWorkers, stageMetadataWritable.getNumWorkers());
assertEquals(numStages, stageMetadataWritable.getNumStages());
assertEquals(stageNo, stageMetadataWritable.getStageNum());
IMantisStageMetadata reconverted = DataFormatAdapter.convertMantisStageMetadataWriteableToMantisStageMetadata(stageMetadataWritable, eventPublisher);
assertEquals(stageMeta, reconverted);
}
Aggregations