You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by bb...@apache.org on 2017/01/12 16:21:59 UTC

nifi git commit: NIFI-3309 ensures that CS are deleted when a process group is deleted

Repository: nifi
Updated Branches:
  refs/heads/master c8f437e83 -> 2fbeabb95


NIFI-3309 ensures that CS are deleted when a process group is deleted

This closes #1411.

Signed-off-by: Bryan Bende <bb...@apache.org>


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

Branch: refs/heads/master
Commit: 2fbeabb95f3976637cc78bd818c65ce59fb253f3
Parents: c8f437e
Author: Pierre Villard <pi...@gmail.com>
Authored: Wed Jan 11 22:43:08 2017 +0100
Committer: Bryan Bende <bb...@apache.org>
Committed: Thu Jan 12 11:21:46 2017 -0500

----------------------------------------------------------------------
 .../service/StandardControllerServiceNode.java      |  2 +-
 .../apache/nifi/groups/StandardProcessGroup.java    |  8 ++++++++
 .../apache/nifi/controller/TestFlowController.java  | 16 +++++++++++++---
 3 files changed, 22 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi/blob/2fbeabb9/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/service/StandardControllerServiceNode.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/service/StandardControllerServiceNode.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/service/StandardControllerServiceNode.java
index 2c5b096..0a64253 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/service/StandardControllerServiceNode.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/service/StandardControllerServiceNode.java
@@ -211,7 +211,7 @@ public class StandardControllerServiceNode extends AbstractConfiguredComponent i
     @Override
     public void verifyCanDelete() {
         if (getState() != ControllerServiceState.DISABLED) {
-            throw new IllegalStateException(implementation.getIdentifier() + " cannot be deleted because it is not disabled");
+            throw new IllegalStateException("Controller Service " + implementation.getIdentifier() + " cannot be deleted because it is not disabled");
         }
     }
 

http://git-wip-us.apache.org/repos/asf/nifi/blob/2fbeabb9/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java
index 49cbd94..3400b00 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java
@@ -619,6 +619,10 @@ public final class StandardProcessGroup implements ProcessGroup {
             group.removeLabel(label);
         }
 
+        for (final ControllerServiceNode cs : group.getControllerServices(false)) {
+            group.removeControllerService(cs);
+        }
+
         for (final ProcessGroup childGroup : new ArrayList<>(group.getProcessGroups())) {
             group.removeProcessGroup(childGroup);
         }
@@ -2324,6 +2328,10 @@ public final class StandardProcessGroup implements ProcessGroup {
                 connection.verifyCanDelete();
             }
 
+            for(final ControllerServiceNode cs : controllerServices.values()) {
+                cs.verifyCanDelete();
+            }
+
             for (final ProcessGroup childGroup : processGroups.values()) {
                 // For nested child groups we can ignore the input/output port
                 // connections as they will be being deleted anyway.

http://git-wip-us.apache.org/repos/asf/nifi/blob/2fbeabb9/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/TestFlowController.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/TestFlowController.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/TestFlowController.java
index 32f8135..85d3491 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/TestFlowController.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/TestFlowController.java
@@ -31,6 +31,7 @@ import java.util.HashMap;
 import java.util.LinkedHashSet;
 import java.util.Map;
 import java.util.Set;
+
 import org.apache.commons.io.IOUtils;
 import org.apache.nifi.admin.service.AuditService;
 import org.apache.nifi.authorization.AbstractPolicyBasedAuthorizer;
@@ -46,6 +47,7 @@ import org.apache.nifi.controller.reporting.ReportingTaskInstantiationException;
 import org.apache.nifi.controller.repository.FlowFileEventRepository;
 import org.apache.nifi.controller.service.ControllerServiceNode;
 import org.apache.nifi.encrypt.StringEncryptor;
+import org.apache.nifi.groups.ProcessGroup;
 import org.apache.nifi.logging.LogLevel;
 import org.apache.nifi.processor.Relationship;
 import org.apache.nifi.provenance.MockProvenanceRepository;
@@ -353,8 +355,16 @@ public class TestFlowController {
         assertEquals("0 sec",p_settings.getSchedulingPeriod());
     }
 
-
-
-
+    @Test
+    public void testDeleteProcessGroup() {
+        ProcessGroup pg = controller.createProcessGroup("my-process-group");
+        pg.setName("my-process-group");
+        ControllerServiceNode cs = controller.createControllerService("org.apache.nifi.NonExistingControllerService", "my-controller-service", false);
+        pg.addControllerService(cs);
+        controller.getRootGroup().addProcessGroup(pg);
+        controller.getRootGroup().removeProcessGroup(pg);
+        pg.getControllerServices(true);
+        assertTrue(pg.getControllerServices(true).isEmpty());
+    }
 
 }