You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ma...@apache.org on 2017/06/21 18:21:00 UTC

nifi git commit: NIFI-4075 Updating 'addRemoteProcessGroup' in StandardFlowSerializer to properly use ScheduledStateLookup. This closes #1922.

Repository: nifi
Updated Branches:
  refs/heads/master aabd4a25d -> 77e49b749


NIFI-4075 Updating 'addRemoteProcessGroup' in StandardFlowSerializer to properly use ScheduledStateLookup. This closes #1922.


Project: http://git-wip-us.apache.org/repos/asf/nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/77e49b74
Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/77e49b74
Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/77e49b74

Branch: refs/heads/master
Commit: 77e49b749e6ab0ab0e91827cb0a58680ad52d910
Parents: aabd4a2
Author: Joe Percivall <JP...@apache.org>
Authored: Fri Jun 16 12:39:26 2017 -0400
Committer: Mark Payne <ma...@hotmail.com>
Committed: Wed Jun 21 14:20:22 2017 -0400

----------------------------------------------------------------------
 .../serialization/StandardFlowSerializer.java         | 12 ++++++------
 .../nifi/fingerprint/FingerprintFactoryTest.java      | 14 ++++++++------
 2 files changed, 14 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi/blob/77e49b74/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/serialization/StandardFlowSerializer.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/serialization/StandardFlowSerializer.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/serialization/StandardFlowSerializer.java
