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 2015/06/07 02:24:24 UTC

[1/4] incubator-nifi git commit: NIFI-427: Allow Process Groups to be deleted as long as no incoming or outgoing connections (unless they are also selected), all components stopped, no FlowFiles queued

Repository: incubator-nifi
Updated Branches:
  refs/heads/develop c9ddf21ad -> 56c173fbd


NIFI-427: Allow Process Groups to be deleted as long as no incoming or outgoing connections (unless they are also selected), all components stopped, no FlowFiles queued


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

Branch: refs/heads/develop
Commit: 5c1afc0897a939bcde803c07216be91b6c4d0c03
Parents: 8d1536e
Author: Mark Payne <ma...@hotmail.com>
Authored: Fri Jun 5 12:59:15 2015 -0400
Committer: Mark Payne <ma...@hotmail.com>
Committed: Fri Jun 5 16:17:50 2015 -0400

----------------------------------------------------------------------
 .../org/apache/nifi/groups/ProcessGroup.java    | 11 +++
 .../nifi/groups/StandardProcessGroup.java       | 88 ++++++++++++++------
 2 files changed, 75 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/5c1afc08/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/groups/ProcessGroup.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/groups/ProcessGroup.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/groups/ProcessGroup.java
index a9cfb58..0e2a3f9 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/groups/ProcessGroup.java
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/groups/ProcessGroup.java
@@ -641,6 +641,17 @@ public interface ProcessGroup {
 
     void verifyCanDelete();
 
+    /**
+     * Ensures that the ProcessGroup is eligible to be deleted.
+     *
+     * @param ignorePortConnections if true, the Connections that are currently connected to Ports
+     * will be ignored. Otherwise, the ProcessGroup is not eligible for deletion if its input ports
+     * or output ports have any connections
+     *
+     * @throws IllegalStateException if the ProcessGroup is not eligible for deletion
+     */
+    void verifyCanDelete(boolean ignorePortConnections);
+
     void verifyCanStart();
 
     void verifyCanStop();

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/5c1afc08/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java
index 9fbfb5d..07e3e91 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java
@@ -243,7 +243,7 @@ public final class StandardProcessGroup implements ProcessGroup {
         }
 
         return new ProcessGroupCounts(inputPortCount, outputPortCount, running, stopped,
-                invalid, disabled, activeRemotePorts, inactiveRemotePorts);
+            invalid, disabled, activeRemotePorts, inactiveRemotePorts);
     }
 
     @Override
