@Override public ProcessGroup getParentGroup() { return connection.getProcessGroup(); } }
@Override public void deleteConnection(final String id) { final Connection connection = locateConnection(id); connection.getProcessGroup().removeConnection(connection); }
@Override public Connection findConnection(final String id) { final Connection connection = flowManager.getConnection(id); if (connection == null) { return null; } // We found a Connection in the Controller, but we only want to return it if // the Process Group is this or is a child of this. if (isOwner(connection.getProcessGroup())) { return connection; } return null; }
/** * Gets the status for the specified connection. * * @param connectionId connection id * @return the status for the specified connection */ public ConnectionStatus getConnectionStatus(final String connectionId) { final ProcessGroup root = getRootGroup(); final Connection connection = root.findConnection(connectionId); // ensure the connection was found if (connection == null) { throw new ResourceNotFoundException(String.format("Unable to locate connection with id '%s'.", connectionId)); } // calculate the process group status final String groupId = connection.getProcessGroup().getIdentifier(); final ProcessGroupStatus processGroupStatus = flowController.getEventAccess().getGroupStatus(groupId, NiFiUserUtils.getNiFiUser(), 1); if (processGroupStatus == null) { throw new ResourceNotFoundException(String.format("Unable to locate group with id '%s'.", groupId)); } final ConnectionStatus status = processGroupStatus.getConnectionStatus().stream().filter(connectionStatus -> connectionId.equals(connectionStatus.getId())).findFirst().orElse(null); if (status == null) { throw new ResourceNotFoundException(String.format("Unable to locate connection with id '%s'.", connectionId)); } return status; }
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; }
.collect(Collectors.toList())); connection.setDestination(getConnectable(connection.getProcessGroup(), proposed.getDestination())); connection.setLabelIndex(proposed.getLabelIndex()); connection.setName(proposed.getName());
@Override public Connection updateConnection(final ConnectionDTO connectionDTO) { final Connection connection = locateConnection(connectionDTO.getId()); final ProcessGroup group = connection.getProcessGroup();
private void verifyUpdate(final Connection connection, final ConnectionDTO connectionDTO) { // determine what the request is attempting if (isAnyNotNull(connectionDTO.getBackPressureDataSizeThreshold(), connectionDTO.getBackPressureObjectThreshold(), connectionDTO.getDestination(), connectionDTO.getFlowFileExpiration(), connectionDTO.getName(), connectionDTO.getPosition(), connectionDTO.getPrioritizers(), connectionDTO.getSelectedRelationships())) { // validate the incoming request final List<String> validationErrors = validateProposedConfiguration(connection.getProcessGroup().getIdentifier(), connectionDTO); // ensure there was no validation errors if (!validationErrors.isEmpty()) { throw new ValidationException(validationErrors); } // If destination is changing, ensure that current destination is not running. This check is done here, rather than // in the Connection object itself because the Connection object itself does not know which updates are to occur and // we don't want to prevent updating things like the connection name or backpressure just because the destination is running final Connectable destination = connection.getDestination(); if (destination != null && destination.isRunning() && destination.getConnectableType() != ConnectableType.FUNNEL && destination.getConnectableType() != ConnectableType.INPUT_PORT) { throw new ValidationException(Collections.singletonList("Cannot change the destination of connection because the current destination is running")); } // verify that this connection supports modification connection.verifyCanUpdate(); } }
dto.setParentGroupId(connection.getProcessGroup().getIdentifier());
dto.setGroupId(connection.getProcessGroup().getIdentifier());
connStatus.setGroupId(conn.getProcessGroup().getIdentifier()); connStatus.setSourceId(conn.getSource().getIdentifier()); connStatus.setSourceName(isSourceAuthorized ? conn.getSource().getName() : conn.getSource().getIdentifier());