@Override public Set<Relationship> getAvailableRelationships() { for (final Connection connection : connectable.getConnections()) { if (connection.getFlowFileQueue().isFull()) { return Collections.emptySet(); } } final Collection<Relationship> relationships = connectable.getRelationships(); if (relationships instanceof Set) { return (Set<Relationship>) relationships; } return new HashSet<>(connectable.getRelationships()); }
public Set<Relationship> getAvailableRelationships() { final Set<Relationship> set = new HashSet<>(); for (final Relationship relationship : getConnectable().getRelationships()) { final Collection<Connection> connections = getConnections(relationship); if (connections.isEmpty()) { set.add(relationship); } else { boolean available = true; for (final Connection connection : connections) { if (connection.getFlowFileQueue().isFull()) { available = false; } } if (available) { set.add(relationship); } } } return set; } }
public static boolean anyRelationshipAvailable(final Connectable connectable) { for (final Relationship relationship : connectable.getRelationships()) { final Collection<Connection> connections = connectable.getConnections(relationship); boolean available = true; for (final Connection connection : connections) { if (connection.getFlowFileQueue().isFull()) { available = false; break; } } if (available) { return true; } } return false; }
/** * Verify that removing this connection will not prevent this Port from * still being connected via each relationship * * @param connection to test for removal * @return true if can be removed */ private boolean canConnectionBeRemoved(final Connection connection) { final Connectable source = connection.getSource(); if (!source.isRunning()) { // we don't have to verify that this Connectable is still connected because it's okay to make // the source invalid since it is not running. return true; } for (final Relationship relationship : source.getRelationships()) { if (source.isAutoTerminated(relationship)) { continue; } final Set<Connection> connectionsForRelationship = source.getConnections(relationship); if (connectionsForRelationship == null || connectionsForRelationship.isEmpty()) { return false; } } return true; }
public boolean isAnyRelationshipAvailable() { for (final Relationship relationship : getConnectable().getRelationships()) { final Collection<Connection> connections = getConnections(relationship); boolean available = true; for (final Connection connection : connections) { if (connection.getFlowFileQueue().isFull()) { available = false; break; } } if (available) { return true; } } return false; }
int unavailable = 0; final Collection<Relationship> allRelationships = connectable.getRelationships(); final int numRelationships = allRelationships.size();
public int getAvailableRelationshipCount() { int count = 0; for (final Relationship relationship : connectable.getRelationships()) { final Collection<Connection> connections = connectable.getConnections(relationship); if (connections == null || connections.isEmpty()) { count++; } else { boolean available = true; for (final Connection connection : connections) { // consider self-loops available if (connection.getSource() == connection.getDestination()) { continue; } if (connection.getFlowFileQueue().isFull()) { available = false; break; } } if (available) { count++; } } } return count; }
public ConnectableTask(final SchedulingAgent schedulingAgent, final Connectable connectable, final FlowController flowController, final RepositoryContextFactory contextFactory, final LifecycleState scheduleState, final StringEncryptor encryptor) { this.schedulingAgent = schedulingAgent; this.connectable = connectable; this.scheduleState = scheduleState; this.numRelationships = connectable.getRelationships().size(); this.flowController = flowController; final StateManager stateManager = new TaskTerminationAwareStateManager(flowController.getStateManagerProvider().getStateManager(connectable.getIdentifier()), scheduleState::isTerminated); if (connectable instanceof ProcessorNode) { processContext = new StandardProcessContext((ProcessorNode) connectable, flowController.getControllerServiceProvider(), encryptor, stateManager, scheduleState::isTerminated); } else { processContext = new ConnectableProcessContext(connectable, encryptor, stateManager); } repositoryContext = contextFactory.newProcessContext(connectable, new AtomicLong(0L)); }
private int getAvailableRelationshipCount(final Connectable connectable) { int count = 0; for (final Relationship relationship : connectable.getRelationships()) { final Collection<Connection> connections = connectable.getConnections(relationship); if (connections == null || connections.isEmpty()) { if (connectable.isAutoTerminated(relationship)) { // If the relationship is auto-terminated, consider it available. count++; } } else { boolean available = true; for (final Connection connection : connections) { if (connection.getSource() == connection.getDestination()) { // don't count self-loops continue; } if (connection.getFlowFileQueue().isFull()) { available = false; } } if (available) { count++; } } } return count; } }
if (!connectable.getRelationships().isEmpty()) { availableRelationshipCount = getAvailableRelationshipCount(connectable);
for (final Relationship availableRelationship : connection.getSource().getRelationships()) { if (!Relationship.ANONYMOUS.equals(availableRelationship)) { if (dto.getAvailableRelationships() == null) {
/** * Verify that removing this connection will not prevent this Port from * still being connected via each relationship * * @param connection to test for removal * @return true if can be removed */ private boolean canConnectionBeRemoved(final Connection connection) { final Connectable source = connection.getSource(); if (!source.isRunning()) { // we don't have to verify that this Connectable is still connected because it's okay to make // the source invalid since it is not running. return true; } for (final Relationship relationship : source.getRelationships()) { if (source.isAutoTerminated(relationship)) { continue; } final Set<Connection> connectionsForRelationship = source.getConnections(relationship); if (connectionsForRelationship == null || connectionsForRelationship.isEmpty()) { return false; } } return true; }