@@ -548,9 +548,7 @@ public final class StandardProcessGroup implements ProcessGroup {
 
     @Override
     public void removeProcessGroup(final ProcessGroup group) {
-        if (!requireNonNull(group).isEmpty()) {
-            throw new IllegalStateException("Cannot remove " + group + " because it is not empty");
-        }
+        requireNonNull(group).verifyCanDelete();
 
         writeLock.lock();
         try {
@@ -558,7 +556,7 @@ public final class StandardProcessGroup implements ProcessGroup {
             if (toRemove == null) {
                 throw new IllegalStateException(group + " is not a member of this Process Group");
             }
-            verifyCanRemove(toRemove);
+            toRemove.verifyCanDelete();
 
             processGroups.remove(group.getIdentifier());
 
@@ -568,12 +566,6 @@ public final class StandardProcessGroup implements ProcessGroup {
         }
     }
 
-    private void verifyCanRemove(final ProcessGroup childGroup) {
-        if (!childGroup.isEmpty()) {
-            throw new IllegalStateException("Cannot remove ProcessGroup because it is not empty");
-        }
-    }
-
     @Override
     public void addRemoteProcessGroup(final RemoteProcessGroup remoteGroup) {
         writeLock.lock();
@@ -801,11 +793,11 @@ public final class StandardProcessGroup implements ProcessGroup {
                 } else if (isInputPort(destination)) {
                     if (!processGroups.containsKey(destinationGroup.getIdentifier())) {
                         throw new IllegalStateException("Cannot add Connection to Process Group because its destination is an Input "
-                                + "Port but the Input Port does not belong to a child Process Group");
+                            + "Port but the Input Port does not belong to a child Process Group");
                     }
                 } else if (destinationGroup != this) {
                     throw new IllegalStateException("Cannot add Connection between " + source + " and " + destination
-                            + " because they are in different Process Groups and neither is an Input Port or Output Port");
+                        + " because they are in different Process Groups and neither is an Input Port or Output Port");
                 }
             }
 
@@ -968,7 +960,7 @@ public final class StandardProcessGroup implements ProcessGroup {
         readLock.lock();
         try {
             return inputPorts.isEmpty() && outputPorts.isEmpty() && connections.isEmpty()
-                    && processGroups.isEmpty() && labels.isEmpty() && processors.isEmpty() && remoteGroups.isEmpty();
+                && processGroups.isEmpty() && labels.isEmpty() && processors.isEmpty() && remoteGroups.isEmpty();
         } finally {
             readLock.unlock();
         }
@@ -1638,7 +1630,7 @@ public final class StandardProcessGroup implements ProcessGroup {
                 for (final Connection conn : connectable.getIncomingConnections()) {
                     if (!connectionIds.contains(conn.getIdentifier()) && !connectables.contains(conn.getSource())) {
                         throw new IllegalStateException(connectable + " cannot be removed because it has incoming connections "
-                                + "that are not selected to be deleted");
+                            + "that are not selected to be deleted");
                     }
                 }
             }
@@ -1646,9 +1638,7 @@ public final class StandardProcessGroup implements ProcessGroup {
             // verify that all of the ProcessGroups in the snippet are empty
             for (final String groupId : snippet.getProcessGroups()) {
                 final ProcessGroup toRemove = getProcessGroup(groupId);
-                if (!toRemove.isEmpty()) {
-                    throw new IllegalStateException("Process Group with name " + toRemove.getName() + " cannot be removed because it is not empty");
-                }
+                toRemove.verifyCanDelete(true);
             }
 
             for (final String id : connectionIdsToRemove) {
@@ -1666,15 +1656,15 @@ public final class StandardProcessGroup implements ProcessGroup {
             for (final String id : replaceNullWithEmptySet(snippet.getLabels())) {
                 removeLabel(labels.get(id));
             }
-            for (final String id : replaceNullWithEmptySet(snippet.getProcessGroups())) {
-                removeProcessGroup(processGroups.get(id));
-            }
             for (final String id : replaceNullWithEmptySet(snippet.getProcessors())) {
                 removeProcessor(processors.get(id));
             }
             for (final String id : replaceNullWithEmptySet(snippet.getRemoteProcessGroups())) {
                 removeRemoteProcessGroup(remoteGroups.get(id));
             }
+            for (final String id : replaceNullWithEmptySet(snippet.getProcessGroups())) {
+                removeProcessGroup(processGroups.get(id));
+            }
         } finally {
             writeLock.unlock();
         }
@@ -1850,8 +1840,58 @@ public final class StandardProcessGroup implements ProcessGroup {
 
     @Override
     public void verifyCanDelete() {
-        if (!isEmpty()) {
-            throw new IllegalStateException(this + " is not empty");
+        verifyCanDelete(false);
+    }
+
+    @Override
+    public void verifyCanDelete(final boolean ignoreConnections) {
+        readLock.lock();
+        try {
+            for (final Port port : inputPorts.values()) {
+                port.verifyCanDelete(true);
+            }
+
+            for (final Port port : outputPorts.values()) {
+                port.verifyCanDelete(true);
+            }
+
+            for (final ProcessorNode procNode : processors.values()) {
+                procNode.verifyCanDelete(true);
+            }
+
+            for (final Connection connection : connections.values()) {
+                connection.verifyCanDelete();
+            }
+
+            for (final ProcessGroup childGroup : processGroups.values()) {
+                childGroup.verifyCanDelete();
+            }
+
+            if (!ignoreConnections) {
+                for (final Port port : inputPorts.values()) {
+                    for (final Connection connection : port.getIncomingConnections()) {
+                        if (connection.getSource().equals(port)) {
+                            connection.verifyCanDelete();
+                        } else {
+                            throw new IllegalStateException("Cannot delete Process Group because Input Port " + port +
+                                " has at least one incoming connection from a component outside of the Process Group. Delete this connection first.");
+                        }
+                    }
+                }
+
+                for (final Port port : outputPorts.values()) {
+                    for (final Connection connection : port.getConnections()) {
+                        if (connection.getDestination().equals(port)) {
+                            connection.verifyCanDelete();
+                        } else {
+                            throw new IllegalStateException("Cannot delete Process Group because Output Port " + port +
+                                " has at least one outgoing connection to a component outside of the Process Group. Delete this connection first.");
+                        }
+                    }
+                }
+            }
+        } finally {
+            readLock.unlock();
         }
     }
 
@@ -1936,7 +1976,7 @@ public final class StandardProcessGroup implements ProcessGroup {
                 if (group == null) {
                     throw new IllegalStateException("Snippet references Process Group with ID " + id + ", which does not exist in this ProcessGroup");
                 }
-                group.verifyCanDelete();
+                group.verifyCanDelete(true);
             }
 
             for (final String id : snippet.getProcessors()) {


[2/4] incubator-nifi git commit: NIFI-663: Updating tests to provide valid options for assertions when in a Windows environment. Preferring regex to contains/endsWith

Posted by ma...@apache.org.
NIFI-663: Updating tests to provide valid options for assertions when in a Windows environment. Preferring regex to contains/endsWith

Signed-off-by: Mark Payne <ma...@hotmail.com>


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

Branch: refs/heads/develop
Commit: ffc5cdb92c2d4b1e37645ad0a7f4ac18233de5d8
Parents: 63bdda4
Author: Aldrin Piri <al...@apache.org>
Authored: Sat Jun 6 11:16:52 2015 -0400
Committer: Mark Payne <ma...@hotmail.com>
Committed: Sat Jun 6 11:28:44 2015 -0400

----------------------------------------------------------------------
 .../standard/TestExecuteStreamCommand.java      | 34 ++++++++++----------
 1 file changed, 17 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/ffc5cdb9/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestExecuteStreamCommand.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestExecuteStreamCommand.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestExecuteStreamCommand.java
index 90fb28f..d565bca 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestExecuteStreamCommand.java
+++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestExecuteStreamCommand.java
@@ -16,25 +16,25 @@
  */
 package org.apache.nifi.processors.standard;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.List;
-
 import org.apache.nifi.util.MockFlowFile;
 import org.apache.nifi.util.TestRunner;
 import org.apache.nifi.util.TestRunners;
-
 import org.junit.BeforeClass;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.List;
+import java.util.regex.Pattern;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
 /**
  *
  */
@@ -70,7 +70,7 @@ public class TestExecuteStreamCommand {
         MockFlowFile outputFlowFile = flowFiles.get(0);
         byte[] byteArray = outputFlowFile.toByteArray();
         String result = new String(byteArray);
-        assertTrue("Test was a success\r\n".equals(result) || "Test was a success\n".equals(result));
+        assertTrue(Pattern.compile("Test was a success\r?\n").matcher(result).find());
         assertEquals("0", outputFlowFile.getAttribute("execution.status"));
         assertEquals("java", outputFlowFile.getAttribute("execution.command"));
         assertEquals("-jar;", outputFlowFile.getAttribute("execution.command.args").substring(0, 5));
@@ -131,8 +131,7 @@ public class TestExecuteStreamCommand {
         byte[] byteArray = flowFiles.get(0).toByteArray();
         String result = new String(byteArray);
 
-        assertTrue(result.contains(File.separator + "nifi-standard-processors:ModifiedResult\r\n")
-          || result.contains(File.separator + "nifi-standard-processors:ModifiedResult\n"));
+        assertTrue(Pattern.compile("nifi-standard-processors:ModifiedResult\r?\n").matcher(result).find());
     }
 
     @Test
@@ -153,8 +152,9 @@ public class TestExecuteStreamCommand {
         List<MockFlowFile> flowFiles = controller.getFlowFilesForRelationship(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP);
         byte[] byteArray = flowFiles.get(0).toByteArray();
         String result = new String(byteArray);
-        assertTrue(result.contains(File.separator + "nifi-standard-processors" + File.separator + "target:ModifiedResult\r\n")
-          || result.contains(File.separator + "nifi-standard-processors" + File.separator + "target:ModifiedResult\n"));
+
+        final String quotedSeparator = Pattern.quote(File.separator);
+        assertTrue(Pattern.compile(quotedSeparator + "nifi-standard-processors" + quotedSeparator + "target:ModifiedResult\r?\n").matcher(result).find());
     }
 
     @Test
@@ -177,7 +177,7 @@ public class TestExecuteStreamCommand {
         byte[] byteArray = flowFiles.get(0).toByteArray();
         String result = new String(byteArray);
         assertTrue("TestIngestAndUpdate.jar should not have received anything to modify",
-          result.endsWith("target:ModifiedResult\n"));
+                Pattern.compile("target:ModifiedResult\r?\n$").matcher(result).find());
     }
 
     // this is dependent on window with cygwin...so it's not enabled
@@ -226,7 +226,7 @@ public class TestExecuteStreamCommand {
         List<MockFlowFile> flowFiles = controller.getFlowFilesForRelationship(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP);
         byte[] byteArray = flowFiles.get(0).toByteArray();
         String result = new String(byteArray);
-        String[] dynamicEnvironment = result.split("\n");
+        String[] dynamicEnvironment = result.split("\r?\n");
         assertEquals("Should contain two environment variables starting with NIFI", 2, dynamicEnvironment.length);
         assertEquals("NIFI_TEST_2 environment variable is missing", "NIFI_TEST_2=testvalue2", dynamicEnvironment[0]);
         assertEquals("NIFI_TEST_1 environment variable is missing", "NIFI_TEST_1=testvalue1", dynamicEnvironment[1]);


[4/4] incubator-nifi git commit: Merge branch 'NIFI-427' into develop

Posted by ma...@apache.org.
Merge branch 'NIFI-427' into develop


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

Branch: refs/heads/develop
Commit: 56c173fbd8df7ab6001a5e2f0480e78e00d73644
Parents: 35308ed 5c1afc0
Author: Mark Payne <ma...@hotmail.com>
Authored: Sat Jun 6 20:24:05 2015 -0400
Committer: Mark Payne <ma...@hotmail.com>
Committed: Sat Jun 6 20:24:05 2015 -0400

----------------------------------------------------------------------
 .../org/apache/nifi/groups/ProcessGroup.java    | 11 +++
 .../nifi/groups/StandardProcessGroup.java       | 88 ++++++++++++++------
 2 files changed, 75 insertions(+), 24 deletions(-)
----------------------------------------------------------------------



[3/4] incubator-nifi git commit: Merge branch 'develop' of http://git-wip-us.apache.org/repos/asf/incubator-nifi into develop

Posted by ma...@apache.org.
Merge branch 'develop' of http://git-wip-us.apache.org/repos/asf/incubator-nifi into develop


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

Branch: refs/heads/develop
Commit: 35308edf4ef9a996af3c3b502353cdcddc3679b4
Parents: ffc5cdb c9ddf21
Author: Mark Payne <ma...@hotmail.com>
Authored: Sat Jun 6 20:22:48 2015 -0400
Committer: Mark Payne <ma...@hotmail.com>
Committed: Sat Jun 6 20:22:48 2015 -0400

----------------------------------------------------------------------
 .../nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js  | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------