index 702932c..4a9a0f7 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/serialization/StandardFlowSerializer.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/serialization/StandardFlowSerializer.java
@@ -188,7 +188,7 @@ public class StandardFlowSerializer implements FlowSerializer {
         }
 
         for (final RemoteProcessGroup remoteRef : group.getRemoteProcessGroups()) {
-            addRemoteProcessGroup(element, remoteRef);
+            addRemoteProcessGroup(element, remoteRef, scheduledStateLookup);
         }
 
         for (final Connection connection : group.getConnections()) {
@@ -261,7 +261,7 @@ public class StandardFlowSerializer implements FlowSerializer {
         addPosition(element, funnel.getPosition());
     }
 
-    private void addRemoteProcessGroup(final Element parentElement, final RemoteProcessGroup remoteRef) {
+    private void addRemoteProcessGroup(final Element parentElement, final RemoteProcessGroup remoteRef, final ScheduledStateLookup scheduledStateLookup) {
         final Document doc = parentElement.getOwnerDocument();
         final Element element = doc.createElement("remoteProcessGroup");
         parentElement.appendChild(element);
@@ -290,20 +290,20 @@ public class StandardFlowSerializer implements FlowSerializer {
 
         for (final RemoteGroupPort port : remoteRef.getInputPorts()) {
             if (port.hasIncomingConnection()) {
-                addRemoteGroupPort(element, port, "inputPort");
+                addRemoteGroupPort(element, port, "inputPort", scheduledStateLookup);
             }
         }
 
         for (final RemoteGroupPort port : remoteRef.getOutputPorts()) {
             if (!port.getConnections().isEmpty()) {
-                addRemoteGroupPort(element, port, "outputPort");
+                addRemoteGroupPort(element, port, "outputPort", scheduledStateLookup);
             }
         }
 
         parentElement.appendChild(element);
     }
 
-    private void addRemoteGroupPort(final Element parentElement, final RemoteGroupPort port, final String elementName) {
+    private void addRemoteGroupPort(final Element parentElement, final RemoteGroupPort port, final String elementName, final ScheduledStateLookup scheduledStateLookup) {
         final Document doc = parentElement.getOwnerDocument();
         final Element element = doc.createElement(elementName);
         parentElement.appendChild(element);
@@ -311,7 +311,7 @@ public class StandardFlowSerializer implements FlowSerializer {
         addTextElement(element, "name", port.getName());
         addPosition(element, port.getPosition());
         addTextElement(element, "comments", port.getComments());
-        addTextElement(element, "scheduledState", port.getScheduledState().name());
+        addTextElement(element, "scheduledState", scheduledStateLookup.getScheduledState(port).name());
         addTextElement(element, "maxConcurrentTasks", port.getMaxConcurrentTasks());
         addTextElement(element, "useCompression", String.valueOf(port.isUseCompression()));
         final Integer batchCount = port.getBatchCount();

http://git-wip-us.apache.org/repos/asf/nifi/blob/77e49b74/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/fingerprint/FingerprintFactoryTest.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/fingerprint/FingerprintFactoryTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/fingerprint/FingerprintFactoryTest.java
index 67f1ad4..1e52cbb 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/fingerprint/FingerprintFactoryTest.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/fingerprint/FingerprintFactoryTest.java
@@ -16,6 +16,7 @@
  */
 package org.apache.nifi.fingerprint;
 
+import static org.apache.nifi.controller.serialization.ScheduledStateLookup.IDENTITY_LOOKUP;
 import static org.apache.nifi.fingerprint.FingerprintFactory.FLOW_CONFIG_XSD;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotEquals;
@@ -33,6 +34,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.apache.nifi.connectable.Position;
 import org.apache.nifi.controller.ScheduledState;
 import org.apache.nifi.controller.serialization.FlowSerializer;
+import org.apache.nifi.controller.serialization.ScheduledStateLookup;
 import org.apache.nifi.controller.serialization.StandardFlowSerializer;
 import org.apache.nifi.encrypt.StringEncryptor;
 import org.apache.nifi.groups.RemoteProcessGroup;
@@ -169,7 +171,7 @@ public class FingerprintFactoryTest {
     }
 
     private <T> Element serializeElement(final StringEncryptor encryptor, final Class<T> componentClass, final T component,
-                                         final String serializerMethodName) throws Exception {
+                                         final String serializerMethodName, ScheduledStateLookup scheduledStateLookup) throws Exception {
 
         final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
         final DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
@@ -177,10 +179,10 @@ public class FingerprintFactoryTest {
 
         final FlowSerializer flowSerializer = new StandardFlowSerializer(encryptor);
         final Method serializeMethod = StandardFlowSerializer.class.getDeclaredMethod(serializerMethodName,
-                Element.class, componentClass);
+                Element.class, componentClass, ScheduledStateLookup.class);
         serializeMethod.setAccessible(true);
         final Element rootElement = doc.createElement("root");
-        serializeMethod.invoke(flowSerializer, rootElement, component);
+        serializeMethod.invoke(flowSerializer, rootElement, component, scheduledStateLookup);
         return rootElement;
     }
 
@@ -234,7 +236,7 @@ public class FingerprintFactoryTest {
                 "NO_VALUE" +
                 "NO_VALUE";
 
-        final Element rootElement = serializeElement(encryptor, RemoteProcessGroup.class, component, "addRemoteProcessGroup");
+        final Element rootElement = serializeElement(encryptor, RemoteProcessGroup.class, component, "addRemoteProcessGroup", IDENTITY_LOOKUP);
         final Element componentElement = (Element) rootElement.getElementsByTagName("remoteProcessGroup").item(0);
         assertEquals(expected, fingerprint("addRemoteProcessGroupFingerprint", Element.class, componentElement));
 
@@ -271,7 +273,7 @@ public class FingerprintFactoryTest {
                 "proxy-user" +
                 "proxy-pass";
 
-        final Element rootElement = serializeElement(encryptor, RemoteProcessGroup.class, component, "addRemoteProcessGroup");
+        final Element rootElement = serializeElement(encryptor, RemoteProcessGroup.class, component, "addRemoteProcessGroup", IDENTITY_LOOKUP);
         final Element componentElement = (Element) rootElement.getElementsByTagName("remoteProcessGroup").item(0);
         assertEquals(expected.toString(), fingerprint("addRemoteProcessGroupFingerprint", Element.class, componentElement));
     }
@@ -310,7 +312,7 @@ public class FingerprintFactoryTest {
                 "64KB" +
                 "10sec";
 
-        final Element rootElement = serializeElement(encryptor, RemoteProcessGroup.class, groupComponent, "addRemoteProcessGroup");
+        final Element rootElement = serializeElement(encryptor, RemoteProcessGroup.class, groupComponent, "addRemoteProcessGroup", IDENTITY_LOOKUP);
         final Element componentElement = (Element) rootElement.getElementsByTagName("inputPort").item(0);
         assertEquals(expected.toString(), fingerprint("addRemoteGroupPortFingerprint", Element.class, componentElement));
     }