Search in sources :

Example 1 with MantisWorkerMetadata

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());
}
Also used : MantisJobMetadata(io.mantisrx.server.master.store.MantisJobMetadata) MantisWorkerMetadata(io.mantisrx.server.master.store.MantisWorkerMetadata) HashMap(java.util.HashMap) CompactJobInfo(io.mantisrx.server.master.http.api.CompactJobInfo) MantisStageMetadata(io.mantisrx.server.master.store.MantisStageMetadata)

Example 2 with MantisWorkerMetadata

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());
}
Also used : MantisWorkerMetadata(io.mantisrx.server.master.store.MantisWorkerMetadata) HashMap(java.util.HashMap) MantisStageMetadata(io.mantisrx.server.master.store.MantisStageMetadata)

Aggregations

MantisStageMetadata (io.mantisrx.server.master.store.MantisStageMetadata)2 MantisWorkerMetadata (io.mantisrx.server.master.store.MantisWorkerMetadata)2 HashMap (java.util.HashMap)2 CompactJobInfo (io.mantisrx.server.master.http.api.CompactJobInfo)1 MantisJobMetadata (io.mantisrx.server.master.store.MantisJobMetadata)1