Repository: nifi Updated Branches: refs/heads/master 0931c6b0d -> e8248353d
NIFI-882: When a ProcessGroup is removed from the graph, ensure that the removeXYZ method is called for each component in that Process Group so that resources are appropriately cleaned up Project: http://git-wip-us.apache.org/repos/asf/nifi/repo Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/d351f3ed Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/d351f3ed Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/d351f3ed Branch: refs/heads/master Commit: d351f3ed1b80e8bb1ec5a078bdde2d36dbc7f088 Parents: 1ddd736 Author: Mark Payne <[email protected]> Authored: Fri Aug 21 15:55:04 2015 -0400 Committer: Mark Payne <[email protected]> Committed: Fri Aug 21 15:55:04 2015 -0400 ---------------------------------------------------------------------- .../nifi/groups/StandardProcessGroup.java | 36 +++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/nifi/blob/d351f3ed/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 70701c0..93acfa4 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 @@ -558,14 +558,48 @@ public final class StandardProcessGroup implements ProcessGroup { } toRemove.verifyCanDelete(); + removeComponents(group); processGroups.remove(group.getIdentifier()); - LOG.info("{} removed from flow", group); } finally { writeLock.unlock(); } } + private void removeComponents(final ProcessGroup group) { + for (final Connection connection : new ArrayList<>(group.getConnections())) { + group.removeConnection(connection); + } + + for (final Port port : new ArrayList<>(group.getInputPorts())) { + group.removeInputPort(port); + } + + for (final Port port : new ArrayList<>(group.getOutputPorts())) { + group.removeOutputPort(port); + } + + for (final Funnel funnel : new ArrayList<>(group.getFunnels())) { + group.removeFunnel(funnel); + } + + for (final ProcessorNode processor : new ArrayList<>(group.getProcessors())) { + group.removeProcessor(processor); + } + + for (final RemoteProcessGroup rpg : new ArrayList<>(group.getRemoteProcessGroups())) { + group.removeRemoteProcessGroup(rpg); + } + + for (final Label label : new ArrayList<>(group.getLabels())) { + group.removeLabel(label); + } + + for (final ProcessGroup childGroup : new ArrayList<>(group.getProcessGroups())) { + group.removeProcessGroup(childGroup); + } + } + @Override public void addRemoteProcessGroup(final RemoteProcessGroup remoteGroup) { writeLock.lock();
