NIFI-13196: Added new isAutoTerminated(Relationship) method to ProcessContext, which simply delegates to Connectable.isAutoTerminated(Relationship)

This closes #8790

Signed-off-by: Joseph Witt <joewitt@apache.org>
This commit is contained in:
Mark Payne 2024-05-09 15:55:06 -04:00 committed by Joseph Witt
parent 196f6bb6b1
commit 62fbd8e8b1
No known key found for this signature in database
GPG Key ID: 9093BF854F811A1A
5 changed files with 36 additions and 9 deletions

View File

@ -108,6 +108,13 @@ public interface ProcessContext extends PropertyContext, ClusterContext {
*/
Set<Relationship> getAvailableRelationships();
/**
* Indicates whether or not the given relationship is configured to be auto-terminated
* @param relationship the relationship
* @return <code>true</code> if the given relationship is auto-terminated, <code>false</code> otherwise
*/
boolean isAutoTerminated(Relationship relationship);
/**
* @return true if the processor has one or more incoming connections,
* false otherwise

View File

@ -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();

View File

@ -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();

View File

@ -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;

View File

@ -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<Relationship> relationships) {
this.unavailableRelationships = Collections.unmodifiableSet(new HashSet<>(relationships));
}