diff --git a/nifi-api/src/main/java/org/apache/nifi/processor/ProcessContext.java b/nifi-api/src/main/java/org/apache/nifi/processor/ProcessContext.java index b419e96367..448414a47b 100644 --- a/nifi-api/src/main/java/org/apache/nifi/processor/ProcessContext.java +++ b/nifi-api/src/main/java/org/apache/nifi/processor/ProcessContext.java @@ -108,6 +108,13 @@ public interface ProcessContext extends PropertyContext, ClusterContext { */ Set getAvailableRelationships(); + /** + * Indicates whether or not the given relationship is configured to be auto-terminated + * @param relationship the relationship + * @return true if the given relationship is auto-terminated, false otherwise + */ + boolean isAutoTerminated(Relationship relationship); + /** * @return true if the processor has one or more incoming connections, * false otherwise diff --git a/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/repository/scheduling/ConnectableProcessContext.java b/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/repository/scheduling/ConnectableProcessContext.java index 3d046411b5..b9e211b6f0 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/repository/scheduling/ConnectableProcessContext.java +++ b/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/repository/scheduling/ConnectableProcessContext.java @@ -16,15 +16,6 @@ */ package org.apache.nifi.controller.repository.scheduling; -import java.time.Duration; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.TimeUnit; - import org.apache.nifi.components.PropertyDescriptor; import org.apache.nifi.components.PropertyValue; import org.apache.nifi.components.resource.ResourceReference; @@ -43,6 +34,15 @@ import org.apache.nifi.processor.exception.ProcessException; import org.apache.nifi.scheduling.ExecutionNode; import org.apache.nifi.util.Connectables; +import java.time.Duration; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.TimeUnit; + /** * This class is essentially an empty shell for {@link Connectable}s that are not Processors */ @@ -250,6 +250,11 @@ public class ConnectableProcessContext implements ProcessContext { return new HashSet<>(connectable.getRelationships()); } + @Override + public boolean isAutoTerminated(final Relationship relationship) { + return connectable.isAutoTerminated(relationship); + } + @Override public boolean hasIncomingConnection() { return connectable.hasIncomingConnection(); diff --git a/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/processor/StandardProcessContext.java b/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/processor/StandardProcessContext.java index e3aa93bb8f..2164348f1d 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/processor/StandardProcessContext.java +++ b/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/processor/StandardProcessContext.java @@ -309,6 +309,11 @@ public class StandardProcessContext implements ProcessContext, ControllerService return set; } + @Override + public boolean isAutoTerminated(final Relationship relationship) { + return procNode.isAutoTerminated(relationship); + } + @Override public String getControllerServiceName(final String serviceIdentifier) { verifyTaskActive(); diff --git a/nifi-framework-bundle/nifi-framework/nifi-framework-nar-utils/src/main/java/org/apache/nifi/mock/MockProcessContext.java b/nifi-framework-bundle/nifi-framework/nifi-framework-nar-utils/src/main/java/org/apache/nifi/mock/MockProcessContext.java index c4b0978f56..d3a75d64ec 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-framework-nar-utils/src/main/java/org/apache/nifi/mock/MockProcessContext.java +++ b/nifi-framework-bundle/nifi-framework/nifi-framework-nar-utils/src/main/java/org/apache/nifi/mock/MockProcessContext.java @@ -85,6 +85,11 @@ public class MockProcessContext implements ProcessContext { return Collections.emptySet(); } + @Override + public boolean isAutoTerminated(final Relationship relationship) { + return false; + } + @Override public boolean hasIncomingConnection() { return true; diff --git a/nifi-mock/src/main/java/org/apache/nifi/util/MockProcessContext.java b/nifi-mock/src/main/java/org/apache/nifi/util/MockProcessContext.java index 2b96099093..cfd396a58b 100644 --- a/nifi-mock/src/main/java/org/apache/nifi/util/MockProcessContext.java +++ b/nifi-mock/src/main/java/org/apache/nifi/util/MockProcessContext.java @@ -444,6 +444,11 @@ public class MockProcessContext extends MockControllerServiceLookup implements P return relationships; } + @Override + public boolean isAutoTerminated(final Relationship relationship) { + return false; + } + public void setUnavailableRelationships(final Set relationships) { this.unavailableRelationships = Collections.unmodifiableSet(new HashSet<>(relationships)); }