Search in sources :

Example 1 with VariableImpact

use of org.apache.nifi.attribute.expression.language.VariableImpact in project nifi by apache.

the class StandardProcessGroup method getComponentsAffectedByVariable.

@Override
public Set<ConfiguredComponent> getComponentsAffectedByVariable(final String variableName) {
    final Set<ConfiguredComponent> affected = new HashSet<>();
    // Determine any Processors that references the variable
    for (final ProcessorNode processor : getProcessors()) {
        for (final VariableImpact impact : getVariableImpact(processor)) {
            if (impact.isImpacted(variableName)) {
                affected.add(processor);
            }
        }
    }
    // find any references to that service and add it.
    for (final ControllerServiceNode service : getControllerServices(false)) {
        for (final VariableImpact impact : getVariableImpact(service)) {
            if (impact.isImpacted(variableName)) {
                affected.add(service);
                final ControllerServiceReference reference = service.getReferences();
                affected.addAll(reference.findRecursiveReferences(ConfiguredComponent.class));
            }
        }
    }
    // is overriding the variable and its components are actually referencing a different variable.
    for (final ProcessGroup childGroup : getProcessGroups()) {
        final ComponentVariableRegistry childRegistry = childGroup.getVariableRegistry();
        final VariableDescriptor descriptor = childRegistry.getVariableKey(variableName);
        final boolean overridden = childRegistry.getVariableMap().containsKey(descriptor);
        if (!overridden) {
            affected.addAll(childGroup.getComponentsAffectedByVariable(variableName));
        }
    }
    return affected;
}
Also used : VariableImpact(org.apache.nifi.attribute.expression.language.VariableImpact) ProcessorNode(org.apache.nifi.controller.ProcessorNode) ControllerServiceNode(org.apache.nifi.controller.service.ControllerServiceNode) ConfiguredComponent(org.apache.nifi.controller.ConfiguredComponent) ComponentVariableRegistry(org.apache.nifi.registry.ComponentVariableRegistry) ControllerServiceReference(org.apache.nifi.controller.service.ControllerServiceReference) VersionedProcessGroup(org.apache.nifi.registry.flow.VersionedProcessGroup) VersionedRemoteProcessGroup(org.apache.nifi.registry.flow.VersionedRemoteProcessGroup) VariableDescriptor(org.apache.nifi.registry.VariableDescriptor) LinkedHashSet(java.util.LinkedHashSet) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 VariableImpact (org.apache.nifi.attribute.expression.language.VariableImpact)1 ConfiguredComponent (org.apache.nifi.controller.ConfiguredComponent)1 ProcessorNode (org.apache.nifi.controller.ProcessorNode)1 ControllerServiceNode (org.apache.nifi.controller.service.ControllerServiceNode)1 ControllerServiceReference (org.apache.nifi.controller.service.ControllerServiceReference)1 ComponentVariableRegistry (org.apache.nifi.registry.ComponentVariableRegistry)1 VariableDescriptor (org.apache.nifi.registry.VariableDescriptor)1 VersionedProcessGroup (org.apache.nifi.registry.flow.VersionedProcessGroup)1 VersionedRemoteProcessGroup (org.apache.nifi.registry.flow.VersionedRemoteProcessGroup)1