You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by kd...@apache.org on 2019/04/25 16:25:52 UTC

[nifi-registry] branch master updated: NIFIREG-251 Update data model to allow tracking of external controller service references (#173)

This is an automated email from the ASF dual-hosted git repository.

kdoran pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nifi-registry.git


The following commit(s) were added to refs/heads/master by this push:
     new cd50df8  NIFIREG-251 Update data model to allow tracking of external controller service references (#173)
cd50df8 is described below

commit cd50df84e4cee6be7f28acd8a994fce96c3c88b2
Author: Bryan Bende <bb...@apache.org>
AuthorDate: Thu Apr 25 12:25:48 2019 -0400

    NIFIREG-251 Update data model to allow tracking of external controller service references (#173)
---
 .../flow/ExternalControllerServiceReference.java   | 45 ++++++++++++++++++++++
 .../nifi/registry/flow/VersionedProcessGroup.java  | 17 ++++++--
 .../TestVersionedProcessGroupSerializer.java       | 44 +++++++++++++++++++++
 3 files changed, 102 insertions(+), 4 deletions(-)

diff --git a/nifi-registry-core/nifi-registry-data-model/src/main/java/org/apache/nifi/registry/flow/ExternalControllerServiceReference.java b/nifi-registry-core/nifi-registry-data-model/src/main/java/org/apache/nifi/registry/flow/ExternalControllerServiceReference.java
new file mode 100644
index 0000000..3bc269e
--- /dev/null
+++ b/nifi-registry-core/nifi-registry-data-model/src/main/java/org/apache/nifi/registry/flow/ExternalControllerServiceReference.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.registry.flow;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+@ApiModel
+public class ExternalControllerServiceReference {
+
+    private String identifier;
+    private String name;
+
+    @ApiModelProperty("The identifier of the controller service")
+    public String getIdentifier() {
+        return identifier;
+    }
+
+    public void setIdentifier(String identifier) {
+        this.identifier = identifier;
+    }
+
+    @ApiModelProperty("The name of the controller service")
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+}
diff --git a/nifi-registry-core/nifi-registry-data-model/src/main/java/org/apache/nifi/registry/flow/VersionedProcessGroup.java b/nifi-registry-core/nifi-registry-data-model/src/main/java/org/apache/nifi/registry/flow/VersionedProcessGroup.java
index 2acd0a4..071574d 100644
--- a/nifi-registry-core/nifi-registry-data-model/src/main/java/org/apache/nifi/registry/flow/VersionedProcessGroup.java
+++ b/nifi-registry-core/nifi-registry-data-model/src/main/java/org/apache/nifi/registry/flow/VersionedProcessGroup.java
@@ -17,15 +17,14 @@
 
 package org.apache.nifi.registry.flow;
 
+import io.swagger.annotations.ApiModelProperty;
+
+import javax.xml.bind.annotation.XmlRootElement;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
-import javax.xml.bind.annotation.XmlRootElement;
-
-import io.swagger.annotations.ApiModelProperty;
-
 @XmlRootElement
 public class VersionedProcessGroup extends VersionedComponent {
 
@@ -41,6 +40,7 @@ public class VersionedProcessGroup extends VersionedComponent {
     private VersionedFlowCoordinates versionedFlowCoordinates = null;
 
     private Map<String, String> variables = new HashMap<>();
+    private Map<String,ExternalControllerServiceReference> externalControllerServices;
 
     @ApiModelProperty("The child Process Groups")
     public Set<VersionedProcessGroup> getProcessGroups() {
@@ -145,4 +145,13 @@ public class VersionedProcessGroup extends VersionedComponent {
     public VersionedFlowCoordinates getVersionedFlowCoordinates() {
         return versionedFlowCoordinates;
     }
+
+    @ApiModelProperty("The information about controller services that exist outside the versioned process group, but are referenced by components within the versioned process group.")
+    public Map<String, ExternalControllerServiceReference> getExternalControllerServices() {
+        return externalControllerServices;
+    }
+
+    public void setExternalControllerServices(Map<String, ExternalControllerServiceReference> externalControllerServices) {
+        this.externalControllerServices = externalControllerServices;
+    }
 }
diff --git a/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/serialization/TestVersionedProcessGroupSerializer.java b/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/serialization/TestVersionedProcessGroupSerializer.java
index 38fdc03..145204b 100644
--- a/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/serialization/TestVersionedProcessGroupSerializer.java
+++ b/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/serialization/TestVersionedProcessGroupSerializer.java
@@ -16,6 +16,7 @@
  */
 package org.apache.nifi.registry.serialization;
 
+import org.apache.nifi.registry.flow.ExternalControllerServiceReference;
 import org.apache.nifi.registry.flow.VersionedProcessGroup;
 import org.apache.nifi.registry.flow.VersionedProcessor;
 import org.junit.Assert;
@@ -25,6 +26,8 @@ import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
@@ -64,6 +67,47 @@ public class TestVersionedProcessGroupSerializer {
     }
 
     @Test
+    public void testSerializeDeserializeWithExternalServices() throws SerializationException {
+        final Serializer<VersionedProcessGroup> serializer = new VersionedProcessGroupSerializer();
+
+        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);
+
+        processGroup1.setExternalControllerServices(serviceReferences);
+
+        final ByteArrayOutputStream out = new ByteArrayOutputStream();
+        serializer.serialize(processGroup1, out);
+
+        final ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
+        final VersionedProcessGroup deserializedProcessGroup = serializer.deserialize(in);
+
+        Assert.assertEquals(processGroup1.getIdentifier(), deserializedProcessGroup.getIdentifier());
+        Assert.assertEquals(processGroup1.getName(), deserializedProcessGroup.getName());
+
+        final Map<String,ExternalControllerServiceReference> deserializedServiceReferences = deserializedProcessGroup.getExternalControllerServices();
+        Assert.assertNotNull(deserializedServiceReferences);
+        Assert.assertEquals(2, deserializedServiceReferences.size());
+
+        final ExternalControllerServiceReference deserializedServiceReference1 = deserializedServiceReferences.get(serviceReference1.getIdentifier());
+        Assert.assertNotNull(deserializedServiceReference1);
+        Assert.assertEquals(serviceReference1.getIdentifier(), deserializedServiceReference1.getIdentifier());
+        Assert.assertEquals(serviceReference1.getName(), deserializedServiceReference1.getName());
+    }
+
+    @Test
     public void testDeserializeJsonNonIntegerVersion() throws IOException {
         final String file = "/serialization/json/non-integer-version.snapshot";
         final VersionedProcessGroupSerializer serializer = new VersionedProcessGroupSerializer();