@Override public ConnectionSchema convert() { Map<String, Object> map = new HashMap<>(); map.put(NAME_KEY, name); if (StringUtil.isNullOrEmpty(sourceRelationshipName)) { map.put(SOURCE_RELATIONSHIP_NAMES_KEY, new ArrayList<>()); } else { map.put(SOURCE_RELATIONSHIP_NAMES_KEY, new ArrayList<>(Arrays.asList(sourceRelationshipName))); } map.put(MAX_WORK_QUEUE_SIZE_KEY, maxWorkQueueSize); map.put(MAX_WORK_QUEUE_DATA_SIZE_KEY, maxWorkQueueDataSize); map.put(FLOWFILE_EXPIRATION__KEY, flowfileExpiration); map.put(QUEUE_PRIORITIZER_CLASS_KEY, queuePrioritizerClass); return new ConnectionSchema(map); }
protected static void addConnection(final Element parentElement, ConnectionSchema connectionProperties, ParentGroupIdResolver parentGroupIdResolver) throws ConfigurationChangeException { try { final Document doc = parentElement.getOwnerDocument(); final Element element = doc.createElement("connection"); parentElement.appendChild(element); addTextElement(element, "id", connectionProperties.getId()); addTextElement(element, "name", connectionProperties.getName()); final Element bendPointsElement = doc.createElement("bendPoints"); element.appendChild(bendPointsElement); addTextElement(element, "labelIndex", "1"); addTextElement(element, "zIndex", "0"); addConnectionSourceOrDestination(element, "source", connectionProperties.getSourceId(), parentGroupIdResolver); addConnectionSourceOrDestination(element, "destination", connectionProperties.getDestinationId(), parentGroupIdResolver); List<String> sourceRelationshipNames = connectionProperties.getSourceRelationshipNames(); if (sourceRelationshipNames.isEmpty()) { addTextElement(element, "relationship", null); } else { for (String relationshipName : sourceRelationshipNames) { addTextElement(element, "relationship", relationshipName); } } addTextElement(element, "maxWorkQueueSize", String.valueOf(connectionProperties.getMaxWorkQueueSize())); addTextElement(element, "maxWorkQueueDataSize", connectionProperties.getMaxWorkQueueDataSize()); addTextElement(element, "flowFileExpiration", connectionProperties.getFlowfileExpiration()); addTextElementIfNotNullOrEmpty(element, "queuePrioritizerClass", connectionProperties.getQueuePrioritizerClass()); parentElement.appendChild(element); } catch (Exception e) { throw new ConfigurationChangeException("Failed to parse the config YAML while trying to add the connection from the Processor to the input port of the Remote Process Group", e); } }
@Override public List<String> getValidationIssues() { String wrapperName = getWrapperName(); List<String> validationIssues = super.getValidationIssues(); StringUtil.doIfNullOrEmpty(getSourceId(), id -> validationIssues.add(getIssueText(SOURCE_ID_KEY, wrapperName, IT_WAS_NOT_FOUND_AND_IT_IS_REQUIRED))); StringUtil.doIfNullOrEmpty(getDestinationId(), id -> validationIssues.add(getIssueText(DESTINATION_ID_KEY, wrapperName, IT_WAS_NOT_FOUND_AND_IT_IS_REQUIRED))); if (needsSourceRelationships && sourceRelationshipNames.isEmpty()) { validationIssues.add("Expected at least one value in " + SOURCE_RELATIONSHIP_NAMES_KEY + " for " + wrapperName + " " + getName()); } return Collections.unmodifiableList(validationIssues); } }
String destinationId = c.getDestinationId(); if (!StringUtil.isNullOrEmpty(destinationId) && !overlapResults.getElements().contains(destinationId)) { addValidationIssue(CONNECTION_WITH_ID + c.getId() + HAS_INVALID_DESTINATION_ID + destinationId); String sourceId = c.getSourceId(); if (!StringUtil.isNullOrEmpty(sourceId) && !overlapResults.getElements().contains(sourceId)) { addValidationIssue(CONNECTION_WITH_ID + c.getId() + HAS_INVALID_SOURCE_ID + sourceId);
@Override public ConnectionSchema apply(final VersionedConnection versionedConnection) { Map<String, Object> map = new HashMap<>(); map.put(ID_KEY, versionedConnection.getIdentifier()); map.put(NAME_KEY, versionedConnection.getName()); map.put(ConnectionSchema.SOURCE_ID_KEY, versionedConnection.getSource().getId()); Set<String> selectedRelationships = nullToEmpty(versionedConnection.getSelectedRelationships()); map.put(ConnectionSchema.SOURCE_RELATIONSHIP_NAMES_KEY, selectedRelationships.stream().sorted().collect(Collectors.toList())); map.put(ConnectionSchema.DESTINATION_ID_KEY, versionedConnection.getDestination().getId()); map.put(ConnectionSchema.MAX_WORK_QUEUE_SIZE_KEY, versionedConnection.getBackPressureObjectThreshold()); map.put(ConnectionSchema.MAX_WORK_QUEUE_DATA_SIZE_KEY, versionedConnection.getBackPressureDataSizeThreshold()); map.put(ConnectionSchema.FLOWFILE_EXPIRATION__KEY, versionedConnection.getFlowFileExpiration()); List<String> queuePrioritizers = nullToEmpty(versionedConnection.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(versionedConnection.getSource().getType())) { connectionSchema.addValidationIssue("Connection " + versionedConnection.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; } }
for (ConnectionSchemaV1 connection : connections) { ConnectionSchema convert = connection.convert(); convert.setId(getUniqueId(ids, convert.getName())); convert.setSourceId(sourceName); } else { if (duplicateProcessorNames.contains(sourceName)) { convert.setSourceId(sourceId); convert.setDestinationId(destinationName); } else { if (duplicateProcessorNames.contains(destinationName)) { convert.setDestinationId(destinationId);
public ProcessGroupSchemaV2(Map map, String wrapperName) { super(map, wrapperName); processors = getOptionalKeyAsList(map, PROCESSORS_KEY, ProcessorSchema::new, wrapperName); funnels = getOptionalKeyAsList(map, FUNNELS_KEY, FunnelSchema::new, wrapperName); remoteProcessGroups = getOptionalKeyAsList(map, REMOTE_PROCESS_GROUPS_KEY, RemoteProcessGroupSchemaV2::new, wrapperName); connections = getOptionalKeyAsList(map, CONNECTIONS_KEY, ConnectionSchema::new, wrapperName); inputPortSchemas = getOptionalKeyAsList(map, INPUT_PORTS_KEY, m -> new PortSchema(m, "InputPort(id: {id}, name: {name})"), wrapperName); outputPortSchemas = getOptionalKeyAsList(map, OUTPUT_PORTS_KEY, m -> new PortSchema(m, "OutputPort(id: {id}, name: {name})"), wrapperName); processGroupSchemas = getOptionalKeyAsList(map, PROCESS_GROUPS_KEY, m -> new ProcessGroupSchemaV2(m, "ProcessGroup(id: {id}, name: {name})"), wrapperName); if (ConfigSchema.TOP_LEVEL_NAME.equals(wrapperName)) { if (inputPortSchemas.size() > 0) { addValidationIssue(INPUT_PORTS_KEY, wrapperName, "must be empty in root group as external input/output ports are currently unsupported"); } if (outputPortSchemas.size() > 0) { addValidationIssue(OUTPUT_PORTS_KEY, wrapperName, "must be empty in root group as external input/output ports are currently unsupported"); } } else if (ID_DEFAULT.equals(getId())) { addValidationIssue(ID_KEY, wrapperName, "must be set to a value not " + ID_DEFAULT + " if not in root group"); } Set<String> portIds = getPortIds(); connections.stream().filter(c -> portIds.contains(c.getSourceId())).forEachOrdered(c -> c.setNeedsSourceRelationships(false)); Set<String> funnelIds = new HashSet<>(funnels.stream().map(FunnelSchema::getId).collect(Collectors.toList())); connections.stream().filter(c -> funnelIds.contains(c.getSourceId())).forEachOrdered(c -> c.setNeedsSourceRelationships(false)); addIssuesIfNotNull(processors); addIssuesIfNotNull(remoteProcessGroups); addIssuesIfNotNull(processGroupSchemas); addIssuesIfNotNull(funnels); addIssuesIfNotNull(connections); }
String destinationId = c.getDestinationId(); if (!StringUtil.isNullOrEmpty(destinationId) && !overlapResults.getElements().contains(destinationId)) { addValidationIssue(CONNECTION_WITH_ID + c.getId() + HAS_INVALID_DESTINATION_ID + destinationId); String sourceId = c.getSourceId(); if (!StringUtil.isNullOrEmpty(sourceId) && !overlapResults.getElements().contains(sourceId)) { addValidationIssue(CONNECTION_WITH_ID + c.getId() + HAS_INVALID_SOURCE_ID + sourceId);
@Override public ConnectionSchema apply(final VersionedConnection versionedConnection) { Map<String, Object> map = new HashMap<>(); map.put(ID_KEY, versionedConnection.getIdentifier()); map.put(NAME_KEY, versionedConnection.getName()); map.put(ConnectionSchema.SOURCE_ID_KEY, versionedConnection.getSource().getId()); Set<String> selectedRelationships = nullToEmpty(versionedConnection.getSelectedRelationships()); map.put(ConnectionSchema.SOURCE_RELATIONSHIP_NAMES_KEY, selectedRelationships.stream().sorted().collect(Collectors.toList())); map.put(ConnectionSchema.DESTINATION_ID_KEY, versionedConnection.getDestination().getId()); map.put(ConnectionSchema.MAX_WORK_QUEUE_SIZE_KEY, versionedConnection.getBackPressureObjectThreshold()); map.put(ConnectionSchema.MAX_WORK_QUEUE_DATA_SIZE_KEY, versionedConnection.getBackPressureDataSizeThreshold()); map.put(ConnectionSchema.FLOWFILE_EXPIRATION__KEY, versionedConnection.getFlowFileExpiration()); List<String> queuePrioritizers = nullToEmpty(versionedConnection.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(versionedConnection.getSource().getType())) { connectionSchema.addValidationIssue("Connection " + versionedConnection.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; } }
connections.stream().filter(c -> portIds.contains(c.getSourceId())).forEachOrdered(c -> c.setNeedsSourceRelationships(false)); connections.stream().filter(c -> funnelIds.contains(c.getSourceId())).forEachOrdered(c -> c.setNeedsSourceRelationships(false));
@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; } }