Java Code Examples for org.apache.nifi.registry.flow.VersionedProcessGroup#getVersionedFlowCoordinates()

The following examples show how to use org.apache.nifi.registry.flow.VersionedProcessGroup#getVersionedFlowCoordinates() . 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: RegistryUrlAliasService.java    From nifi-registry with Apache License 2.0 5 votes vote down vote up
/**
 * Recursively replaces the aliases with the external url for a process group and children.
 */
public void setExternal(VersionedProcessGroup processGroup) {
    processGroup.getProcessGroups().forEach(this::setExternal);

    VersionedFlowCoordinates coordinates = processGroup.getVersionedFlowCoordinates();
    if (coordinates != null) {
        coordinates.setRegistryUrl(getExternal(coordinates.getRegistryUrl()));
    }
}
 
Example 2
Source File: RegistryUrlAliasService.java    From nifi-registry with Apache License 2.0 5 votes vote down vote up
/**
 * Recursively replaces the external url with the aliases for a process group and children.
 */
public void setInternal(VersionedProcessGroup processGroup) {
    processGroup.getProcessGroups().forEach(this::setInternal);

    VersionedFlowCoordinates coordinates = processGroup.getVersionedFlowCoordinates();
    if (coordinates != null) {
        coordinates.setRegistryUrl(getInternal(coordinates.getRegistryUrl()));
    }
}
 
Example 3
Source File: StandardFlowComparator.java    From nifi-registry with Apache License 2.0 5 votes vote down vote up
private void compare(final VersionedProcessGroup groupA, final VersionedProcessGroup groupB, final Set<FlowDifference> differences, final boolean compareNamePos) {
    if (compareComponents(groupA, groupB, differences, compareNamePos, compareNamePos, true)) {
        return;
    }

    if (groupA == null) {
        differences.add(difference(DifferenceType.COMPONENT_ADDED, groupA, groupB, groupA, groupB));
        return;
    }

    if (groupB == null) {
        differences.add(difference(DifferenceType.COMPONENT_REMOVED, groupA, groupB, groupA, groupB));
        return;
    }

    addIfDifferent(differences, DifferenceType.VERSIONED_FLOW_COORDINATES_CHANGED, groupA, groupB, VersionedProcessGroup::getVersionedFlowCoordinates);
    addIfDifferent(differences, DifferenceType.FLOWFILE_CONCURRENCY_CHANGED, groupA, groupB, VersionedProcessGroup::getFlowFileConcurrency,
        true, FlowFileConcurrency.UNBOUNDED);
    addIfDifferent(differences, DifferenceType.FLOWFILE_OUTBOUND_POLICY_CHANGED, groupA, groupB, VersionedProcessGroup::getFlowFileOutboundPolicy,
        true, FlowFileOutboundPolicy.STREAM_WHEN_AVAILABLE);

    final VersionedFlowCoordinates groupACoordinates = groupA.getVersionedFlowCoordinates();
    final VersionedFlowCoordinates groupBCoordinates = groupB.getVersionedFlowCoordinates();

    if ((groupACoordinates == null && groupBCoordinates == null)
            || (groupACoordinates != null && groupBCoordinates != null && !groupACoordinates.equals(groupBCoordinates)) ) {
        differences.addAll(compareComponents(groupA.getConnections(), groupB.getConnections(), this::compare));
        differences.addAll(compareComponents(groupA.getProcessors(), groupB.getProcessors(), this::compare));
        differences.addAll(compareComponents(groupA.getControllerServices(), groupB.getControllerServices(), this::compare));
        differences.addAll(compareComponents(groupA.getFunnels(), groupB.getFunnels(), this::compare));
        differences.addAll(compareComponents(groupA.getInputPorts(), groupB.getInputPorts(), this::compare));
        differences.addAll(compareComponents(groupA.getLabels(), groupB.getLabels(), this::compare));
        differences.addAll(compareComponents(groupA.getOutputPorts(), groupB.getOutputPorts(), this::compare));
        differences.addAll(compareComponents(groupA.getProcessGroups(), groupB.getProcessGroups(), (a, b, diffs) -> compare(a, b, diffs, true)));
        differences.addAll(compareComponents(groupA.getRemoteProcessGroups(), groupB.getRemoteProcessGroups(), this::compare));
    }
}
 
Example 4
Source File: RegistryUtil.java    From nifi with Apache License 2.0 5 votes vote down vote up
private void populateVersionedContentsRecursively(final VersionedProcessGroup group, final NiFiUser user) throws NiFiRegistryException, IOException {
    if (group == null) {
        return;
    }

    final VersionedFlowCoordinates coordinates = group.getVersionedFlowCoordinates();
    if (coordinates != null) {
        final String registryUrl = coordinates.getRegistryUrl();
        final String bucketId = coordinates.getBucketId();
        final String flowId = coordinates.getFlowId();
        final int version = coordinates.getVersion();

        final RegistryUtil subFlowUtil = new RegistryUtil(registryUrl, sslContext);
        final VersionedFlowSnapshot snapshot = subFlowUtil.getFlowByID(bucketId, flowId, version);
        final VersionedProcessGroup contents = snapshot.getFlowContents();

        group.setComments(contents.getComments());
        group.setConnections(contents.getConnections());
        group.setControllerServices(contents.getControllerServices());
        group.setFunnels(contents.getFunnels());
        group.setInputPorts(contents.getInputPorts());
        group.setLabels(contents.getLabels());
        group.setOutputPorts(contents.getOutputPorts());
        group.setProcessGroups(contents.getProcessGroups());
        group.setProcessors(contents.getProcessors());
        group.setRemoteProcessGroups(contents.getRemoteProcessGroups());
        group.setVariables(contents.getVariables());
        coordinates.setLatest(snapshot.isLatest());
    }

    for (final VersionedProcessGroup child : group.getProcessGroups()) {
        populateVersionedContentsRecursively(child, user);
    }
}
 
Example 5
Source File: FlowDifferenceFilters.java    From nifi with Apache License 2.0 5 votes vote down vote up
public static boolean isIgnorableVersionedFlowCoordinateChange(final FlowDifference fd) {
    if (fd.getDifferenceType() == DifferenceType.VERSIONED_FLOW_COORDINATES_CHANGED) {
        final VersionedComponent componentA = fd.getComponentA();
        final VersionedComponent componentB = fd.getComponentB();

        if (componentA instanceof VersionedProcessGroup && componentB instanceof VersionedProcessGroup) {
            final VersionedProcessGroup versionedProcessGroupA = (VersionedProcessGroup) componentA;
            final VersionedProcessGroup versionedProcessGroupB = (VersionedProcessGroup) componentB;

            final VersionedFlowCoordinates coordinatesA = versionedProcessGroupA.getVersionedFlowCoordinates();
            final VersionedFlowCoordinates coordinatesB = versionedProcessGroupB.getVersionedFlowCoordinates();

            if (coordinatesA != null && coordinatesB != null) {
                String registryUrlA = coordinatesA.getRegistryUrl();
                String registryUrlB = coordinatesB.getRegistryUrl();

                if (registryUrlA != null && registryUrlB != null && !registryUrlA.equals(registryUrlB)) {
                    if (registryUrlA.endsWith("/")) {
                        registryUrlA = registryUrlA.substring(0, registryUrlA.length() - 1);
                    }

                    if (registryUrlB.endsWith("/")) {
                        registryUrlB = registryUrlB.substring(0, registryUrlB.length() - 1);
                    }

                    if (registryUrlA.equals(registryUrlB)) {
                        return true;
                    }
                }
            }
        }
    }

    return false;
}