private Set<VersionedConnection> findAllConnections(final VersionedProcessGroup group) { final Set<VersionedConnection> conns = new HashSet<>(); for (final VersionedConnection connection : group.getConnections()) { conns.add(connection); } for (final VersionedProcessGroup childGroup : group.getProcessGroups()) { conns.addAll(findAllConnections(childGroup)); } return conns; }
private void findAllProcessGroups(final VersionedProcessGroup group, final Map<String, VersionedProcessGroup> map) { map.put(group.getIdentifier(), group); for (final VersionedProcessGroup child : group.getProcessGroups()) { findAllProcessGroups(child, map); } }
private void findAllProcessors(final VersionedProcessGroup group, final Map<String, VersionedProcessor> map) { for (final VersionedProcessor processor : group.getProcessors()) { map.put(processor.getIdentifier(), processor); } for (final VersionedProcessGroup childGroup : group.getProcessGroups()) { findAllProcessors(childGroup, map); } }
private void findAllConnectionIds(final VersionedProcessGroup group, final Set<String> ids) { for (final VersionedConnection connection : group.getConnections()) { ids.add(connection.getIdentifier()); } for (final VersionedProcessGroup childGroup : group.getProcessGroups()) { findAllConnectionIds(childGroup, ids); } }
private void findAllControllerServices(final VersionedProcessGroup group, final Map<String, VersionedControllerService> map) { for (final VersionedControllerService service : group.getControllerServices()) { map.put(service.getIdentifier(), service); } for (final VersionedProcessGroup childGroup : group.getProcessGroups()) { findAllControllerServices(childGroup, map); } }
private void findAllConnections(final VersionedProcessGroup group, final Map<String, VersionedConnection> map) { for (final VersionedConnection connection : group.getConnections()) { map.put(connection.getIdentifier(), connection); } for (final VersionedProcessGroup childGroup : group.getProcessGroups()) { findAllConnections(childGroup, map); } }
private void verifyControllerServicesInVersionedFlow(final VersionedProcessGroup versionedFlow, final Map<String, Set<BundleCoordinate>> supportedTypes) { if (versionedFlow.getControllerServices() != null) { versionedFlow.getControllerServices().forEach(controllerService -> { if (supportedTypes.containsKey(controllerService.getType())) { if (controllerService.getBundle() == null) { throw new IllegalArgumentException("Controller Service bundle must be specified."); } verifyBundleInVersionedFlow(controllerService.getBundle(), supportedTypes.get(controllerService.getType())); } else { throw new IllegalStateException("Invalid Controller Service Type: " + controllerService.getType()); } }); } if (versionedFlow.getProcessGroups() != null) { versionedFlow.getProcessGroups().forEach(processGroup -> { verifyControllerServicesInVersionedFlow(processGroup, supportedTypes); }); } }
private void verifyProcessorsInVersionedFlow(final VersionedProcessGroup versionedFlow, final Map<String, Set<BundleCoordinate>> supportedTypes) { if (versionedFlow.getProcessors() != null) { versionedFlow.getProcessors().forEach(processor -> { if (processor.getBundle() == null) { throw new IllegalArgumentException("Processor bundle must be specified."); } if (supportedTypes.containsKey(processor.getType())) { verifyBundleInVersionedFlow(processor.getBundle(), supportedTypes.get(processor.getType())); } else { throw new IllegalStateException("Invalid Processor Type: " + processor.getType()); } }); } if (versionedFlow.getProcessGroups() != null) { versionedFlow.getProcessGroups().forEach(processGroup -> { verifyProcessorsInVersionedFlow(processGroup, supportedTypes); }); } }
private static void populateComponentTypes(final VersionedProcessGroup group, final Set<Tuple<String, BundleCoordinate>> componentTypes) { group.getProcessors().stream() .map(versionedProc -> new Tuple<>(versionedProc.getType(), createBundleCoordinate(versionedProc.getBundle()))) .forEach(componentTypes::add); group.getControllerServices().stream() .map(versionedSvc -> new Tuple<>(versionedSvc.getType(), createBundleCoordinate(versionedSvc.getBundle()))) .forEach(componentTypes::add); for (final VersionedProcessGroup childGroup : group.getProcessGroups()) { populateComponentTypes(childGroup, componentTypes); } }
for (final VersionedProcessGroup childGroup : versionedFlow.getProcessGroups()) { allConns.addAll(findAllConnections(childGroup));
@Override public VersionedFlowSnapshot getFlowContents(final String bucketId, final String flowId, final int version, final boolean fetchRemoteFlows, final NiFiUser user) throws IOException, NiFiRegistryException { final FlowSnapshotClient snapshotClient = getFlowSnapshotClient(user); final VersionedFlowSnapshot flowSnapshot = snapshotClient.get(bucketId, flowId, version); if (fetchRemoteFlows) { final VersionedProcessGroup contents = flowSnapshot.getFlowContents(); for (final VersionedProcessGroup child : contents.getProcessGroups()) { populateVersionedContentsRecursively(child, user); } } return flowSnapshot; }
private void verifyImportProcessGroup(final VersionControlInformationDTO vciDto, final VersionedProcessGroup contents, final ProcessGroup group) { if (group == null) { return; } final VersionControlInformation vci = group.getVersionControlInformation(); if (vci != null) { // Note that we do not compare the Registry ID here because there could be two registry clients // that point to the same server (one could point to localhost while another points to 127.0.0.1, for instance).. if (Objects.equals(vciDto.getBucketId(), vci.getBucketIdentifier()) && Objects.equals(vciDto.getFlowId(), vci.getFlowIdentifier())) { throw new IllegalStateException("Cannot import the specified Versioned Flow into the Process Group because doing so would cause a recursive dataflow. " + "If Process Group A contains Process Group B, then Process Group B is not allowed to contain the flow identified by Process Group A."); } } final Set<VersionedProcessGroup> childGroups = contents.getProcessGroups(); if (childGroups != null) { for (final VersionedProcessGroup childGroup : childGroups) { final VersionedFlowCoordinates childCoordinates = childGroup.getVersionedFlowCoordinates(); if (childCoordinates != null) { final VersionControlInformationDTO childVci = new VersionControlInformationDTO(); childVci.setBucketId(childCoordinates.getBucketId()); childVci.setFlowId(childCoordinates.getFlowId()); verifyImportProcessGroup(childVci, childGroup, group); } } } verifyImportProcessGroup(vciDto, contents, group.getParent()); }
final Set<String> childGroupsRemoved = new HashSet<>(childGroupsByVersionedId.keySet()); for (final VersionedProcessGroup proposedChildGroup : proposed.getProcessGroups()) { final ProcessGroup childGroup = childGroupsByVersionedId.get(proposedChildGroup.getIdentifier()); final VersionedFlowCoordinates childCoordinates = proposedChildGroup.getVersionedFlowCoordinates();
if (versionedGroup.getProcessGroups() != null) { versionedGroup.getProcessGroups().forEach(processGroup -> { discoverCompatibleBundles(extensionManager, processGroup); });
group.setLabels(contents.getLabels()); group.setOutputPorts(contents.getOutputPorts()); group.setProcessGroups(contents.getProcessGroups()); group.setProcessors(contents.getProcessors()); group.setRemoteProcessGroups(contents.getRemoteProcessGroups()); for (final VersionedProcessGroup child : group.getProcessGroups()) { populateVersionedContentsRecursively(child, user);
for (final VersionedProcessGroup childGroup : processGroup.getProcessGroups()) { if (childGroup.getVersionedFlowCoordinates() == null) { copyChildren.add(stripContentsFromRemoteDescendantGroups(childGroup, false));
private static void getAllVersionedProcessGroups(VersionedProcessGroup versionedProcessGroup, List<VersionedProcessGroup> result) { result.add(versionedProcessGroup); nullToEmpty(versionedProcessGroup.getProcessGroups()).stream().forEach(f -> getAllVersionedProcessGroups(f, result)); }
private static void getAllVersionedProcessGroups(VersionedProcessGroup versionedProcessGroup, List<VersionedProcessGroup> result) { result.add(versionedProcessGroup); nullToEmpty(versionedProcessGroup.getProcessGroups()).stream().forEach(f -> getAllVersionedProcessGroups(f, result)); }
.collect(Collectors.toList())); map.put(ProcessGroupSchema.PROCESS_GROUPS_KEY, nullToEmpty(versionedProcessGroup.getProcessGroups()).stream() .map(p -> addVersionedProcessGroup(new HashMap<>(), p.getIdentifier(), p.getName(), p)).collect(Collectors.toList()));
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); if (groupA.getVersionedFlowCoordinates() == null && groupB.getVersionedFlowCoordinates() == null) { 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)); } }