@Override public ProcessorSchema convert() { Map<String, Object> map = new HashMap<>(); map.put(NAME_KEY, name); map.put(CLASS_KEY, processorClass); map.put(MAX_CONCURRENT_TASKS_KEY, maxConcurrentTasks); map.put(SCHEDULING_STRATEGY_KEY, schedulingStrategy); map.put(SCHEDULING_PERIOD_KEY, schedulingPeriod); map.put(PENALIZATION_PERIOD_KEY, penalizationPeriod); map.put(YIELD_PERIOD_KEY, yieldPeriod); map.put(RUN_DURATION_NANOS_KEY, runDurationNanos); map.put(AUTO_TERMINATED_RELATIONSHIPS_LIST_KEY, autoTerminatedRelationshipsList); map.put(PROPERTIES_KEY, new HashMap<>(properties)); return new ProcessorSchema(map); }
protected List<ProcessorSchema> getProcessorSchemas() { Set<UUID> ids = new HashSet<>(); List<ProcessorSchema> processorSchemas = new ArrayList<>(processors.size()); for (ProcessorSchemaV1 processor : processors) { ProcessorSchema processorSchema = processor.convert(); processorSchema.setId(getUniqueId(ids, processorSchema.getName())); processorSchemas.add(processorSchema); } return processorSchemas; }
public ProcessorSchema(Map map) { super(map, "Processor(id: {id}, name: {name})"); String wrapperName = getWrapperName(); processorClass = getRequiredKeyAsType(map, CLASS_KEY, String.class, wrapperName); schedulingStrategy = getRequiredKeyAsType(map, SCHEDULING_STRATEGY_KEY, String.class, wrapperName); if (schedulingStrategy != null && !isSchedulingStrategy(schedulingStrategy)) { addValidationIssue(SCHEDULING_STRATEGY_KEY, wrapperName, IT_IS_NOT_A_VALID_SCHEDULING_STRATEGY); } schedulingPeriod = getRequiredKeyAsType(map, SCHEDULING_PERIOD_KEY, String.class, wrapperName); maxConcurrentTasks = getOptionalKeyAsType(map, MAX_CONCURRENT_TASKS_KEY, Number.class, wrapperName, DEFAULT_MAX_CONCURRENT_TASKS); penalizationPeriod = getOptionalKeyAsType(map, PENALIZATION_PERIOD_KEY, String.class, wrapperName, DEFAULT_PENALIZATION_PERIOD); yieldPeriod = getOptionalKeyAsType(map, YIELD_PERIOD_KEY, String.class, wrapperName, DEFAULT_YIELD_DURATION); runDurationNanos = getOptionalKeyAsType(map, RUN_DURATION_NANOS_KEY, Number.class, wrapperName, DEFAULT_RUN_DURATION_NANOS); autoTerminatedRelationshipsList = getOptionalKeyAsType(map, AUTO_TERMINATED_RELATIONSHIPS_LIST_KEY, List.class, wrapperName, DEFAULT_AUTO_TERMINATED_RELATIONSHIPS_LIST); properties = getOptionalKeyAsType(map, PROPERTIES_KEY, Map.class, wrapperName, DEFAULT_PROPERTIES); annotationData = getOptionalKeyAsType(map, ANNOTATION_DATA_KEY, String.class, wrapperName, ""); }
parentElement.appendChild(element); addTextElement(element, "id", processorConfig.getId()); addTextElement(element, "name", processorConfig.getName()); addTextElement(element, "class", processorConfig.getProcessorClass()); addTextElement(element, "maxConcurrentTasks", String.valueOf(processorConfig.getMaxConcurrentTasks())); addTextElement(element, "schedulingPeriod", processorConfig.getSchedulingPeriod()); addTextElement(element, "penalizationPeriod", processorConfig.getPenalizationPeriod()); addTextElement(element, "yieldPeriod", processorConfig.getYieldPeriod()); addTextElement(element, "bulletinLevel", "WARN"); addTextElement(element, "lossTolerant", "false"); addTextElement(element, "scheduledState", "RUNNING"); addTextElement(element, "schedulingStrategy", processorConfig.getSchedulingStrategy()); addTextElement(element, "runDurationNanos", String.valueOf(processorConfig.getRunDurationNanos())); String annotationData = processorConfig.getAnnotationData(); if(annotationData != null && !annotationData.isEmpty()) { addTextElement(element, "annotationData", annotationData); addConfiguration(element, processorConfig.getProperties()); Collection<String> autoTerminatedRelationships = processorConfig.getAutoTerminatedRelationshipsList(); if (autoTerminatedRelationships != null) { for (String rel : autoTerminatedRelationships) {
@Override public ProcessorSchema apply(final VersionedProcessor versionedProcessor) { Map<String, Object> map = new HashMap<>(); map.put(NAME_KEY, versionedProcessor.getName()); map.put(ID_KEY, versionedProcessor.getIdentifier()); map.put(CLASS_KEY, versionedProcessor.getType()); map.put(SCHEDULING_STRATEGY_KEY, versionedProcessor.getSchedulingStrategy()); map.put(SCHEDULING_PERIOD_KEY, versionedProcessor.getSchedulingPeriod()); map.put(CommonPropertyKeys.MAX_CONCURRENT_TASKS_KEY, versionedProcessor.getConcurrentlySchedulableTaskCount()); map.put(ProcessorSchema.PENALIZATION_PERIOD_KEY, versionedProcessor.getPenaltyDuration()); map.put(CommonPropertyKeys.YIELD_PERIOD_KEY, versionedProcessor.getYieldDuration()); Long runDurationMillis = versionedProcessor.getRunDurationMillis(); if (runDurationMillis != null) { map.put(ProcessorSchema.RUN_DURATION_NANOS_KEY, runDurationMillis * 1000); } final List<String> autoTerminateRelationships = new ArrayList<>(nullToEmpty(versionedProcessor.getAutoTerminatedRelationships())); map.put(ProcessorSchema.AUTO_TERMINATED_RELATIONSHIPS_LIST_KEY, autoTerminateRelationships); map.put(PROPERTIES_KEY, new HashMap<>(nullToEmpty(versionedProcessor.getProperties()))); String annotationData = versionedProcessor.getAnnotationData(); if(annotationData != null && !annotationData.isEmpty()) { map.put(ANNOTATION_DATA_KEY, annotationData); } return new ProcessorSchema(map); } }
@Override public ProcessorSchema apply(final VersionedProcessor versionedProcessor) { Map<String, Object> map = new HashMap<>(); map.put(NAME_KEY, versionedProcessor.getName()); map.put(ID_KEY, versionedProcessor.getIdentifier()); map.put(CLASS_KEY, versionedProcessor.getType()); map.put(SCHEDULING_STRATEGY_KEY, versionedProcessor.getSchedulingStrategy()); map.put(SCHEDULING_PERIOD_KEY, versionedProcessor.getSchedulingPeriod()); map.put(CommonPropertyKeys.MAX_CONCURRENT_TASKS_KEY, versionedProcessor.getConcurrentlySchedulableTaskCount()); map.put(ProcessorSchema.PENALIZATION_PERIOD_KEY, versionedProcessor.getPenaltyDuration()); map.put(CommonPropertyKeys.YIELD_PERIOD_KEY, versionedProcessor.getYieldDuration()); Long runDurationMillis = versionedProcessor.getRunDurationMillis(); if (runDurationMillis != null) { map.put(ProcessorSchema.RUN_DURATION_NANOS_KEY, runDurationMillis * 1000); } final List<String> autoTerminateRelationships = new ArrayList<>(nullToEmpty(versionedProcessor.getAutoTerminatedRelationships())); map.put(ProcessorSchema.AUTO_TERMINATED_RELATIONSHIPS_LIST_KEY, autoTerminateRelationships); map.put(PROPERTIES_KEY, new HashMap<>(nullToEmpty(versionedProcessor.getProperties()))); String annotationData = versionedProcessor.getAnnotationData(); if(annotationData != null && !annotationData.isEmpty()) { map.put(ANNOTATION_DATA_KEY, annotationData); } return new ProcessorSchema(map); } }
return new ProcessorSchema(map);