Search in sources :

Example 1 with MantisStageMetadata

use of io.mantisrx.server.master.store.MantisStageMetadata 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 MantisStageMetadata

use of io.mantisrx.server.master.store.MantisStageMetadata in project mantis by Netflix.

the class NoOpMantisJobOperations method convertMantisJobWriteableToMantisJobMetadata.

// TODO job specific migration config is not supported, migration config will be at cluster level
public static IMantisJobMetadata convertMantisJobWriteableToMantisJobMetadata(MantisJobMetadata archJob, LifecycleEventPublisher eventPublisher, boolean isArchived) throws Exception {
    if (logger.isTraceEnabled()) {
        logger.trace("DataFormatAdapter:Converting {}", archJob);
    }
    // convert stages to new format
    List<IMantisStageMetadata> convertedStageList = new ArrayList<>();
    for (MantisStageMetadata stageMeta : ((MantisJobMetadataWritable) archJob).getStageMetadata()) {
        // if this is an archived job then add workerIndex may fail as there maybe multiple workers related to a given index so skip adding workers to stage
        boolean skipAddingWorkers = false;
        if (isArchived) {
            skipAddingWorkers = true;
        }
        convertedStageList.add(convertMantisStageMetadataWriteableToMantisStageMetadata(stageMeta, eventPublisher, skipAddingWorkers));
    }
    // generate SchedulingInfo
    SchedulingInfo schedulingInfo = generateSchedulingInfo(convertedStageList);
    URL jarUrl = archJob.getJarUrl();
    Optional<String> artifactName = extractArtifactName(jarUrl);
    // generate job defn
    JobDefinition jobDefn = new JobDefinition(archJob.getName(), archJob.getUser(), artifactName.orElse(""), null, archJob.getParameters(), archJob.getSla(), archJob.getSubscriptionTimeoutSecs(), schedulingInfo, archJob.getNumStages(), archJob.getLabels(), null);
    Optional<JobId> jIdOp = JobId.fromId(archJob.getJobId());
    if (!jIdOp.isPresent()) {
        throw new IllegalArgumentException("Invalid JobId " + archJob.getJobId());
    }
    // generate job meta
    MantisJobMetadataImpl mantisJobMetadata = new MantisJobMetadataImpl(jIdOp.get(), archJob.getSubmittedAt(), archJob.getStartedAt(), jobDefn, convertMantisJobStateToJobState(archJob.getState()), archJob.getNextWorkerNumberToUse());
    // add the stages
    for (IMantisStageMetadata stageMetadata : convertedStageList) {
        mantisJobMetadata.addJobStageIfAbsent(stageMetadata);
    }
    if (logger.isTraceEnabled()) {
        logger.trace("DataFormatAdapter:Completed conversion to IMantisJobMetadata {}", mantisJobMetadata);
    }
    return mantisJobMetadata;
}
Also used : StageSchedulingInfo(io.mantisrx.runtime.descriptor.StageSchedulingInfo) SchedulingInfo(io.mantisrx.runtime.descriptor.SchedulingInfo) ArrayList(java.util.ArrayList) URL(java.net.URL) FilterableMantisJobMetadataWritable(io.mantisrx.master.jobcluster.job.FilterableMantisJobMetadataWritable) MantisJobMetadataWritable(io.mantisrx.server.master.store.MantisJobMetadataWritable) IMantisStageMetadata(io.mantisrx.master.jobcluster.job.IMantisStageMetadata) MantisStageMetadata(io.mantisrx.server.master.store.MantisStageMetadata) IMantisStageMetadata(io.mantisrx.master.jobcluster.job.IMantisStageMetadata) MantisJobMetadataImpl(io.mantisrx.master.jobcluster.job.MantisJobMetadataImpl) MantisJobDefinition(io.mantisrx.runtime.MantisJobDefinition) NamedJobDefinition(io.mantisrx.runtime.NamedJobDefinition)

Example 3 with MantisStageMetadata

use of io.mantisrx.server.master.store.MantisStageMetadata 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)3 MantisWorkerMetadata (io.mantisrx.server.master.store.MantisWorkerMetadata)2 HashMap (java.util.HashMap)2 FilterableMantisJobMetadataWritable (io.mantisrx.master.jobcluster.job.FilterableMantisJobMetadataWritable)1 IMantisStageMetadata (io.mantisrx.master.jobcluster.job.IMantisStageMetadata)1 MantisJobMetadataImpl (io.mantisrx.master.jobcluster.job.MantisJobMetadataImpl)1 MantisJobDefinition (io.mantisrx.runtime.MantisJobDefinition)1 NamedJobDefinition (io.mantisrx.runtime.NamedJobDefinition)1 SchedulingInfo (io.mantisrx.runtime.descriptor.SchedulingInfo)1 StageSchedulingInfo (io.mantisrx.runtime.descriptor.StageSchedulingInfo)1 CompactJobInfo (io.mantisrx.server.master.http.api.CompactJobInfo)1 MantisJobMetadata (io.mantisrx.server.master.store.MantisJobMetadata)1 MantisJobMetadataWritable (io.mantisrx.server.master.store.MantisJobMetadataWritable)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1