use of io.mantisrx.server.master.store.MantisJobMetadataWritable 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.MantisJobMetadataWritable in project mantis by Netflix.
the class MantisStorageProviderAdapter method loadArchivedJob.
@Override
public Optional<IMantisJobMetadata> loadArchivedJob(String jobId) throws IOException {
if (logger.isTraceEnabled()) {
logger.trace("Enter MantisStorageProviderAdapter:loadArchivedJob {}", jobId);
}
IMantisJobMetadata mantisJobMetadata;
try {
MantisJobMetadataWritable archJob = sProvider.loadArchivedJob(jobId);
mantisJobMetadata = (DataFormatAdapter.convertMantisJobWriteableToMantisJobMetadata(archJob, eventPublisher, true));
} catch (Exception e) {
logger.error("Exception loading archived Job", e);
return Optional.empty();
}
if (logger.isTraceEnabled()) {
logger.trace("Exit MantisStorageProviderAdapter:loadArchivedJob {}", jobId);
}
return Optional.ofNullable(mantisJobMetadata);
}
Aggregations