mirror of https://github.com/apache/nifi.git
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 <aldrin@apache.org>
This commit is contained in:
parent
da234abd76
commit
73e168e954
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue