use of io.mantisrx.server.master.store.MantisWorkerMetadata 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());
}
use of io.mantisrx.server.master.store.MantisWorkerMetadata in project mantis by Netflix.
the class CompactJobInfo method fromJob.
static CompactJobInfo fromJob(MantisJobMetadata job) {
if (job == null)
return null;
int workers = 0;
double totCPUs = 0.0;
double totMem = 0.0;
Map<String, Integer> stSmry = new HashMap<>();
for (MantisStageMetadata s : job.getStageMetadata()) {
workers += s.getNumWorkers();
totCPUs += s.getNumWorkers() * s.getMachineDefinition().getCpuCores();
totMem += s.getNumWorkers() * s.getMachineDefinition().getMemoryMB();
for (MantisWorkerMetadata w : s.getWorkerByIndexMetadataSet()) {
final Integer prevVal = stSmry.get(w.getState() + "");
if (prevVal == null)
stSmry.put(w.getState() + "", 1);
else
stSmry.put(w.getState() + "", prevVal + 1);
}
}
String artifact = job.getJarUrl().toString();
return new CompactJobInfo(job.getJobId(), artifact, job.getSubmittedAt(), job.getUser(), job.getState(), job.getSla().getDurationType(), job.getNumStages(), workers, totCPUs, totMem, stSmry, job.getLabels());
}
Aggregations