/** * Scrubs connections prior to saving. This includes removing available relationships. * * @param connections conns */ private static void scrubConnections(final Set<ConnectionDTO> connections) { // go through each connection for (final ConnectionDTO connectionDTO : connections) { connectionDTO.setAvailableRelationships(null); scrubConnectable(connectionDTO.getSource()); scrubConnectable(connectionDTO.getDestination()); } }
final ConnectableDTO proposedDestination = connectionDTO.getDestination(); if (proposedDestination != null && ConnectableType.REMOTE_INPUT_PORT.name().equals(proposedDestination.getType())) {
if (requestConnection.getDestination() != null) { if (requestConnection.getDestination().getId() == null) { throw new IllegalArgumentException("When specifying a destination component, the destination id is required."); if (requestConnection.getDestination().getType() == null) { throw new IllegalArgumentException("When specifying a destination component, the type of the destination is required."); if (requestConnection.getDestination() != null && !currentDestination.getIdentifier().equals(requestConnection.getDestination().getId())) { try { final ConnectableType destinationConnectableType = ConnectableType.valueOf(requestConnection.getDestination().getType()); newDestinationAuthorizable = lookup.getRemoteProcessGroup(requestConnection.getDestination().getGroupId()); } else { newDestinationAuthorizable = lookup.getLocalConnectable(requestConnection.getDestination().getId()); } catch (final IllegalArgumentException e) { throw new IllegalArgumentException(String.format("Unrecognized destination type %s. Excepted values are [%s]", requestConnection.getDestination().getType(), StringUtils.join(ConnectableType.values(), ", ")));
final ConnectableDTO destinationDto = connectionDTO.getDestination(); if (destinationDto == null || destinationDto.getId() == null) { throw new IllegalArgumentException("Cannot create connection without specifying destination");
if (requestConnection.getDestination() == null || requestConnection.getDestination().getId() == null) { throw new IllegalArgumentException("The destination of the connection must be specified."); if (requestConnection.getDestination().getType() == null) { throw new IllegalArgumentException("The type of the destination of the connection must be specified."); destinationConnectableType = ConnectableType.valueOf(requestConnection.getDestination().getType()); } catch (final IllegalArgumentException e) { throw new IllegalArgumentException(String.format("Unrecognized destination type %s. Expected values are [%s]", requestConnection.getDestination().getType(), StringUtils.join(ConnectableType.values(), ", "))); destination = lookup.getRemoteProcessGroup(requestConnection.getDestination().getGroupId()); } else { destination = lookup.getLocalConnectable(requestConnection.getDestination().getId()); throw new ResourceNotFoundException("Cannot find destination component with ID [" + requestConnection.getDestination().getId() + "]");
cdto.setGroupId(id.toString()); cdto = connectionDTO.getDestination(); if (!cdto.getType().equals("REMOTE_INPUT_PORT") && !cdto.getType().equals("REMOTE_OUTPUT_PORT")) { id = new UUID(this.generateMsb(cdto.getId()), LSB);
final ConnectableDTO proposedDestination = connectionDTO.getDestination(); if (proposedDestination != null) { final Connectable currentDestination = connection.getDestination();
final ConnectableDTO destination = connection.getDestination();
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(); } }
public ConnectionEntity createConnectionEntity(final ConnectionDTO dto, final RevisionDTO revision, final PermissionsDTO permissions, final ConnectionStatusDTO status) { final ConnectionEntity entity = new ConnectionEntity(); entity.setRevision(revision); if (dto != null) { entity.setPermissions(permissions); entity.setStatus(status); entity.setId(dto.getId()); entity.setPosition(dto.getPosition()); entity.setBends(dto.getBends()); entity.setLabelIndex(dto.getLabelIndex()); entity.setzIndex(dto.getzIndex()); entity.setSourceId(dto.getSource().getId()); entity.setSourceGroupId(dto.getSource().getGroupId()); entity.setSourceType(dto.getSource().getType()); entity.setDestinationId(dto.getDestination().getId()); entity.setDestinationGroupId(dto.getDestination().getGroupId()); entity.setDestinationType(dto.getDestination().getType()); if (permissions != null && permissions.getCanRead()) { entity.setComponent(dto); } } return entity; }
final ConnectableDTO destinationConnectableDTO = connectionDTO.getDestination();
final ConnectableDTO destination = connectableMap.get(cp.getDestination().getGroupId() + "-" + cp.getDestination().getId());
final ConnectableDTO destinationDto = dto.getDestination(); if (ConnectableType.REMOTE_INPUT_PORT.name().equals(destinationDto.getType())) { final RemoteProcessGroup remoteGroup = processGroup.getRemoteProcessGroup(destinationDto.getGroupId()); final ProcessGroup destinationGroup = flowManager.getGroup(destinationDto.getGroupId()); if (destinationGroup == null) { throw new RuntimeException("Found Invalid ProcessGroup ID for Destination: " + dto.getDestination().getGroupId()); throw new RuntimeException("Found Invalid Connectable ID for Destination: " + dto.getDestination().getId());
public ConnectionDTO copy(final ConnectionDTO original) { final ConnectionDTO copy = new ConnectionDTO(); copy.setAvailableRelationships(copy(original.getAvailableRelationships())); copy.setDestination(original.getDestination()); copy.setPosition(original.getPosition()); copy.setId(original.getId()); copy.setName(original.getName()); copy.setParentGroupId(original.getParentGroupId()); copy.setSelectedRelationships(copy(original.getSelectedRelationships())); copy.setFlowFileExpiration(original.getFlowFileExpiration()); copy.setBackPressureObjectThreshold(original.getBackPressureObjectThreshold()); copy.setBackPressureDataSizeThreshold(original.getBackPressureDataSizeThreshold()); copy.setPrioritizers(copy(original.getPrioritizers())); copy.setSource(original.getSource()); copy.setzIndex(original.getzIndex()); copy.setLabelIndex(original.getLabelIndex()); copy.setBends(copy(original.getBends())); copy.setLoadBalancePartitionAttribute(original.getLoadBalancePartitionAttribute()); copy.setLoadBalanceStrategy(original.getLoadBalanceStrategy()); copy.setLoadBalanceCompression(original.getLoadBalanceCompression()); copy.setLoadBalanceStatus(original.getLoadBalanceStatus()); copy.setVersionedComponentId(original.getVersionedComponentId()); return copy; }
final ConnectableDTO destinationDTO = connectionDTO.getDestination(); final Connectable source; final Connectable destination;
@Override public ConnectionSchema apply(ConnectionDTO connectionDTO) { Map<String, Object> map = new HashMap<>(); map.put(ID_KEY, connectionDTO.getId()); map.put(NAME_KEY, connectionDTO.getName()); map.put(ConnectionSchema.SOURCE_ID_KEY, connectionDTO.getSource().getId()); Set<String> selectedRelationships = nullToEmpty(connectionDTO.getSelectedRelationships()); map.put(ConnectionSchema.SOURCE_RELATIONSHIP_NAMES_KEY, selectedRelationships.stream().sorted().collect(Collectors.toList())); map.put(ConnectionSchema.DESTINATION_ID_KEY, connectionDTO.getDestination().getId()); map.put(ConnectionSchema.MAX_WORK_QUEUE_SIZE_KEY, connectionDTO.getBackPressureObjectThreshold()); map.put(ConnectionSchema.MAX_WORK_QUEUE_DATA_SIZE_KEY, connectionDTO.getBackPressureDataSizeThreshold()); map.put(ConnectionSchema.FLOWFILE_EXPIRATION__KEY, connectionDTO.getFlowFileExpiration()); List<String> queuePrioritizers = nullToEmpty(connectionDTO.getPrioritizers()); if (queuePrioritizers.size() > 0) { map.put(ConnectionSchema.QUEUE_PRIORITIZER_CLASS_KEY, queuePrioritizers.get(0)); } ConnectionSchema connectionSchema = new ConnectionSchema(map); if (ConnectableType.FUNNEL.name().equals(connectionDTO.getSource().getType())) { connectionSchema.addValidationIssue("Connection " + connectionDTO.getName() + " has type " + ConnectableType.FUNNEL.name() + " which is not supported by MiNiFi"); } if (queuePrioritizers.size() > 1) { connectionSchema.addValidationIssue(ConnectionSchema.QUEUE_PRIORITIZER_CLASS_KEY, CONNECTIONS_KEY, " has more than one queue prioritizer"); } return connectionSchema; } }
@Override public ConnectionSchema apply(ConnectionDTO connectionDTO) { Map<String, Object> map = new HashMap<>(); map.put(ID_KEY, connectionDTO.getId()); map.put(NAME_KEY, connectionDTO.getName()); map.put(ConnectionSchema.SOURCE_ID_KEY, connectionDTO.getSource().getId()); Set<String> selectedRelationships = nullToEmpty(connectionDTO.getSelectedRelationships()); map.put(ConnectionSchema.SOURCE_RELATIONSHIP_NAMES_KEY, selectedRelationships.stream().sorted().collect(Collectors.toList())); map.put(ConnectionSchema.DESTINATION_ID_KEY, connectionDTO.getDestination().getId()); map.put(ConnectionSchema.MAX_WORK_QUEUE_SIZE_KEY, connectionDTO.getBackPressureObjectThreshold()); map.put(ConnectionSchema.MAX_WORK_QUEUE_DATA_SIZE_KEY, connectionDTO.getBackPressureDataSizeThreshold()); map.put(ConnectionSchema.FLOWFILE_EXPIRATION__KEY, connectionDTO.getFlowFileExpiration()); List<String> queuePrioritizers = nullToEmpty(connectionDTO.getPrioritizers()); if (queuePrioritizers.size() > 0) { map.put(ConnectionSchema.QUEUE_PRIORITIZER_CLASS_KEY, queuePrioritizers.get(0)); } ConnectionSchema connectionSchema = new ConnectionSchema(map); if (ConnectableType.FUNNEL.name().equals(connectionDTO.getSource().getType())) { connectionSchema.addValidationIssue("Connection " + connectionDTO.getName() + " has type " + ConnectableType.FUNNEL.name() + " which is not supported by MiNiFi"); } if (queuePrioritizers.size() > 1) { connectionSchema.addValidationIssue(ConnectionSchema.QUEUE_PRIORITIZER_CLASS_KEY, CONNECTIONS_KEY, " has more than one queue prioritizer"); } return connectionSchema; } }
setName(connectableNameMap, connection.getDestination(), rpgIdToTargetIdMap); .flatMap(connectionDTO -> Stream.of(connectionDTO.getSource(), connectionDTO.getDestination())) .filter(connectable -> connectable.getType().equals(ConnectableType.REMOTE_OUTPUT_PORT.toString()) || connectable.getType().equals(ConnectableType.REMOTE_INPUT_PORT.toString())) .forEach(connectable -> connectable.setId(Optional.ofNullable(rpgIdToTargetIdMap.get(connectable.getId())).orElse(connectable.getId()))); ConnectableDTO connectionDestination = connection.getDestination(); name.append(determineValueForConnectable(connectionDestination, rpgIdToTargetIdMap));
setName(connectableNameMap, connection.getDestination(), rpgIdToTargetIdMap); .flatMap(connectionDTO -> Stream.of(connectionDTO.getSource(), connectionDTO.getDestination())) .filter(connectable -> connectable.getType().equals(ConnectableType.REMOTE_OUTPUT_PORT.toString()) || connectable.getType().equals(ConnectableType.REMOTE_INPUT_PORT.toString())) .forEach(connectable -> connectable.setId(Optional.ofNullable(rpgIdToTargetIdMap.get(connectable.getId())).orElse(connectable.getId()))); ConnectableDTO connectionDestination = connection.getDestination(); name.append(determineValueForConnectable(connectionDestination, rpgIdToTargetIdMap));