Repository: nifi Updated Branches: refs/heads/master da234abd7 -> 73e168e95
NIFI-1003 A relationship can be auto-terminable. In this case the processor will auto-terminate the relationship and allow the user to run it even if he does not connect those relationships and does not terminate them. This closes #217 Signed-off-by: Aldrin Piri <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/nifi/repo Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/73e168e9 Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/73e168e9 Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/73e168e9 Branch: refs/heads/master Commit: 73e168e954ad8304bbd7f4a078031c106cf2e8e3 Parents: da234ab Author: Pasqualino Ferrentino <[email protected]> Authored: Thu Feb 11 01:10:24 2016 -0600 Committer: Aldrin Piri <[email protected]> Committed: Thu Mar 10 14:56:46 2016 -0500 ---------------------------------------------------------------------- .../org/apache/nifi/processor/Relationship.java | 18 ++++++++++++++++++ .../nifi/controller/StandardProcessorNode.java | 3 +++ 2 files changed, 21 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/nifi/blob/73e168e9/nifi-api/src/main/java/org/apache/nifi/processor/Relationship.java ---------------------------------------------------------------------- diff --git a/nifi-api/src/main/java/org/apache/nifi/processor/Relationship.java b/nifi-api/src/main/java/org/apache/nifi/processor/Relationship.java index 0fec1f6..148940c 100644 --- a/nifi-api/src/main/java/org/apache/nifi/processor/Relationship.java +++ b/nifi-api/src/main/java/org/apache/nifi/processor/Relationship.java @@ -41,9 +41,17 @@ public final class Relationship implements Comparable<Relationship> { */ private final int hashCode; + /** + * The flag which tells the controller to auto terminate this + * relationship, so that the processor can be run even if it does + * not have connections from this relationship + */ + private final boolean isAutoTerminate; + protected Relationship(final Builder builder) { this.name = builder.name == null ? null : builder.name.intern(); this.description = builder.description; + this.isAutoTerminate = builder.autoTerminate; this.hashCode = 301 + ( (name == null) ? 0 :this.name.hashCode() ); // compute only once, since it gets called a bunch and will never change } @@ -71,6 +79,7 @@ public final class Relationship implements Comparable<Relationship> { private String name = ""; private String description = ""; + private boolean autoTerminate = false; public Builder name(final String name) { if (null != name) { @@ -86,6 +95,11 @@ public final class Relationship implements Comparable<Relationship> { return this; } + public Builder autoTerminateDefault(boolean autoTerminate) { + this.autoTerminate = autoTerminate; + return this; + } + public Relationship build() { return new Relationship(this); } @@ -99,6 +113,10 @@ public final class Relationship implements Comparable<Relationship> { return this.description; } + public boolean isAutoTerminated() { + return this.isAutoTerminate; + } + @Override public boolean equals(final Object other) { if (other == null) { http://git-wip-us.apache.org/repos/asf/nifi/blob/73e168e9/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java index 2db506c..f57343e 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java @@ -304,6 +304,9 @@ public class StandardProcessorNode extends ProcessorNode implements Connectable @Override public boolean isAutoTerminated(final Relationship relationship) { + if (relationship.isAutoTerminated() && getConnections(relationship).isEmpty()) { + return true; + } final Set<Relationship> terminatable = undefinedRelationshipsToTerminate.get(); if (terminatable == null) { return false;
