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());
}
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;
}
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());
}
Aggregations