use of io.mantisrx.runtime.descriptor.MetadataInfo in project mantis by Netflix.
the class CreateJobDescriptorFile method execute.
@SuppressWarnings("unchecked")
@Override
public void execute() throws CommandException {
Metadata jobMetadata = job.getMetadata();
// create stage info
Map<Integer, StageInfo> stagesInfo = new HashMap<>();
List<StageConfig<?, ?>> stages = job.getStages();
int numStages = 0;
for (StageConfig<?, ?> stage : stages) {
stagesInfo.put(numStages, new StageInfo(numStages, stage.getDescription()));
numStages++;
}
// create parameter info
final Map<String, ParameterInfo> parameterInfo = createParameterInfo(job.getParameterDefinitions());
final Map<String, ParameterInfo> systemParameterInfo = createParameterInfo(ParameterUtils.getSystemParameters());
final int totalNumStages = numStages;
final Map<String, ParameterInfo> sysParams = systemParameterInfo.entrySet().stream().filter(sysParam -> {
for (int stageNum = totalNumStages + 1; stageNum <= ParameterUtils.MAX_NUM_STAGES_FOR_JVM_OPTS_OVERRIDE; stageNum++) {
if (sysParam.getKey().equals(String.format(ParameterUtils.PER_STAGE_JVM_OPTS_FORMAT, stageNum))) {
return false;
}
}
return true;
}).collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue()));
parameterInfo.putAll(sysParams);
// create source/sink info
Metadata sourceMetadata = job.getSource().getMetadata();
MetadataInfo sourceMetadataInfo = toMetaDataInfo(sourceMetadata);
Metadata sinkMetadata = job.getSink().getMetadata();
MetadataInfo sinkMetadataInfo = toMetaDataInfo(sinkMetadata);
JobInfo jobInfo = new JobInfo(jobMetadata.getName(), jobMetadata.getDescription(), numStages, parameterInfo, sourceMetadataInfo, sinkMetadataInfo, stagesInfo);
JobDescriptor jobDescriptor = new JobDescriptor(jobInfo, project, version, System.currentTimeMillis(), readyForJobMaster);
try {
mapper.writeValue(descriptorFile, jobDescriptor);
} catch (IOException e) {
throw new DescriptorException(e);
}
}
Aggregations