Java Code Examples for org.apache.nifi.web.api.dto.ProcessorConfigDTO#getExecutionNode()
The following examples show how to use
org.apache.nifi.web.api.dto.ProcessorConfigDTO#getExecutionNode() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProcessorAuditor.java From localization_nifi with Apache License 2.0 | 4 votes |
/** * Extracts the values for the configured properties from the specified Processor. */ private Map<String, String> extractConfiguredPropertyValues(ProcessorNode processor, ProcessorDTO processorDTO) { Map<String, String> values = new HashMap<>(); if (processorDTO.getName() != null) { values.put(NAME, processor.getName()); } if (processorDTO.getConfig() != null) { ProcessorConfigDTO newConfig = processorDTO.getConfig(); if (newConfig.getConcurrentlySchedulableTaskCount() != null) { values.put(CONCURRENTLY_SCHEDULABLE_TASKS, String.valueOf(processor.getMaxConcurrentTasks())); } if (newConfig.getPenaltyDuration() != null) { values.put(PENALTY_DURATION, processor.getPenalizationPeriod()); } if (newConfig.getYieldDuration() != null) { values.put(YIELD_DURATION, processor.getYieldPeriod()); } if (newConfig.getBulletinLevel() != null) { values.put(BULLETIN_LEVEL, processor.getBulletinLevel().name()); } if (newConfig.getAnnotationData() != null) { values.put(ANNOTATION_DATA, processor.getAnnotationData()); } if (newConfig.getSchedulingPeriod() != null) { values.put(SCHEDULING_PERIOD, String.valueOf(processor.getSchedulingPeriod())); } if (newConfig.getAutoTerminatedRelationships() != null) { // get each of the auto terminated relationship names final Set<Relationship> autoTerminatedRelationships = processor.getAutoTerminatedRelationships(); final List<String> autoTerminatedRelationshipNames = new ArrayList<>(autoTerminatedRelationships.size()); for (final Relationship relationship : autoTerminatedRelationships) { autoTerminatedRelationshipNames.add(relationship.getName()); } // sort them and include in the configuration Collections.sort(autoTerminatedRelationshipNames, Collator.getInstance(Locale.US)); values.put(AUTO_TERMINATED_RELATIONSHIPS, StringUtils.join(autoTerminatedRelationshipNames, ", ")); } if (newConfig.getProperties() != null) { // for each property specified, extract its configured value Map<String, String> properties = newConfig.getProperties(); Map<PropertyDescriptor, String> configuredProperties = processor.getProperties(); for (String propertyName : properties.keySet()) { // build a descriptor for getting the configured value PropertyDescriptor propertyDescriptor = new PropertyDescriptor.Builder().name(propertyName).build(); String configuredPropertyValue = configuredProperties.get(propertyDescriptor); // if the configured value couldn't be found, use the default value from the actual descriptor if (configuredPropertyValue == null) { propertyDescriptor = locatePropertyDescriptor(configuredProperties.keySet(), propertyDescriptor); configuredPropertyValue = propertyDescriptor.getDefaultValue(); } values.put(propertyName, configuredPropertyValue); } } if (newConfig.getComments() != null) { values.put(COMMENTS, processor.getComments()); } if (newConfig.getSchedulingStrategy() != null) { values.put(SCHEDULING_STRATEGY, processor.getSchedulingStrategy().name()); } if (newConfig.getExecutionNode() != null) { values.put(EXECUTION_NODE, processor.getExecutionNode().name()); } } return values; }
Example 2
Source File: StandardFlowSynchronizer.java From localization_nifi with Apache License 2.0 | 4 votes |
private void updateProcessor(final ProcessorNode procNode, final ProcessorDTO processorDTO, final ProcessGroup processGroup, final FlowController controller) throws ProcessorInstantiationException { final ProcessorConfigDTO config = processorDTO.getConfig(); procNode.setPosition(toPosition(processorDTO.getPosition())); procNode.setName(processorDTO.getName()); procNode.setStyle(processorDTO.getStyle()); procNode.setProcessGroup(processGroup); procNode.setComments(config.getComments()); procNode.setLossTolerant(config.isLossTolerant()); procNode.setPenalizationPeriod(config.getPenaltyDuration()); procNode.setYieldPeriod(config.getYieldDuration()); procNode.setBulletinLevel(LogLevel.valueOf(config.getBulletinLevel())); if (config.getSchedulingStrategy() != null) { procNode.setSchedulingStrategy(SchedulingStrategy.valueOf(config.getSchedulingStrategy())); } if (config.getExecutionNode() != null) { procNode.setExecutionNode(ExecutionNode.valueOf(config.getExecutionNode())); } // must set scheduling strategy before these two procNode.setMaxConcurrentTasks(config.getConcurrentlySchedulableTaskCount()); procNode.setScheduldingPeriod(config.getSchedulingPeriod()); if (config.getRunDurationMillis() != null) { procNode.setRunDuration(config.getRunDurationMillis(), TimeUnit.MILLISECONDS); } procNode.setAnnotationData(config.getAnnotationData()); if (config.getAutoTerminatedRelationships() != null) { final Set<Relationship> relationships = new HashSet<>(); for (final String rel : config.getAutoTerminatedRelationships()) { relationships.add(procNode.getRelationship(rel)); } procNode.setAutoTerminatedRelationships(relationships); } procNode.setProperties(config.getProperties()); final ScheduledState scheduledState = ScheduledState.valueOf(processorDTO.getState()); if (ScheduledState.RUNNING.equals(scheduledState)) { controller.startProcessor(processGroup.getIdentifier(), procNode.getIdentifier()); } else if (ScheduledState.DISABLED.equals(scheduledState)) { processGroup.disableProcessor(procNode); } }
Example 3
Source File: ProcessorAuditor.java From nifi with Apache License 2.0 | 4 votes |
/** * Extracts the values for the configured properties from the specified Processor. */ private Map<String, String> extractConfiguredPropertyValues(ProcessorNode processor, ProcessorDTO processorDTO) { Map<String, String> values = new HashMap<>(); if (processorDTO.getName() != null) { values.put(NAME, processor.getName()); } if (processorDTO.getBundle() != null) { final BundleCoordinate bundle = processor.getBundleCoordinate(); values.put(EXTENSION_VERSION, formatExtensionVersion(processor.getComponentType(), bundle)); } if (processorDTO.getConfig() != null) { ProcessorConfigDTO newConfig = processorDTO.getConfig(); if (newConfig.getConcurrentlySchedulableTaskCount() != null) { values.put(CONCURRENTLY_SCHEDULABLE_TASKS, String.valueOf(processor.getMaxConcurrentTasks())); } if (newConfig.getPenaltyDuration() != null) { values.put(PENALTY_DURATION, processor.getPenalizationPeriod()); } if (newConfig.getYieldDuration() != null) { values.put(YIELD_DURATION, processor.getYieldPeriod()); } if (newConfig.getBulletinLevel() != null) { values.put(BULLETIN_LEVEL, processor.getBulletinLevel().name()); } if (newConfig.getAnnotationData() != null) { values.put(ANNOTATION_DATA, processor.getAnnotationData()); } if (newConfig.getSchedulingPeriod() != null) { values.put(SCHEDULING_PERIOD, String.valueOf(processor.getSchedulingPeriod())); } if (newConfig.getAutoTerminatedRelationships() != null) { // get each of the auto terminated relationship names final Set<Relationship> autoTerminatedRelationships = processor.getAutoTerminatedRelationships(); final List<String> autoTerminatedRelationshipNames = new ArrayList<>(autoTerminatedRelationships.size()); for (final Relationship relationship : autoTerminatedRelationships) { autoTerminatedRelationshipNames.add(relationship.getName()); } // sort them and include in the configuration Collections.sort(autoTerminatedRelationshipNames, Collator.getInstance(Locale.US)); values.put(AUTO_TERMINATED_RELATIONSHIPS, StringUtils.join(autoTerminatedRelationshipNames, ", ")); } if (newConfig.getProperties() != null) { // for each property specified, extract its configured value Map<String, String> properties = newConfig.getProperties(); Map<PropertyDescriptor, String> configuredProperties = processor.getRawPropertyValues(); for (String propertyName : properties.keySet()) { // build a descriptor for getting the configured value PropertyDescriptor propertyDescriptor = new PropertyDescriptor.Builder().name(propertyName).build(); String configuredPropertyValue = configuredProperties.get(propertyDescriptor); // if the configured value couldn't be found, use the default value from the actual descriptor if (configuredPropertyValue == null) { propertyDescriptor = locatePropertyDescriptor(configuredProperties.keySet(), propertyDescriptor); configuredPropertyValue = propertyDescriptor.getDefaultValue(); } values.put(propertyName, configuredPropertyValue); } } if (newConfig.getComments() != null) { values.put(COMMENTS, processor.getComments()); } if (newConfig.getSchedulingStrategy() != null) { values.put(SCHEDULING_STRATEGY, processor.getSchedulingStrategy().name()); } if (newConfig.getExecutionNode() != null) { values.put(EXECUTION_NODE, processor.getExecutionNode().name()); } } return values; }
Example 4
Source File: StandardFlowSynchronizer.java From nifi with Apache License 2.0 | 4 votes |
private void updateProcessor(final ProcessorNode procNode, final ProcessorDTO processorDTO, final ProcessGroup processGroup, final FlowController controller) { procNode.pauseValidationTrigger(); try { final ProcessorConfigDTO config = processorDTO.getConfig(); procNode.setProcessGroup(processGroup); procNode.setLossTolerant(config.isLossTolerant()); procNode.setPenalizationPeriod(config.getPenaltyDuration()); procNode.setYieldPeriod(config.getYieldDuration()); procNode.setBulletinLevel(LogLevel.valueOf(config.getBulletinLevel())); updateNonFingerprintedProcessorSettings(procNode, processorDTO); if (config.getSchedulingStrategy() != null) { procNode.setSchedulingStrategy(SchedulingStrategy.valueOf(config.getSchedulingStrategy())); } if (config.getExecutionNode() != null) { procNode.setExecutionNode(ExecutionNode.valueOf(config.getExecutionNode())); } // must set scheduling strategy before these two procNode.setMaxConcurrentTasks(config.getConcurrentlySchedulableTaskCount()); procNode.setScheduldingPeriod(config.getSchedulingPeriod()); if (config.getRunDurationMillis() != null) { procNode.setRunDuration(config.getRunDurationMillis(), TimeUnit.MILLISECONDS); } procNode.setAnnotationData(config.getAnnotationData()); if (config.getAutoTerminatedRelationships() != null) { final Set<Relationship> relationships = new HashSet<>(); for (final String rel : config.getAutoTerminatedRelationships()) { relationships.add(procNode.getRelationship(rel)); } procNode.setAutoTerminatedRelationships(relationships); } procNode.setProperties(config.getProperties()); final ScheduledState scheduledState = ScheduledState.valueOf(processorDTO.getState()); if (ScheduledState.RUNNING.equals(scheduledState)) { procNode.performValidation(); // ensure that processor has been validated controller.startProcessor(processGroup.getIdentifier(), procNode.getIdentifier()); } else if (ScheduledState.DISABLED.equals(scheduledState)) { processGroup.disableProcessor(procNode); } else if (ScheduledState.STOPPED.equals(scheduledState)) { controller.stopProcessor(processGroup.getIdentifier(), procNode.getIdentifier()); } } finally { procNode.resumeValidationTrigger(); } }