@Override public Authorizable getSourceAuthorizable() { final Connectable sourceConnectable = getSource(); final Authorizable sourceAuthorizable; // if the source is a remote group port, authorize according to the RPG if (sourceConnectable instanceof RemoteGroupPort) { sourceAuthorizable = ((RemoteGroupPort) sourceConnectable).getRemoteProcessGroup(); } else { sourceAuthorizable = sourceConnectable; } return sourceAuthorizable; }
@Override public void setRelationships(final Collection<Relationship> newRelationships) { final Collection<Relationship> currentRelationships = relationships.get(); if (currentRelationships.equals(newRelationships)) { return; } try { getSource().verifyCanUpdate(); } catch (final IllegalStateException ise) { throw new IllegalStateException("Cannot update the relationships for Connection", ise); } try { this.relationships.set(new ArrayList<>(newRelationships)); getSource().updateConnection(this); } catch (final RuntimeException e) { this.relationships.set(currentRelationships); throw e; } }
@Override public void setDestination(final Connectable newDestination) { final Connectable previousDestination = destination.get(); if (previousDestination.equals(newDestination)) { return; } if (previousDestination.isRunning() && !(previousDestination instanceof Funnel || previousDestination instanceof LocalPort)) { throw new IllegalStateException("Cannot change destination of Connection because the current destination is running"); } if (getFlowFileQueue().isUnacknowledgedFlowFile()) { throw new IllegalStateException("Cannot change destination of Connection because FlowFiles from this Connection are currently held by " + previousDestination); } if (newDestination instanceof Funnel && newDestination.equals(source)) { throw new IllegalStateException("Funnels do not support self-looping connections."); } try { previousDestination.removeConnection(this); this.destination.set(newDestination); getSource().updateConnection(this); newDestination.addConnection(this); scheduler.registerEvent(newDestination); } catch (final RuntimeException e) { this.destination.set(previousDestination); throw e; } }
@Override public String toString() { return "Connection[ID=" + getIdentifier() + ", Source ID=" + getSource().getIdentifier() + ", Dest ID=" + getDestination().getIdentifier() + "]"; }