use of io.mantisrx.server.master.http.api.CompactJobInfo in project mantis by Netflix.
the class JobRouteTest method testJobClusterGetJobsCompact.
@Test(dependsOnMethods = { "testJobClusterGetJobDetail" })
public void testJobClusterGetJobsCompact() throws InterruptedException {
final CompletionStage<HttpResponse> responseFuture = http.singleRequest(HttpRequest.GET(jobAPIEndpoint("list?compact=true")));
try {
responseFuture.thenCompose(r -> processRespFut(r, Optional.of(200))).whenComplete((msg, t) -> {
String responseMessage = getResponseMessage(msg, t);
logger.info("got response {}", responseMessage);
List<CompactJobInfo> jobIdInfos = Collections.emptyList();
try {
jobIdInfos = Jackson.fromJSON(responseMessage, new TypeReference<List<CompactJobInfo>>() {
});
} catch (IOException e) {
logger.error("failed to get CompactJobInfos from json response {}", responseMessage, e);
fail("compactJobInfo deser failed");
}
logger.info("got jobIdInfos {}", jobIdInfos);
assertEquals(1, jobIdInfos.size());
CompactJobInfo jobInfo = jobIdInfos.get(0);
assertEquals("sine-function-1", jobInfo.getJobId());
assertEquals("nmahilani", jobInfo.getUser());
assertEquals(7, jobInfo.getLabels().size());
assertEquals(2, jobInfo.getNumStages());
assertEquals(2, jobInfo.getNumWorkers());
assertTrue(jobInfo.getState().equals(MantisJobState.Accepted) || jobInfo.getState().equals(MantisJobState.Launched));
assertEquals(2.0, jobInfo.getTotCPUs(), 0.0);
// TODO total memory is 400 for old master, 2048 for new master
// assertEquals(400.0, jobInfo.getTotMemory(), 0.0);
assertEquals(MantisJobDurationType.Perpetual, jobInfo.getType());
assertTrue(Collections.singletonMap("Started", 2).equals(jobInfo.getStatesSummary()) || Collections.singletonMap("StartInitiated", 2).equals(jobInfo.getStatesSummary()) || Collections.singletonMap("Launched", 2).equals(jobInfo.getStatesSummary()) || Collections.singletonMap("Accepted", 2).equals(jobInfo.getStatesSummary()));
}).toCompletableFuture().get(2, TimeUnit.SECONDS);
} catch (ExecutionException e) {
throw new RuntimeException(e);
} catch (TimeoutException e) {
throw new RuntimeException(e);
}
}
use of io.mantisrx.server.master.http.api.CompactJobInfo in project mantis by Netflix.
the class JobClusterProtoAdapter method toCompactJobInfo.
public static final CompactJobInfo toCompactJobInfo(final MantisJobMetadataView view) {
MantisJobMetadata jm = view.getJobMetadata();
int workers = 0;
double totCPUs = 0.0;
double totMem = 0.0;
Map<String, Integer> stSmry = new HashMap<>();
for (MantisStageMetadata s : view.getStageMetadataList()) {
workers += s.getNumWorkers();
totCPUs += s.getNumWorkers() * s.getMachineDefinition().getCpuCores();
totMem += s.getNumWorkers() * s.getMachineDefinition().getMemoryMB();
}
for (MantisWorkerMetadata w : view.getWorkerMetadataList()) {
final Integer prevVal = stSmry.get(w.getState() + "");
if (prevVal == null) {
stSmry.put(w.getState() + "", 1);
} else {
stSmry.put(w.getState() + "", prevVal + 1);
}
}
return new CompactJobInfo(jm.getJobId(), (jm.getJarUrl() != null) ? jm.getJarUrl().toString() : "", jm.getSubmittedAt(), jm.getUser(), jm.getState(), jm.getSla() != null ? jm.getSla().getDurationType() : MantisJobDurationType.Transient, jm.getNumStages(), workers, totCPUs, totMem, stSmry, jm.getLabels());
}
Aggregations