Java Code Examples for org.apache.nifi.registry.flow.VersionedProcessGroup#setName()
The following examples show how to use
org.apache.nifi.registry.flow.VersionedProcessGroup#setName() .
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: 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 2
Source File: TestJAXBVersionedProcessGroupSerializer.java From nifi-registry with Apache License 2.0 | 5 votes |
@Test public void testSerializeDeserializeFlowSnapshot() throws SerializationException { final VersionedSerializer<VersionedProcessGroup> serializer = new JAXBVersionedProcessGroupSerializer(); final VersionedProcessGroup processGroup1 = new VersionedProcessGroup(); processGroup1.setIdentifier("pg1"); processGroup1.setName("My Process Group"); final VersionedProcessor processor1 = new VersionedProcessor(); processor1.setIdentifier("processor1"); processor1.setName("My Processor 1"); // make sure nested objects are serialized/deserialized processGroup1.getProcessors().add(processor1); final ByteArrayOutputStream out = new ByteArrayOutputStream(); serializer.serialize(1, processGroup1, out); final String snapshotStr = new String(out.toByteArray(), StandardCharsets.UTF_8); //System.out.println(snapshotStr); final ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); in.mark(1024); final int version = serializer.readDataModelVersion(in); Assert.assertEquals(1, version); in.reset(); final VersionedProcessGroup deserializedProcessGroup1 = serializer.deserialize(in); Assert.assertEquals(processGroup1.getIdentifier(), deserializedProcessGroup1.getIdentifier()); Assert.assertEquals(processGroup1.getName(), deserializedProcessGroup1.getName()); Assert.assertEquals(1, deserializedProcessGroup1.getProcessors().size()); final VersionedProcessor deserializedProcessor1 = deserializedProcessGroup1.getProcessors().iterator().next(); Assert.assertEquals(processor1.getIdentifier(), deserializedProcessor1.getIdentifier()); Assert.assertEquals(processor1.getName(), deserializedProcessor1.getName()); }
Example 3
Source File: TestRestAPI.java From nifi-registry with Apache License 2.0 | 5 votes |
private static VersionedFlowSnapshot createSnapshot(Client client, VersionedFlow flow, int num) { final VersionedFlowSnapshotMetadata snapshotMetadata1 = new VersionedFlowSnapshotMetadata(); snapshotMetadata1.setBucketIdentifier(flow.getBucketIdentifier()); snapshotMetadata1.setFlowIdentifier(flow.getIdentifier()); snapshotMetadata1.setVersion(num); snapshotMetadata1.setComments("This is snapshot #" + num); final VersionedProcessGroup snapshotContents1 = new VersionedProcessGroup(); snapshotContents1.setIdentifier("pg1"); snapshotContents1.setName("Process Group 1"); final VersionedFlowSnapshot snapshot1 = new VersionedFlowSnapshot(); snapshot1.setSnapshotMetadata(snapshotMetadata1); snapshot1.setFlowContents(snapshotContents1); final VersionedFlowSnapshot createdSnapshot = client.target(REGISTRY_API_BUCKETS_URL) .path("{bucketId}/flows/{flowId}/versions") .resolveTemplate("bucketId", flow.getBucketIdentifier()) .resolveTemplate("flowId", flow.getIdentifier()) .request() .post( Entity.entity(snapshot1, MediaType.APPLICATION_JSON_TYPE), VersionedFlowSnapshot.class ); return createdSnapshot; }
Example 4
Source File: DBFlowStorageIT.java From nifi-registry with Apache License 2.0 | 5 votes |
private VersionedFlowSnapshot createSnapshot(final Bucket bucket, final VersionedFlow flow, final int version, final String rootPgName) { final VersionedProcessGroup rootPg = new VersionedProcessGroup(); rootPg.setName(rootPgName); final VersionedFlowSnapshotMetadata snapshotMetadata = new VersionedFlowSnapshotMetadata(); snapshotMetadata.setBucketIdentifier(bucket.getIdentifier()); snapshotMetadata.setFlowIdentifier(flow.getIdentifier()); snapshotMetadata.setVersion(version); snapshotMetadata.setComments("comments"); final VersionedFlowSnapshot snapshot = new VersionedFlowSnapshot(); snapshot.setFlowContents(rootPg); snapshot.setSnapshotMetadata(snapshotMetadata); return snapshot; }
Example 5
Source File: TestFlowContentSerializer.java From nifi-registry with Apache License 2.0 | 4 votes |
@Test public void testSerializeDeserializeFlowContent() { final VersionedProcessor processor1 = new VersionedProcessor(); processor1.setIdentifier("processor1"); processor1.setName("My Processor 1"); final VersionedProcessGroup processGroup1 = new VersionedProcessGroup(); processGroup1.setIdentifier("pg1"); processGroup1.setName("My Process Group"); processGroup1.getProcessors().add(processor1); final VersionedFlowSnapshot snapshot = new VersionedFlowSnapshot(); snapshot.setFlowContents(processGroup1); final FlowContent flowContent = new FlowContent(); flowContent.setFlowSnapshot(snapshot); final ByteArrayOutputStream out = new ByteArrayOutputStream(); serializer.serializeFlowContent(flowContent, out); //final String json = new String(out.toByteArray(), StandardCharsets.UTF_8); //System.out.println(json); final ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); // make sure we can read the version from the input stream and it should be the current version final Integer version = serializer.readDataModelVersion(in); assertEquals(serializer.getCurrentDataModelVersion(), version); assertEquals(false, serializer.isProcessGroupVersion(version)); // make sure we can deserialize back to FlowContent final FlowContent deserializedFlowContent = serializer.deserializeFlowContent(version, in); assertNotNull(deserializedFlowContent); final VersionedFlowSnapshot deserializedSnapshot = deserializedFlowContent.getFlowSnapshot(); assertNotNull(deserializedSnapshot); final VersionedProcessGroup deserializedProcessGroup1 = deserializedSnapshot.getFlowContents(); assertNotNull(deserializedProcessGroup1); assertEquals(processGroup1.getIdentifier(), deserializedProcessGroup1.getIdentifier()); assertEquals(processGroup1.getName(), deserializedProcessGroup1.getName()); assertEquals(1, deserializedProcessGroup1.getProcessors().size()); final VersionedProcessor deserializedProcessor1 = deserializedProcessGroup1.getProcessors().iterator().next(); assertEquals(processor1.getIdentifier(), deserializedProcessor1.getIdentifier()); assertEquals(processor1.getName(), deserializedProcessor1.getName()); }
Example 6
Source File: TestFlowContentSerializer.java From nifi-registry with Apache License 2.0 | 4 votes |
@Test public void testSerializeDeserializeWithExternalServices() throws SerializationException { final VersionedProcessGroup processGroup1 = new VersionedProcessGroup(); processGroup1.setIdentifier("pg1"); processGroup1.setName("My Process Group"); final ExternalControllerServiceReference serviceReference1 = new ExternalControllerServiceReference(); serviceReference1.setIdentifier("1"); serviceReference1.setName("Service 1"); final ExternalControllerServiceReference serviceReference2 = new ExternalControllerServiceReference(); serviceReference2.setIdentifier("2"); serviceReference2.setName("Service 2"); final Map<String,ExternalControllerServiceReference> serviceReferences = new HashMap<>(); serviceReferences.put(serviceReference1.getIdentifier(), serviceReference1); serviceReferences.put(serviceReference2.getIdentifier(), serviceReference2); final VersionedFlowSnapshot snapshot = new VersionedFlowSnapshot(); snapshot.setFlowContents(processGroup1); snapshot.setExternalControllerServices(serviceReferences); final FlowContent flowContent = new FlowContent(); flowContent.setFlowSnapshot(snapshot); final ByteArrayOutputStream out = new ByteArrayOutputStream(); serializer.serializeFlowContent(flowContent, out); final ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); // make sure we can read the version from the input stream and it should be the current version final Integer version = serializer.readDataModelVersion(in); assertEquals(serializer.getCurrentDataModelVersion(), version); // make sure we can deserialize back to FlowContent final FlowContent deserializedFlowContent = serializer.deserializeFlowContent(version, in); assertNotNull(deserializedFlowContent); final VersionedFlowSnapshot deserializedSnapshot = deserializedFlowContent.getFlowSnapshot(); assertNotNull(deserializedSnapshot); final VersionedProcessGroup deserializedProcessGroup = deserializedSnapshot.getFlowContents(); assertEquals(processGroup1.getIdentifier(), deserializedProcessGroup.getIdentifier()); assertEquals(processGroup1.getName(), deserializedProcessGroup.getName()); final Map<String,ExternalControllerServiceReference> deserializedServiceReferences = deserializedSnapshot.getExternalControllerServices(); assertNotNull(deserializedServiceReferences); assertEquals(2, deserializedServiceReferences.size()); final ExternalControllerServiceReference deserializedServiceReference1 = deserializedServiceReferences.get(serviceReference1.getIdentifier()); assertNotNull(deserializedServiceReference1); assertEquals(serviceReference1.getIdentifier(), deserializedServiceReference1.getIdentifier()); assertEquals(serviceReference1.getName(), deserializedServiceReference1.getName()); }
Example 7
Source File: SecureNiFiRegistryClientIT.java From nifi-registry with Apache License 2.0 | 4 votes |
@Test public void testCrudOperations() throws IOException, NiFiRegistryException { final Bucket bucket = new Bucket(); bucket.setName("Bucket 1 " + System.currentTimeMillis()); bucket.setDescription("This is bucket 1"); bucket.setRevision(new RevisionInfo(null, 0L)); final BucketClient bucketClient = client.getBucketClient(); final Bucket createdBucket = bucketClient.create(bucket); Assert.assertNotNull(createdBucket); Assert.assertNotNull(createdBucket.getIdentifier()); Assert.assertNotNull(createdBucket.getRevision()); final List<Bucket> buckets = bucketClient.getAll(); Assert.assertEquals(4, buckets.size()); buckets.forEach(b -> Assert.assertNotNull(b.getRevision())); final VersionedFlow flow = new VersionedFlow(); flow.setBucketIdentifier(createdBucket.getIdentifier()); flow.setName("Flow 1 - " + System.currentTimeMillis()); flow.setRevision(new RevisionInfo(null, 0L)); final FlowClient flowClient = client.getFlowClient(); final VersionedFlow createdFlow = flowClient.create(flow); Assert.assertNotNull(createdFlow); Assert.assertNotNull(createdFlow.getIdentifier()); Assert.assertNotNull(createdFlow.getRevision()); final VersionedFlowSnapshotMetadata snapshotMetadata = new VersionedFlowSnapshotMetadata(); snapshotMetadata.setBucketIdentifier(createdFlow.getBucketIdentifier()); snapshotMetadata.setFlowIdentifier(createdFlow.getIdentifier()); snapshotMetadata.setVersion(1); snapshotMetadata.setComments("This is snapshot #1"); final VersionedProcessGroup rootProcessGroup = new VersionedProcessGroup(); rootProcessGroup.setIdentifier("root-pg"); rootProcessGroup.setName("Root Process Group"); final VersionedFlowSnapshot snapshot = new VersionedFlowSnapshot(); snapshot.setSnapshotMetadata(snapshotMetadata); snapshot.setFlowContents(rootProcessGroup); final FlowSnapshotClient snapshotClient = client.getFlowSnapshotClient(); final VersionedFlowSnapshot createdSnapshot = snapshotClient.create(snapshot); Assert.assertNotNull(createdSnapshot); Assert.assertEquals("CN=user1, OU=nifi", createdSnapshot.getSnapshotMetadata().getAuthor()); }
Example 8
Source File: UnsecuredNiFiRegistryClientIT.java From nifi-registry with Apache License 2.0 | 4 votes |
private static VersionedFlowSnapshot buildSnapshot(VersionedFlow flow, int num) { final VersionedFlowSnapshotMetadata snapshotMetadata = new VersionedFlowSnapshotMetadata(); snapshotMetadata.setBucketIdentifier(flow.getBucketIdentifier()); snapshotMetadata.setFlowIdentifier(flow.getIdentifier()); snapshotMetadata.setVersion(num); snapshotMetadata.setComments("This is snapshot #" + num); final VersionedProcessGroup rootProcessGroup = new VersionedProcessGroup(); rootProcessGroup.setIdentifier("root-pg"); rootProcessGroup.setName("Root Process Group"); final VersionedProcessGroup subProcessGroup = new VersionedProcessGroup(); subProcessGroup.setIdentifier("sub-pg"); subProcessGroup.setName("Sub Process Group"); rootProcessGroup.getProcessGroups().add(subProcessGroup); final Map<String,String> processorProperties = new HashMap<>(); processorProperties.put("Prop 1", "Val 1"); processorProperties.put("Prop 2", "Val 2"); final Map<String, VersionedPropertyDescriptor> propertyDescriptors = new HashMap<>(); final VersionedProcessor processor1 = new VersionedProcessor(); processor1.setIdentifier("p1"); processor1.setName("Processor 1"); processor1.setProperties(processorProperties); processor1.setPropertyDescriptors(propertyDescriptors); final VersionedProcessor processor2 = new VersionedProcessor(); processor2.setIdentifier("p2"); processor2.setName("Processor 2"); processor2.setProperties(processorProperties); processor2.setPropertyDescriptors(propertyDescriptors); subProcessGroup.getProcessors().add(processor1); subProcessGroup.getProcessors().add(processor2); final VersionedFlowSnapshot snapshot = new VersionedFlowSnapshot(); snapshot.setSnapshotMetadata(snapshotMetadata); snapshot.setFlowContents(rootProcessGroup); return snapshot; }
Example 9
Source File: ImportFlowIT.java From nifi with Apache License 2.0 | 4 votes |
private VersionedFlowSnapshot createFlowSnapshot(final List<ControllerServiceNode> controllerServices, final List<ProcessorNode> processors, final Set<Parameter> parameters) { final VersionedFlowSnapshotMetadata snapshotMetadata = new VersionedFlowSnapshotMetadata(); snapshotMetadata.setAuthor("unit-test"); snapshotMetadata.setBucketIdentifier("unit-test-bucket"); snapshotMetadata.setFlowIdentifier("unit-test-flow"); snapshotMetadata.setTimestamp(System.currentTimeMillis()); snapshotMetadata.setVersion(1); final Bucket bucket = new Bucket(); bucket.setCreatedTimestamp(System.currentTimeMillis()); bucket.setIdentifier("unit-test-bucket"); bucket.setName("Unit Test Bucket"); final VersionedFlow flow = new VersionedFlow(); flow.setBucketIdentifier("unit-test-bucket"); flow.setBucketName("Unit Test Bucket"); flow.setCreatedTimestamp(System.currentTimeMillis()); flow.setIdentifier("unit-test-flow"); flow.setName("Unit Test Flow"); final BundleCoordinate coordinate = getSystemBundle().getBundleDetails().getCoordinate(); final Bundle bundle = new Bundle(); bundle.setArtifact(coordinate.getId()); bundle.setGroup(coordinate.getGroup()); bundle.setVersion(coordinate.getVersion()); final NiFiRegistryFlowMapper flowMapper = new NiFiRegistryFlowMapper(getExtensionManager()); final Set<VersionedProcessor> versionedProcessors = new HashSet<>(); for (final ProcessorNode processor : processors) { final VersionedProcessor versionedProcessor = flowMapper.mapProcessor(processor, getFlowController().getControllerServiceProvider(), Collections.emptySet(), new HashMap<>()); versionedProcessors.add(versionedProcessor); processor.setVersionedComponentId(versionedProcessor.getIdentifier()); } final Set<VersionedControllerService> services = new HashSet<>(); for (final ControllerServiceNode serviceNode : controllerServices) { final VersionedControllerService service = flowMapper.mapControllerService(serviceNode, getFlowController().getControllerServiceProvider(), Collections.emptySet(), new HashMap<>()); services.add(service); serviceNode.setVersionedComponentId(service.getIdentifier()); } final VersionedProcessGroup flowContents = new VersionedProcessGroup(); flowContents.setIdentifier("unit-test-flow-contents"); flowContents.setName("Unit Test"); flowContents.setProcessors(versionedProcessors); flowContents.setControllerServices(services); final VersionedFlowSnapshot versionedFlowSnapshot = new VersionedFlowSnapshot(); versionedFlowSnapshot.setSnapshotMetadata(snapshotMetadata); versionedFlowSnapshot.setBucket(bucket); versionedFlowSnapshot.setFlow(flow); versionedFlowSnapshot.setFlowContents(flowContents); if (parameters != null) { final Set<VersionedParameter> versionedParameters = new HashSet<>(); for (final Parameter parameter : parameters) { final VersionedParameter versionedParameter = new VersionedParameter(); versionedParameter.setName(parameter.getDescriptor().getName()); versionedParameter.setValue(parameter.getValue()); versionedParameter.setSensitive(parameter.getDescriptor().isSensitive()); versionedParameters.add(versionedParameter); } final VersionedParameterContext versionedParameterContext = new VersionedParameterContext(); versionedParameterContext.setName("Unit Test Context"); versionedParameterContext.setParameters(versionedParameters); versionedFlowSnapshot.setParameterContexts(Collections.singletonMap(versionedParameterContext.getName(), versionedParameterContext)); flowContents.setParameterContextName("Unit Test Context"); } return versionedFlowSnapshot; }