Search in sources :

Example 1 with MantisJobMetadataWritable

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;
}
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 2 with MantisJobMetadataWritable

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);
}
Also used : MantisJobMetadataWritable(io.mantisrx.server.master.store.MantisJobMetadataWritable) IMantisJobMetadata(io.mantisrx.master.jobcluster.job.IMantisJobMetadata) JobNameAlreadyExistsException(io.mantisrx.server.master.store.JobNameAlreadyExistsException) JobAlreadyExistsException(io.mantisrx.server.master.store.JobAlreadyExistsException) IOException(java.io.IOException) InvalidNamedJobException(io.mantisrx.server.master.store.InvalidNamedJobException)

Aggregations

MantisJobMetadataWritable (io.mantisrx.server.master.store.MantisJobMetadataWritable)2 FilterableMantisJobMetadataWritable (io.mantisrx.master.jobcluster.job.FilterableMantisJobMetadataWritable)1 IMantisJobMetadata (io.mantisrx.master.jobcluster.job.IMantisJobMetadata)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 InvalidNamedJobException (io.mantisrx.server.master.store.InvalidNamedJobException)1 JobAlreadyExistsException (io.mantisrx.server.master.store.JobAlreadyExistsException)1 JobNameAlreadyExistsException (io.mantisrx.server.master.store.JobNameAlreadyExistsException)1 MantisStageMetadata (io.mantisrx.server.master.store.MantisStageMetadata)1 IOException (java.io.IOException)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1