Java Code Examples for org.apache.nifi.controller.ProcessorNode#getAutoTerminatedRelationships()

The following examples show how to use org.apache.nifi.controller.ProcessorNode#getAutoTerminatedRelationships() . 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: StandardFlowSerializer.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
private void addProcessor(final Element parentElement, final ProcessorNode processor) {
    final Document doc = parentElement.getOwnerDocument();
    final Element element = doc.createElement("processor");
    parentElement.appendChild(element);
    addTextElement(element, "id", processor.getIdentifier());
    addTextElement(element, "name", processor.getName());

    addPosition(element, processor.getPosition());
    addStyle(element, processor.getStyle());

    addTextElement(element, "comment", processor.getComments());
    addTextElement(element, "class", processor.getCanonicalClassName());
    addTextElement(element, "maxConcurrentTasks", processor.getMaxConcurrentTasks());
    addTextElement(element, "schedulingPeriod", processor.getSchedulingPeriod());
    addTextElement(element, "penalizationPeriod", processor.getPenalizationPeriod());
    addTextElement(element, "yieldPeriod", processor.getYieldPeriod());
    addTextElement(element, "bulletinLevel", processor.getBulletinLevel().toString());
    addTextElement(element, "lossTolerant", String.valueOf(processor.isLossTolerant()));
    addTextElement(element, "scheduledState", processor.getScheduledState().name());
    addTextElement(element, "schedulingStrategy", processor.getSchedulingStrategy().name());
    addTextElement(element, "executionNode", processor.getExecutionNode().name());
    addTextElement(element, "runDurationNanos", processor.getRunDuration(TimeUnit.NANOSECONDS));

    addConfiguration(element, processor.getProperties(), processor.getAnnotationData(), encryptor);

    for (final Relationship rel : processor.getAutoTerminatedRelationships()) {
        addTextElement(element, "autoTerminatedRelationship", rel.getName());
    }
}
 
Example 2
Source File: StandardFlowSerializer.java    From nifi with Apache License 2.0 5 votes vote down vote up
private void addProcessor(final Element parentElement, final ProcessorNode processor, final ScheduledStateLookup scheduledStateLookup) {
    final Document doc = parentElement.getOwnerDocument();
    final Element element = doc.createElement("processor");
    parentElement.appendChild(element);
    addTextElement(element, "id", processor.getIdentifier());
    addTextElement(element, "versionedComponentId", processor.getVersionedComponentId());
    addTextElement(element, "name", processor.getName());

    addPosition(element, processor.getPosition());
    addStyle(element, processor.getStyle());

    addTextElement(element, "comment", processor.getComments());
    addTextElement(element, "class", processor.getCanonicalClassName());

    addBundle(element, processor.getBundleCoordinate());

    addTextElement(element, "maxConcurrentTasks", processor.getMaxConcurrentTasks());
    addTextElement(element, "schedulingPeriod", processor.getSchedulingPeriod());
    addTextElement(element, "penalizationPeriod", processor.getPenalizationPeriod());
    addTextElement(element, "yieldPeriod", processor.getYieldPeriod());
    addTextElement(element, "bulletinLevel", processor.getBulletinLevel().toString());
    addTextElement(element, "lossTolerant", String.valueOf(processor.isLossTolerant()));
    addTextElement(element, "scheduledState", scheduledStateLookup.getScheduledState(processor).name());
    addTextElement(element, "schedulingStrategy", processor.getSchedulingStrategy().name());
    addTextElement(element, "executionNode", processor.getExecutionNode().name());
    addTextElement(element, "runDurationNanos", processor.getRunDuration(TimeUnit.NANOSECONDS));

    addConfiguration(element, processor.getRawPropertyValues(), processor.getAnnotationData(), encryptor);

    for (final Relationship rel : processor.getAutoTerminatedRelationships()) {
        addTextElement(element, "autoTerminatedRelationship", rel.getName());
    }
}
 
Example 3
Source File: ProcessorAuditor.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
/**
 * 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 4
Source File: ProcessorAuditor.java    From nifi with Apache License 2.0 4 votes vote down vote up
/**
 * 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;
}