@Override public void addConnection(final Connection connection) throws IllegalArgumentException { writeLock.lock(); try { if (!requireNonNull(connection).getSource().equals(this)) { if (connection.getDestination().equals(this)) { // don't add the connection twice. This may occur if we have a self-loop because we will be told // to add the connection once because we are the source and again because we are the destination. if (!incomingConnections.contains(connection)) { incomingConnections.add(connection); } return; } else { throw new IllegalArgumentException("Cannot add a connection to a LocalPort for which the LocalPort is neither the Source nor the Destination"); } } for (final Relationship relationship : connection.getRelationships()) { if (!relationship.equals(PORT_RELATIONSHIP)) { throw new IllegalArgumentException("No relationship with name " + relationship + " exists for Local Ports"); } } // don't add the connection twice. This may occur if we have a self-loop because we will be told // to add the connection once because we are the source and again because we are the destination. if (!outgoingConnections.contains(connection)) { outgoingConnections.add(connection); } } finally { writeLock.unlock(); } }
for (final Relationship relationship : connection.getRelationships()) { if (!relationship.equals(Relationship.ANONYMOUS)) { throw new IllegalArgumentException("No relationship with name " + relationship + " exists for Funnels");
/** * Audits the creation of relationships via createConnection(). * * This method only needs to be run 'after returning'. However, in Java 7 the order in which these methods are returned from Class.getDeclaredMethods (even though there is no order guaranteed) * seems to differ from Java 6. SpringAOP depends on this ordering to determine advice precedence. By normalizing all advice into Around advice we can alleviate this issue. * * @param proceedingJoinPoint join point * @return connection * @throws java.lang.Throwable ex */ @Around("within(org.apache.nifi.web.dao.ConnectionDAO+) && " + "execution(org.apache.nifi.connectable.Connection createConnection(java.lang.String, org.apache.nifi.web.api.dto.ConnectionDTO))") public Connection createConnectionAdvice(ProceedingJoinPoint proceedingJoinPoint) throws Throwable { // perform the underlying operation Connection connection = (Connection) proceedingJoinPoint.proceed(); // audit the connection creation final ConnectDetails connectDetails = createConnectDetails(connection, connection.getRelationships()); final Action action = generateAuditRecordForConnection(connection, Operation.Connect, connectDetails); // save the actions if (action != null) { saveAction(action, logger); } return connection; }
for (final Relationship relationship : connection.getRelationships()) { final Set<Connection> connectionsForRelationship = getConnections(relationship); if ((connectionsForRelationship == null || connectionsForRelationship.size() <= 1) && isRunning()) {
for (final Relationship relationship : connection.getRelationships()) { final Relationship rel = getRelationship(relationship.getName()); Set<Connection> set = connections.get(rel); autoTerminated.removeAll(connection.getRelationships()); this.undefinedRelationshipsToTerminate.set(autoTerminated);
for (final Relationship rel : connection.getRelationships()) { if (!existingRelationships.contains(rel)) { for (final Relationship rel : connection.getRelationships()) { Set<Connection> set = connections.get(rel); if (set == null) { autoTerminated.removeAll(connection.getRelationships()); this.undefinedRelationshipsToTerminate.set(autoTerminated);
/** * Audits the removal of relationships via deleteConnection(). * * @param proceedingJoinPoint join point * @param id id * @param connectionDAO dao * @throws Throwable ex */ @Around("within(org.apache.nifi.web.dao.ConnectionDAO+) && " + "execution(void deleteConnection(java.lang.String)) && " + "args(id) && " + "target(connectionDAO)") public void removeConnectionAdvice(ProceedingJoinPoint proceedingJoinPoint, String id, ConnectionDAO connectionDAO) throws Throwable { // get the connection before performing the update Connection connection = connectionDAO.getConnection(id); // perform the underlying operation proceedingJoinPoint.proceed(); // audit the connection creation final ConnectDetails connectDetails = createConnectDetails(connection, connection.getRelationships()); final Action action = generateAuditRecordForConnection(connection, Operation.Disconnect, connectDetails); // save the actions if (action != null) { saveAction(action, logger); } }
Collection<String> relationshipNames = new HashSet<>(connection.getRelationships().size()); for (final Relationship relationship : connection.getRelationships()) { relationshipNames.add(relationship.getName());
final ConnectDetails connectDetails = relationshipAuditor.createConnectDetails(connection, connection.getRelationships()); final Action action = relationshipAuditor.generateAuditRecordForConnection(connection, Operation.Disconnect, connectDetails); if (action != null) {
Collection<Relationship> previousRelationships = connection.getRelationships(); Map<String, String> values = extractConfiguredPropertyValues(connection, connectionDTO); final ConnectDetails connectDetails = createConnectDetails(connection, connection.getRelationships()); actions.add(generateAuditRecordForConnection(connection, Operation.Connect, connectDetails)); Collection<Relationship> newRelationships = connection.getRelationships();
/** * Creates action details for connect/disconnect actions. * * @param connection connection * @param source source * @param relationships relationships * @param destination destinations * @return details */ public ConnectDetails createConnectDetails(final Connection connection, final Connectable source, final Collection<Relationship> relationships, final Connectable destination) { final Component sourceType = determineConnectableType(source); final Component destiantionType = determineConnectableType(destination); // format the relationship names Collection<String> relationshipNames = new HashSet<>(connection.getRelationships().size()); for (final Relationship relationship : relationships) { relationshipNames.add(relationship.getName()); } final String formattedRelationships = relationshipNames.isEmpty() ? StringUtils.EMPTY : StringUtils.join(relationshipNames, ", "); // create the connect details final FlowChangeConnectDetails connectDetails = new FlowChangeConnectDetails(); connectDetails.setSourceId(source.getIdentifier()); connectDetails.setSourceName(source.getName()); connectDetails.setSourceType(sourceType); connectDetails.setRelationship(formattedRelationships); connectDetails.setDestinationId(destination.getIdentifier()); connectDetails.setDestinationName(destination.getName()); connectDetails.setDestinationType(destiantionType); return connectDetails; }
public VersionedConnection mapConnection(final Connection connection) { final FlowFileQueue queue = connection.getFlowFileQueue(); final VersionedConnection versionedConnection = new InstantiatedVersionedConnection(connection.getIdentifier(), connection.getProcessGroup().getIdentifier()); versionedConnection.setIdentifier(getId(connection.getVersionedComponentId(), connection.getIdentifier())); versionedConnection.setGroupIdentifier(getGroupId(connection.getProcessGroup().getIdentifier())); versionedConnection.setName(connection.getName()); versionedConnection.setBackPressureDataSizeThreshold(queue.getBackPressureDataSizeThreshold()); versionedConnection.setBackPressureObjectThreshold(queue.getBackPressureObjectThreshold()); versionedConnection.setFlowFileExpiration(queue.getFlowFileExpiration()); versionedConnection.setLabelIndex(connection.getLabelIndex()); versionedConnection.setPrioritizers(queue.getPriorities().stream().map(p -> p.getClass().getName()).collect(Collectors.toList())); versionedConnection.setSelectedRelationships(connection.getRelationships().stream().map(Relationship::getName).collect(Collectors.toSet())); versionedConnection.setzIndex(connection.getZIndex()); final FlowFileQueue flowFileQueue = connection.getFlowFileQueue(); versionedConnection.setLoadBalanceStrategy(flowFileQueue.getLoadBalanceStrategy().name()); versionedConnection.setPartitioningAttribute(flowFileQueue.getPartitioningAttribute()); versionedConnection.setLoadBalanceCompression(flowFileQueue.getLoadBalanceCompression().name()); versionedConnection.setBends(connection.getBendPoints().stream() .map(this::mapPosition) .collect(Collectors.toList())); versionedConnection.setSource(mapConnectable(connection.getSource())); versionedConnection.setDestination(mapConnectable(connection.getDestination())); return versionedConnection; }
for (final Relationship relationship : connection.getRelationships()) { addIfAppropriate(searchStr, relationship.getName(), "Relationship", matches); } else if (!connection.getRelationships().isEmpty()) { final List<String> relationships = new ArrayList<>(connection.getRelationships().size()); for (final Relationship relationship : connection.getRelationships()) { if (StringUtils.isNotBlank(relationship.getName())) { relationships.add(relationship.getName());
for (final Relationship selectedRelationship : connection.getRelationships()) { if (!Relationship.ANONYMOUS.equals(selectedRelationship)) { if (dto.getSelectedRelationships() == null) {
final Collection<Relationship> relationships = connection.getRelationships(); if (StringUtils.isBlank(name) && CollectionUtils.isNotEmpty(relationships)) { name = StringUtils.join(relationships.stream().map(Relationship::getName).collect(Collectors.toSet()), ", ");
addTextElement(element, "destinationType", destinationType.toString()); for (final Relationship relationship : connection.getRelationships()) { addTextElement(element, "relationship", relationship.getName());
if (StringUtils.isNotBlank(conn.getName())) { connStatus.setName(conn.getName()); } else if (conn.getRelationships() != null && !conn.getRelationships().isEmpty()) { final Collection<String> relationships = new ArrayList<>(conn.getRelationships().size()); for (final Relationship relationship : conn.getRelationships()) { relationships.add(relationship.getName());
@Override public void addConnection(final Connection connection) throws IllegalArgumentException { writeLock.lock(); try { if (!requireNonNull(connection).getSource().equals(this)) { if (connection.getDestination().equals(this)) { // don't add the connection twice. This may occur if we have a self-loop because we will be told // to add the connection once because we are the source and again because we are the destination. if (!incomingConnections.contains(connection)) { incomingConnections.add(connection); } return; } else { throw new IllegalArgumentException("Cannot add a connection to a LocalPort for which the LocalPort is neither the Source nor the Destination"); } } for (final Relationship relationship : connection.getRelationships()) { if (!relationship.equals(PORT_RELATIONSHIP)) { throw new IllegalArgumentException("No relationship with name " + relationship + " exists for Local Ports"); } } // don't add the connection twice. This may occur if we have a self-loop because we will be told // to add the connection once because we are the source and again because we are the destination. if (!outgoingConnections.contains(connection)) { outgoingConnections.add(connection); } } finally { writeLock.unlock(); } }
for (final Relationship relationship : connection.getRelationships()) { if (!relationship.equals(Relationship.ANONYMOUS)) { throw new IllegalArgumentException("No relationship with name " + relationship + " exists for Funnels");