private void verifyProcessorsInVersionedFlow(final VersionedProcessGroup versionedFlow, final Map<String, Set<BundleCoordinate>> supportedTypes) { if (versionedFlow.getProcessors() != null) { versionedFlow.getProcessors().forEach(processor -> { if (processor.getBundle() == null) { throw new IllegalArgumentException("Processor bundle must be specified."); } if (supportedTypes.containsKey(processor.getType())) { verifyBundleInVersionedFlow(processor.getBundle(), supportedTypes.get(processor.getType())); } else { throw new IllegalStateException("Invalid Processor Type: " + processor.getType()); } }); } if (versionedFlow.getProcessGroups() != null) { versionedFlow.getProcessGroups().forEach(processGroup -> { verifyProcessorsInVersionedFlow(processGroup, supportedTypes); }); } }
private static void populateComponentTypes(final VersionedProcessGroup group, final Set<Tuple<String, BundleCoordinate>> componentTypes) { group.getProcessors().stream() .map(versionedProc -> new Tuple<>(versionedProc.getType(), createBundleCoordinate(versionedProc.getBundle()))) .forEach(componentTypes::add); group.getControllerServices().stream() .map(versionedSvc -> new Tuple<>(versionedSvc.getType(), createBundleCoordinate(versionedSvc.getBundle()))) .forEach(componentTypes::add); for (final VersionedProcessGroup childGroup : group.getProcessGroups()) { populateComponentTypes(childGroup, componentTypes); } }
final String processorToAddClass = processorToAdd.getType(); final BundleCoordinate processorToAddCoordinate = toCoordinate(processorToAdd.getBundle());
private ProcessorNode addProcessor(final ProcessGroup destination, final VersionedProcessor proposed, final String componentIdSeed) throws ProcessorInstantiationException { final BundleCoordinate coordinate = toCoordinate(proposed.getBundle()); final ProcessorNode procNode = flowManager.createProcessor(proposed.getType(), generateUuid(proposed.getIdentifier(), destination.getIdentifier(), componentIdSeed), coordinate, true); procNode.setVersionedComponentId(proposed.getIdentifier()); destination.addProcessor(procNode); updateProcessor(procNode, proposed); return procNode; }
if (versionedGroup.getProcessors() != null) { versionedGroup.getProcessors().forEach(processor -> { final BundleCoordinate coordinate = BundleUtils.getCompatibleBundle(extensionManager, processor.getType(), createBundleDto(processor.getBundle()));
private void updateProcessor(final ProcessorNode processor, final VersionedProcessor proposed) throws ProcessorInstantiationException { processor.pauseValidationTrigger(); try { processor.setAnnotationData(proposed.getAnnotationData()); processor.setBulletinLevel(LogLevel.valueOf(proposed.getBulletinLevel())); processor.setComments(proposed.getComments()); processor.setName(proposed.getName()); processor.setPenalizationPeriod(proposed.getPenaltyDuration()); final Map<String, String> properties = populatePropertiesMap(processor.getProperties(), proposed.getProperties(), proposed.getPropertyDescriptors(), processor.getProcessGroup()); processor.setProperties(properties, true); processor.setRunDuration(proposed.getRunDurationMillis(), TimeUnit.MILLISECONDS); processor.setSchedulingStrategy(SchedulingStrategy.valueOf(proposed.getSchedulingStrategy())); processor.setScheduldingPeriod(proposed.getSchedulingPeriod()); processor.setMaxConcurrentTasks(proposed.getConcurrentlySchedulableTaskCount()); processor.setExecutionNode(ExecutionNode.valueOf(proposed.getExecutionNode())); processor.setStyle(proposed.getStyle()); processor.setYieldPeriod(proposed.getYieldDuration()); processor.setPosition(new Position(proposed.getPosition().getX(), proposed.getPosition().getY())); if (!isEqual(processor.getBundleCoordinate(), proposed.getBundle())) { final BundleCoordinate newBundleCoordinate = toCoordinate(proposed.getBundle()); final List<PropertyDescriptor> descriptors = new ArrayList<>(processor.getProperties().keySet()); final Set<URL> additionalUrls = processor.getAdditionalClasspathResources(descriptors); flowController.getReloadComponent().reload(processor, proposed.getType(), newBundleCoordinate, additionalUrls); } } finally { processor.resumeValidationTrigger(); } }
@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); } }