org.apache.nifi.registry.flow.VersionedProcessGroup Java Examples
The following examples show how to use
org.apache.nifi.registry.flow.VersionedProcessGroup.
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: FlowContentSerializer.java From nifi-registry with Apache License 2.0 | 6 votes |
public FlowContentSerializer() { final Map<Integer, VersionedSerializer<FlowContent>> tempFlowContentSerializers = new HashMap<>(); tempFlowContentSerializers.put(3, new JacksonFlowContentSerializer()); flowContentSerializers = Collections.unmodifiableMap(tempFlowContentSerializers); final Map<Integer, VersionedSerializer<VersionedProcessGroup>> tempProcessGroupSerializers = new HashMap<>(); tempProcessGroupSerializers.put(2, new JacksonVersionedProcessGroupSerializer()); tempProcessGroupSerializers.put(1, new JAXBVersionedProcessGroupSerializer()); processGroupSerializers = Collections.unmodifiableMap(tempProcessGroupSerializers); final Map<Integer,VersionedSerializer<?>> tempAllSerializers = new HashMap<>(); tempAllSerializers.putAll(processGroupSerializers); tempAllSerializers.putAll(flowContentSerializers); allSerializers = Collections.unmodifiableMap(tempAllSerializers); final List<Integer> sortedVersions = new ArrayList<>(allSerializers.keySet()); sortedVersions.sort(Collections.reverseOrder(Integer::compareTo)); this.descendingVersions = sortedVersions; }
Example #2
Source File: TestFlowDifferenceFilters.java From nifi with Apache License 2.0 | 6 votes |
@Test public void testFilterIgnorableVersionedCoordinateDifferencesWithIgnorableDifference() { VersionedFlowCoordinates coordinatesA = new VersionedFlowCoordinates(); coordinatesA.setRegistryUrl("http://localhost:18080"); VersionedProcessGroup processGroupA = new VersionedProcessGroup(); processGroupA.setVersionedFlowCoordinates(coordinatesA); VersionedFlowCoordinates coordinatesB = new VersionedFlowCoordinates(); coordinatesB.setRegistryUrl("http://localhost:18080/"); VersionedProcessGroup processGroupB = new VersionedProcessGroup(); processGroupB.setVersionedFlowCoordinates(coordinatesB); StandardFlowDifference flowDifference = new StandardFlowDifference( DifferenceType.VERSIONED_FLOW_COORDINATES_CHANGED, processGroupA, processGroupB, coordinatesA.getRegistryUrl(), coordinatesB.getRegistryUrl(), ""); Assert.assertFalse(FlowDifferenceFilters.FILTER_IGNORABLE_VERSIONED_FLOW_COORDINATE_CHANGES.test(flowDifference)); }
Example #3
Source File: TestFlowContentSerializer.java From nifi-registry with Apache License 2.0 | 6 votes |
@Test public void testDeserializeVer1() throws IOException { final String file = "/serialization/ver1.snapshot"; final VersionedProcessGroup processGroup; try (final InputStream is = this.getClass().getResourceAsStream(file)) { final Integer version = serializer.readDataModelVersion(is); assertNotNull(version); assertEquals(1, version.intValue()); if (serializer.isProcessGroupVersion(version)) { processGroup = serializer.deserializeProcessGroup(version, is); } else { processGroup = null; } } assertNotNull(processGroup); assertNotNull(processGroup.getProcessors()); assertTrue(processGroup.getProcessors().size() > 0); //System.out.printf("processGroup=" + processGroup); }
Example #4
Source File: TestFlowDifferenceFilters.java From nifi with Apache License 2.0 | 6 votes |
@Test public void testFilterIgnorableVersionedCoordinateDifferencesWithNonIgnorableDifference() { VersionedFlowCoordinates coordinatesA = new VersionedFlowCoordinates(); coordinatesA.setRegistryUrl("http://localhost:18080"); VersionedProcessGroup processGroupA = new VersionedProcessGroup(); processGroupA.setVersionedFlowCoordinates(coordinatesA); VersionedFlowCoordinates coordinatesB = new VersionedFlowCoordinates(); coordinatesB.setRegistryUrl("http://localhost:18080"); VersionedProcessGroup processGroupB = new VersionedProcessGroup(); processGroupB.setVersionedFlowCoordinates(coordinatesB); StandardFlowDifference flowDifference = new StandardFlowDifference( DifferenceType.VERSIONED_FLOW_COORDINATES_CHANGED, processGroupA, processGroupB, coordinatesA.getRegistryUrl(), coordinatesB.getRegistryUrl(), ""); Assert.assertTrue(FlowDifferenceFilters.FILTER_IGNORABLE_VERSIONED_FLOW_COORDINATE_CHANGES.test(flowDifference)); }
Example #5
Source File: ImportFlowIT.java From nifi with Apache License 2.0 | 6 votes |
private Set<FlowDifference> getLocalModifications(final ProcessGroup processGroup, final VersionedFlowSnapshot versionedFlowSnapshot) { final NiFiRegistryFlowMapper mapper = new NiFiRegistryFlowMapper(getFlowController().getExtensionManager()); final VersionedProcessGroup localGroup = mapper.mapProcessGroup(processGroup, getFlowController().getControllerServiceProvider(), getFlowController().getFlowRegistryClient(), true); final VersionedProcessGroup registryGroup = versionedFlowSnapshot.getFlowContents(); final ComparableDataFlow localFlow = new StandardComparableDataFlow("Local Flow", localGroup); final ComparableDataFlow registryFlow = new StandardComparableDataFlow("Versioned Flow", registryGroup); final Set<String> ancestorServiceIds = processGroup.getAncestorServiceIds(); final FlowComparator flowComparator = new StandardFlowComparator(registryFlow, localFlow, ancestorServiceIds, new ConciseEvolvingDifferenceDescriptor()); final FlowComparison flowComparison = flowComparator.compare(); final Set<FlowDifference> differences = flowComparison.getDifferences().stream() .filter(difference -> difference.getDifferenceType() != DifferenceType.BUNDLE_CHANGED) .filter(FlowDifferenceFilters.FILTER_ADDED_REMOVED_REMOTE_PORTS) .filter(FlowDifferenceFilters.FILTER_PUBLIC_PORT_NAME_CHANGES) .filter(FlowDifferenceFilters.FILTER_IGNORABLE_VERSIONED_FLOW_COORDINATE_CHANGES) .collect(Collectors.toCollection(HashSet::new)); return differences; }
Example #6
Source File: NiFiRegistryFlowMapper.java From nifi with Apache License 2.0 | 6 votes |
private void populateReferencedAncestorVariables(final ProcessGroup group, final VersionedProcessGroup versionedGroup) { final Set<String> ancestorVariableNames = new HashSet<>(); populateVariableNames(group.getParent(), ancestorVariableNames); final Map<String, String> implicitlyDefinedVariables = new HashMap<>(); for (final String variableName : ancestorVariableNames) { final boolean isReferenced = !group.getComponentsAffectedByVariable(variableName).isEmpty(); if (isReferenced) { final String value = group.getVariableRegistry().getVariableValue(variableName); implicitlyDefinedVariables.put(variableName, value); } } if (!implicitlyDefinedVariables.isEmpty()) { // Merge the implicit variables with the explicitly defined variables for the Process Group // and set those as the Versioned Group's variables. if (versionedGroup.getVariables() != null) { implicitlyDefinedVariables.putAll(versionedGroup.getVariables()); } versionedGroup.setVariables(implicitlyDefinedVariables); } }
Example #7
Source File: TestFlowContentSerializer.java From nifi-registry with Apache License 2.0 | 6 votes |
@Test public void testDeserializeVer2() throws IOException { final String file = "/serialization/ver2.snapshot"; final VersionedProcessGroup processGroup; try (final InputStream is = this.getClass().getResourceAsStream(file)) { final Integer version = serializer.readDataModelVersion(is); assertNotNull(version); assertEquals(2, version.intValue()); if (serializer.isProcessGroupVersion(version)) { processGroup = serializer.deserializeProcessGroup(version, is); } else { processGroup = null; } } assertNotNull(processGroup); assertNotNull(processGroup.getProcessors()); assertTrue(processGroup.getProcessors().size() > 0); //System.out.printf("processGroup=" + processGroup); }
Example #8
Source File: TestFlowContentSerializer.java From nifi-registry with Apache License 2.0 | 6 votes |
@Test public void testDeserializeVer3() throws IOException { final String file = "/serialization/ver3.snapshot"; try (final InputStream is = this.getClass().getResourceAsStream(file)) { final Integer version = serializer.readDataModelVersion(is); assertNotNull(version); assertEquals(3, version.intValue()); assertFalse(serializer.isProcessGroupVersion(version)); final FlowContent flowContent = serializer.deserializeFlowContent(version, is); assertNotNull(flowContent); final VersionedFlowSnapshot flowSnapshot = flowContent.getFlowSnapshot(); assertNotNull(flowSnapshot); final VersionedProcessGroup processGroup = flowSnapshot.getFlowContents(); assertNotNull(processGroup); assertNotNull(processGroup.getProcessors()); assertEquals(1, processGroup.getProcessors().size()); } }
Example #9
Source File: FlowController.java From nifi with Apache License 2.0 | 6 votes |
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); }); } }
Example #10
Source File: TestRegistryService.java From nifi-registry with Apache License 2.0 | 6 votes |
private VersionedFlowSnapshot createSnapshot() { final VersionedFlowSnapshotMetadata snapshotMetadata = new VersionedFlowSnapshotMetadata(); snapshotMetadata.setFlowIdentifier("flow1"); snapshotMetadata.setVersion(1); snapshotMetadata.setComments("This is the first snapshot"); snapshotMetadata.setBucketIdentifier("b1"); snapshotMetadata.setAuthor("user1"); final VersionedProcessGroup processGroup = new VersionedProcessGroup(); processGroup.setIdentifier("pg1"); processGroup.setName("My Process Group"); final VersionedFlowSnapshot snapshot = new VersionedFlowSnapshot(); snapshot.setSnapshotMetadata(snapshotMetadata); snapshot.setFlowContents(processGroup); return snapshot; }
Example #11
Source File: TestRegistryService.java From nifi-registry with Apache License 2.0 | 6 votes |
@Test public void testGetDiffReturnsRemovedComponentChanges() { when(flowPersistenceProvider.getFlowContent( anyString(), anyString(), anyInt() )).thenReturn(new byte[10], new byte[10]); final VersionedProcessGroup pgA = createVersionedProcessGroupA(); final VersionedProcessGroup pgB = createVersionedProcessGroupB(); when(flowContentSerializer.readDataModelVersion(any(InputStream.class))).thenReturn(2); when(flowContentSerializer.isProcessGroupVersion(eq(2))).thenReturn(true); when(flowContentSerializer.deserializeProcessGroup(eq(2),any())).thenReturn(pgA, pgB); final VersionedFlowDifference diff = registryService.getFlowDiff( "bucketIdentifier", "flowIdentifier", 1, 2); assertNotNull(diff); Optional<ComponentDifferenceGroup> removedComponent = diff.getComponentDifferenceGroups().stream() .filter(p->p.getComponentId().equals("ID-pg1")).findFirst(); assertTrue(removedComponent.isPresent()); assertTrue(removedComponent.get().getDifferences().iterator().next().getDifferenceType().equals("COMPONENT_REMOVED")); }
Example #12
Source File: FlowController.java From nifi with Apache License 2.0 | 6 votes |
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); }); } }
Example #13
Source File: TestProcessGroupResource.java From nifi with Apache License 2.0 | 6 votes |
@Test public void testExportProcessGroup() { final String groupId = UUID.randomUUID().toString(); final VersionedFlowSnapshot versionedFlowSnapshot = mock(VersionedFlowSnapshot.class); when(serviceFacade.getCurrentFlowSnapshotByGroupId(groupId)).thenReturn(versionedFlowSnapshot); final String flowName = "flowname"; final VersionedProcessGroup versionedProcessGroup = mock(VersionedProcessGroup.class); when(versionedFlowSnapshot.getFlowContents()).thenReturn(versionedProcessGroup); when(versionedProcessGroup.getName()).thenReturn(flowName); final Response response = processGroupResource.exportProcessGroup(groupId); final VersionedFlowSnapshot resultEntity = (VersionedFlowSnapshot)response.getEntity(); assertEquals(200, response.getStatus()); assertEquals(versionedFlowSnapshot, resultEntity); }
Example #14
Source File: IntegrationTestUtils.java From nifi-registry with Apache License 2.0 | 6 votes |
private static void assertVersionedProcessGroupsEqual(VersionedProcessGroup expected, VersionedProcessGroup actual) { assertNotNull(actual); assertEquals(((VersionedComponent)expected), ((VersionedComponent)actual)); // Poor man's set equality assertion as we are only checking the base type and not doing a recursive check // TODO, this would be a stronger assertion by replacing this with a true VersionedProcessGroup.equals() method that does a deep equality check assertSetsEqual(expected.getProcessGroups(), actual.getProcessGroups()); assertSetsEqual(expected.getRemoteProcessGroups(), actual.getRemoteProcessGroups()); assertSetsEqual(expected.getProcessors(), actual.getProcessors()); assertSetsEqual(expected.getInputPorts(), actual.getInputPorts()); assertSetsEqual(expected.getOutputPorts(), actual.getOutputPorts()); assertSetsEqual(expected.getConnections(), actual.getConnections()); assertSetsEqual(expected.getLabels(), actual.getLabels()); assertSetsEqual(expected.getFunnels(), actual.getFunnels()); assertSetsEqual(expected.getControllerServices(), actual.getControllerServices()); }
Example #15
Source File: StandardProcessGroupDAO.java From nifi with Apache License 2.0 | 6 votes |
@Override public ProcessGroup updateVersionControlInformation(final VersionControlInformationDTO versionControlInformation, final Map<String, String> versionedComponentMapping) { final String groupId = versionControlInformation.getGroupId(); final ProcessGroup group = locateProcessGroup(flowController, groupId); final String registryId = versionControlInformation.getRegistryId(); final FlowRegistry flowRegistry = flowController.getFlowRegistryClient().getFlowRegistry(registryId); final String registryName = flowRegistry == null ? registryId : flowRegistry.getName(); final NiFiRegistryFlowMapper mapper = new NiFiRegistryFlowMapper(flowController.getExtensionManager()); final VersionedProcessGroup flowSnapshot = mapper.mapProcessGroup(group, flowController.getControllerServiceProvider(), flowController.getFlowRegistryClient(), false); final StandardVersionControlInformation vci = StandardVersionControlInformation.Builder.fromDto(versionControlInformation) .registryName(registryName) .flowSnapshot(flowSnapshot) .build(); group.setVersionControlInformation(vci, versionedComponentMapping); group.onComponentModified(); return group; }
Example #16
Source File: FlowUpdateResource.java From nifi with Apache License 2.0 | 6 votes |
/** * Authorize read/write permissions for the given user on every component of the given flow in support of flow update. * * @param lookup A lookup instance to use for retrieving components for authorization purposes * @param user the user to authorize * @param groupId the id of the process group being evaluated * @param flowSnapshot the new flow contents to examine for restricted components */ protected void authorizeFlowUpdate(final AuthorizableLookup lookup, final NiFiUser user, final String groupId, final VersionedFlowSnapshot flowSnapshot) { // Step 2: Verify READ and WRITE permissions for user, for every component. final ProcessGroupAuthorizable groupAuthorizable = lookup.getProcessGroup(groupId); authorizeProcessGroup(groupAuthorizable, authorizer, lookup, RequestAction.READ, true, false, true, true, true); authorizeProcessGroup(groupAuthorizable, authorizer, lookup, RequestAction.WRITE, true, false, true, true, false); final VersionedProcessGroup groupContents = flowSnapshot.getFlowContents(); final Set<ConfigurableComponent> restrictedComponents = FlowRegistryUtils.getRestrictedComponents(groupContents, serviceFacade); restrictedComponents.forEach(restrictedComponent -> { final ComponentAuthorizable restrictedComponentAuthorizable = lookup.getConfigurableComponent(restrictedComponent); authorizeRestrictions(authorizer, restrictedComponentAuthorizable); }); final Map<String, VersionedParameterContext> parameterContexts = flowSnapshot.getParameterContexts(); if (parameterContexts != null) { parameterContexts.values().forEach( context -> AuthorizeParameterReference.authorizeParameterContextAddition(context, serviceFacade, authorizer, lookup, user) ); } }
Example #17
Source File: MockSingleFlowRegistryClient.java From nifi with Apache License 2.0 | 5 votes |
@Override public VersionedFlowSnapshot registerVersionedFlowSnapshot(final VersionedFlow flow, final VersionedProcessGroup snapshot, final Map<String, ExternalControllerServiceReference> externalControllerServices, final Map<String, VersionedParameterContext> parameterContexts, final String comments, final int expectedVersion, final NiFiUser user) throws IOException, NiFiRegistryException { return null; }
Example #18
Source File: RegistryUtil.java From nifi with Apache License 2.0 | 5 votes |
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; }
Example #19
Source File: RegistryUtil.java From nifi with Apache License 2.0 | 5 votes |
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 #20
Source File: FlowDifferenceFilters.java From nifi with Apache License 2.0 | 5 votes |
/** * Determines whether or not the given Process Group has a Connection whose source is the given Processor and that contains the given relationship * * @param processGroup the process group * @param processor the source processor * @param relationship the relationship * * @return <code>true</code> if such a connection exists, <code>false</code> otherwise. */ private static boolean hasConnection(final VersionedProcessGroup processGroup, final VersionedProcessor processor, final String relationship) { for (final VersionedConnection connection : processGroup.getConnections()) { if (connection.getSource().getId().equals(processor.getIdentifier()) && connection.getSelectedRelationships().contains(relationship)) { return true; } } return false; }
Example #21
Source File: FlowController.java From nifi with Apache License 2.0 | 5 votes |
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; }
Example #22
Source File: FlowDifferenceFilters.java From nifi with Apache License 2.0 | 5 votes |
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; }
Example #23
Source File: NiFiRegistryFlowMapper.java From nifi with Apache License 2.0 | 5 votes |
private InstantiatedVersionedProcessGroup mapGroup(final ProcessGroup group, final ControllerServiceProvider serviceProvider, final BiFunction<ProcessGroup, VersionedProcessGroup, Boolean> applyVersionControlInfo) { final Set<String> allIncludedGroupsIds = group.findAllProcessGroups().stream() .map(ProcessGroup::getIdentifier) .collect(Collectors.toSet()); allIncludedGroupsIds.add(group.getIdentifier()); final Map<String, ExternalControllerServiceReference> externalControllerServiceReferences = new HashMap<>(); final InstantiatedVersionedProcessGroup versionedGroup = mapGroup(group, serviceProvider, applyVersionControlInfo, true, allIncludedGroupsIds, externalControllerServiceReferences); populateReferencedAncestorVariables(group, versionedGroup); return versionedGroup; }
Example #24
Source File: NiFiRegistryFlowMapperTest.java From nifi with Apache License 2.0 | 5 votes |
/** * Test mapping a versioned ProcessGroup model to a versioned VersionedProcessGroup excluding descendant versioned flows. * VersionControlInformation should be mapped to the versioned inner process group instead of the group contents */ @Test public void testMapVersionedProcessGroupsExcludingVersionedDescendants() { // prepare a versioned process group with a nested versioned process group, each with 1 processor final ProcessGroup innerProcessGroup = prepareProcessGroup(1,false, false, false, false, false,null, false, true, Collections.emptyList()); final ProcessGroup processGroup = prepareProcessGroup(1,false,false, false, false, false, null, false, true, Lists.newArrayList(innerProcessGroup)); final List<ProcessGroup> allProcessGroups = Lists.newArrayList(innerProcessGroup); when(processGroup.findAllProcessGroups()).thenReturn(allProcessGroups); // perform the mapping, excluding descendant versioned flows final InstantiatedVersionedProcessGroup versionedProcessGroup = flowMapper.mapProcessGroup(processGroup, controllerServiceProvider, flowRegistryClient, false); final VersionedProcessGroup innerVersionedProcessGroup = versionedProcessGroup.getProcessGroups().iterator().next(); // verify root versioned process group contents only verifyVersionedProcessGroup(processGroup, versionedProcessGroup,false,false); // verify versioned descendant is present with VersionControlInfo only verifyVersionedProcessGroup(innerProcessGroup, innerVersionedProcessGroup,true,false); }
Example #25
Source File: VersionsResource.java From nifi with Apache License 2.0 | 5 votes |
/** * Recursively clear the registry info in the given versioned process group and all nested versioned process groups * * @param versionedProcessGroup the process group to sanitize */ private void sanitizeRegistryInfo(final VersionedProcessGroup versionedProcessGroup) { versionedProcessGroup.setVersionedFlowCoordinates(null); for (final VersionedProcessGroup innerVersionedProcessGroup : versionedProcessGroup.getProcessGroups()) { sanitizeRegistryInfo(innerVersionedProcessGroup); } }
Example #26
Source File: NiFiRegConfigSchemaFunction.java From nifi-minifi with Apache License 2.0 | 5 votes |
@Override public ConfigSchema apply(final VersionedFlowSnapshot versionedFlowSnapshot) { Map<String, Object> map = new HashMap<>(); map.put(CommonPropertyKeys.FLOW_CONTROLLER_PROPS_KEY, flowControllerSchemaFunction.apply(versionedFlowSnapshot).toMap()); VersionedProcessGroup versionedProcessGroup = versionedFlowSnapshot.getFlowContents(); addVersionedProcessGroup(map, versionedProcessGroup); return new ConfigSchema(map); }
Example #27
Source File: StandardFlowComparator.java From nifi-registry with Apache License 2.0 | 5 votes |
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 #28
Source File: StandardFlowComparator.java From nifi-registry with Apache License 2.0 | 5 votes |
private Set<FlowDifference> compare(final VersionedProcessGroup groupA, final VersionedProcessGroup groupB) { final Set<FlowDifference> differences = new HashSet<>(); // Note that we do not compare the names, because when we import a Flow into NiFi, we may well give it a new name. // Child Process Groups' names will still compare but the main group that is under Version Control will not compare(groupA, groupB, differences, false); return differences; }
Example #29
Source File: StandardFlowComparator.java From nifi-registry with Apache License 2.0 | 5 votes |
@Override public FlowComparison compare() { final VersionedProcessGroup groupA = flowA.getContents(); final VersionedProcessGroup groupB = flowB.getContents(); final Set<FlowDifference> differences = compare(groupA, groupB); return new StandardFlowComparison(flowA, flowB, differences); }
Example #30
Source File: TestVersionsResource.java From nifi with Apache License 2.0 | 5 votes |
@Test public void testExportFlowVersion() { final String groupId = UUID.randomUUID().toString(); final VersionedFlowSnapshot versionedFlowSnapshot = mock(VersionedFlowSnapshot.class); when(serviceFacade.getVersionedFlowSnapshotByGroupId(groupId)).thenReturn(versionedFlowSnapshot); final String flowName = "flowname"; final int flowVersion = 1; final VersionedProcessGroup versionedProcessGroup = mock(VersionedProcessGroup.class); final VersionedFlowSnapshotMetadata snapshotMetadata = mock(VersionedFlowSnapshotMetadata.class); when(versionedFlowSnapshot.getFlowContents()).thenReturn(versionedProcessGroup); when(versionedProcessGroup.getName()).thenReturn(flowName); when(versionedFlowSnapshot.getSnapshotMetadata()).thenReturn(snapshotMetadata); when(snapshotMetadata.getVersion()).thenReturn(flowVersion); final VersionedProcessGroup innerVersionedProcessGroup = mock(VersionedProcessGroup.class); final VersionedProcessGroup innerInnerVersionedProcessGroup = mock(VersionedProcessGroup.class); when(versionedProcessGroup.getProcessGroups()).thenReturn(Sets.newHashSet(innerVersionedProcessGroup)); when(innerVersionedProcessGroup.getProcessGroups()).thenReturn(Sets.newHashSet(innerInnerVersionedProcessGroup)); final Response response = versionsResource.exportFlowVersion(groupId); final VersionedFlowSnapshot resultEntity = (VersionedFlowSnapshot)response.getEntity(); assertEquals(200, response.getStatus()); assertEquals(versionedFlowSnapshot, resultEntity); verify(versionedFlowSnapshot).setFlow(null); verify(versionedFlowSnapshot).setBucket(null); verify(versionedFlowSnapshot).setSnapshotMetadata(null); verify(versionedProcessGroup).setVersionedFlowCoordinates(null); verify(innerVersionedProcessGroup).setVersionedFlowCoordinates(null); verify(innerInnerVersionedProcessGroup).setVersionedFlowCoordinates(null); }