Search in sources :

Example 1 with ParameterInfo

use of io.mantisrx.runtime.descriptor.ParameterInfo in project mantis by Netflix.

the class CreateJobDescriptorFile method createParameterInfo.

private Map<String, ParameterInfo> createParameterInfo(final Map<String, ParameterDefinition<?>> parameters) {
    final Map<String, ParameterInfo> parameterInfo = new HashMap<>();
    for (Entry<String, ParameterDefinition<?>> entry : parameters.entrySet()) {
        ParameterDefinition<?> definition = entry.getValue();
        String defaultValue = null;
        if (definition.getDefaultValue() != null) {
            defaultValue = definition.getDefaultValue().toString();
        }
        parameterInfo.put(entry.getKey(), new ParameterInfo(definition.getName(), definition.getDescription(), defaultValue, definition.getTypeDescription(), definition.getValidator().getDescription(), definition.isRequired()));
    }
    return parameterInfo;
}
Also used : HashMap(java.util.HashMap) ParameterInfo(io.mantisrx.runtime.descriptor.ParameterInfo) ParameterDefinition(io.mantisrx.runtime.parameter.ParameterDefinition)

Example 2 with ParameterInfo

use of io.mantisrx.runtime.descriptor.ParameterInfo 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);
    }
}
Also used : StageInfo(io.mantisrx.runtime.descriptor.StageInfo) StageConfig(io.mantisrx.runtime.StageConfig) ObjectMapper(io.mantisrx.shaded.com.fasterxml.jackson.databind.ObjectMapper) Metadata(io.mantisrx.runtime.Metadata) IOException(java.io.IOException) HashMap(java.util.HashMap) Collectors(java.util.stream.Collectors) File(java.io.File) ParameterDefinition(io.mantisrx.runtime.parameter.ParameterDefinition) Job(io.mantisrx.runtime.Job) DeserializationFeature(io.mantisrx.shaded.com.fasterxml.jackson.databind.DeserializationFeature) List(java.util.List) MetadataInfo(io.mantisrx.runtime.descriptor.MetadataInfo) ParameterUtils(io.mantisrx.runtime.parameter.ParameterUtils) Map(java.util.Map) Entry(java.util.Map.Entry) JobInfo(io.mantisrx.runtime.descriptor.JobInfo) JobDescriptor(io.mantisrx.runtime.descriptor.JobDescriptor) ParameterInfo(io.mantisrx.runtime.descriptor.ParameterInfo) MetadataInfo(io.mantisrx.runtime.descriptor.MetadataInfo) HashMap(java.util.HashMap) JobDescriptor(io.mantisrx.runtime.descriptor.JobDescriptor) StageInfo(io.mantisrx.runtime.descriptor.StageInfo) Metadata(io.mantisrx.runtime.Metadata) ParameterInfo(io.mantisrx.runtime.descriptor.ParameterInfo) IOException(java.io.IOException) StageConfig(io.mantisrx.runtime.StageConfig) JobInfo(io.mantisrx.runtime.descriptor.JobInfo)

Aggregations

ParameterInfo (io.mantisrx.runtime.descriptor.ParameterInfo)2 ParameterDefinition (io.mantisrx.runtime.parameter.ParameterDefinition)2 HashMap (java.util.HashMap)2 Job (io.mantisrx.runtime.Job)1 Metadata (io.mantisrx.runtime.Metadata)1 StageConfig (io.mantisrx.runtime.StageConfig)1 JobDescriptor (io.mantisrx.runtime.descriptor.JobDescriptor)1 JobInfo (io.mantisrx.runtime.descriptor.JobInfo)1 MetadataInfo (io.mantisrx.runtime.descriptor.MetadataInfo)1 StageInfo (io.mantisrx.runtime.descriptor.StageInfo)1 ParameterUtils (io.mantisrx.runtime.parameter.ParameterUtils)1 DeserializationFeature (io.mantisrx.shaded.com.fasterxml.jackson.databind.DeserializationFeature)1 ObjectMapper (io.mantisrx.shaded.com.fasterxml.jackson.databind.ObjectMapper)1 File (java.io.File)1 IOException (java.io.IOException)1 List (java.util.List)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Collectors (java.util.stream.Collectors)1