Search in sources :

Example 1 with EvolvingDifferenceDescriptor

use of org.apache.nifi.registry.flow.diff.EvolvingDifferenceDescriptor 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

StandardVersionControlInformation (org.apache.nifi.registry.flow.StandardVersionControlInformation)1 VersionedProcessGroup (org.apache.nifi.registry.flow.VersionedProcessGroup)1 ComparableDataFlow (org.apache.nifi.registry.flow.diff.ComparableDataFlow)1 EvolvingDifferenceDescriptor (org.apache.nifi.registry.flow.diff.EvolvingDifferenceDescriptor)1 FlowComparator (org.apache.nifi.registry.flow.diff.FlowComparator)1 FlowComparison (org.apache.nifi.registry.flow.diff.FlowComparison)1 FlowDifference (org.apache.nifi.registry.flow.diff.FlowDifference)1 StandardComparableDataFlow (org.apache.nifi.registry.flow.diff.StandardComparableDataFlow)1 StandardFlowComparator (org.apache.nifi.registry.flow.diff.StandardFlowComparator)1 NiFiRegistryFlowMapper (org.apache.nifi.registry.flow.mapping.NiFiRegistryFlowMapper)1