Search in sources :

Example 6 with NiFiRegistryFlowMapper

use of org.apache.nifi.registry.flow.mapping.NiFiRegistryFlowMapper in project nifi by apache.

the class StandardProcessGroup method getModifications.

private Set<FlowDifference> getModifications() {
    final StandardVersionControlInformation vci = versionControlInfo.get();
    // So we have to perform a diff of the flows and see if they are the same.
    if (vci == null) {
        return null;
    }
    if (vci.getFlowSnapshot() == null) {
        // As a result, we will just return an empty optional
        return null;
    }
    final NiFiRegistryFlowMapper mapper = new NiFiRegistryFlowMapper();
    final VersionedProcessGroup versionedGroup = mapper.mapProcessGroup(this, controllerServiceProvider, flowController.getFlowRegistryClient(), false);
    final ComparableDataFlow currentFlow = new StandardComparableDataFlow("Local Flow", versionedGroup);
    final ComparableDataFlow snapshotFlow = new StandardComparableDataFlow("Versioned Flow", vci.getFlowSnapshot());
    final FlowComparator flowComparator = new StandardFlowComparator(snapshotFlow, currentFlow, getAncestorGroupServiceIds(), new EvolvingDifferenceDescriptor());
    final FlowComparison comparison = flowComparator.compare();
    final Set<FlowDifference> differences = comparison.getDifferences().stream().filter(difference -> difference.getDifferenceType() != DifferenceType.BUNDLE_CHANGED).filter(FlowDifferenceFilters.FILTER_ADDED_REMOVED_REMOTE_PORTS).collect(Collectors.toCollection(HashSet::new));
    LOG.debug("There are {} differences between this Local Flow and the Versioned Flow: {}", differences.size(), differences);
    return differences;
}
Also used : StandardFlowComparator(org.apache.nifi.registry.flow.diff.StandardFlowComparator) StandardComparableDataFlow(org.apache.nifi.registry.flow.diff.StandardComparableDataFlow) ComparableDataFlow(org.apache.nifi.registry.flow.diff.ComparableDataFlow) FlowDifference(org.apache.nifi.registry.flow.diff.FlowDifference) StandardVersionControlInformation(org.apache.nifi.registry.flow.StandardVersionControlInformation) NiFiRegistryFlowMapper(org.apache.nifi.registry.flow.mapping.NiFiRegistryFlowMapper) EvolvingDifferenceDescriptor(org.apache.nifi.registry.flow.diff.EvolvingDifferenceDescriptor) VersionedProcessGroup(org.apache.nifi.registry.flow.VersionedProcessGroup) FlowComparison(org.apache.nifi.registry.flow.diff.FlowComparison) StandardComparableDataFlow(org.apache.nifi.registry.flow.diff.StandardComparableDataFlow) FlowComparator(org.apache.nifi.registry.flow.diff.FlowComparator) StandardFlowComparator(org.apache.nifi.registry.flow.diff.StandardFlowComparator)

Aggregations

VersionedProcessGroup (org.apache.nifi.registry.flow.VersionedProcessGroup)6 NiFiRegistryFlowMapper (org.apache.nifi.registry.flow.mapping.NiFiRegistryFlowMapper)6 ComparableDataFlow (org.apache.nifi.registry.flow.diff.ComparableDataFlow)4 FlowComparator (org.apache.nifi.registry.flow.diff.FlowComparator)4 FlowComparison (org.apache.nifi.registry.flow.diff.FlowComparison)4 StandardComparableDataFlow (org.apache.nifi.registry.flow.diff.StandardComparableDataFlow)4 StandardFlowComparator (org.apache.nifi.registry.flow.diff.StandardFlowComparator)4 ProcessGroup (org.apache.nifi.groups.ProcessGroup)3 RemoteProcessGroup (org.apache.nifi.groups.RemoteProcessGroup)3 FlowDifference (org.apache.nifi.registry.flow.diff.FlowDifference)3 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 LinkedHashSet (java.util.LinkedHashSet)2 FlowRegistry (org.apache.nifi.registry.flow.FlowRegistry)2 StandardVersionControlInformation (org.apache.nifi.registry.flow.StandardVersionControlInformation)2 InstantiatedVersionedProcessGroup (org.apache.nifi.registry.flow.mapping.InstantiatedVersionedProcessGroup)2 Sets (com.google.common.collect.Sets)1 StandardCharsets (java.nio.charset.StandardCharsets)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1