org.apache.nifi.registry.flow.VersionedConnection Java Examples

The following examples show how to use org.apache.nifi.registry.flow.VersionedConnection. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StandardFlowComparator.java    From nifi-registry with Apache License 2.0 6 votes vote down vote up
private void compare(final VersionedConnection connectionA, final VersionedConnection connectionB, final Set<FlowDifference> differences) {
    if (compareComponents(connectionA, connectionB, differences)) {
        return;
    }

    addIfDifferent(differences, DifferenceType.BACKPRESSURE_DATA_SIZE_THRESHOLD_CHANGED, connectionA, connectionB, VersionedConnection::getBackPressureDataSizeThreshold);
    addIfDifferent(differences, DifferenceType.BACKPRESSURE_OBJECT_THRESHOLD_CHANGED, connectionA, connectionB, VersionedConnection::getBackPressureObjectThreshold);
    addIfDifferent(differences, DifferenceType.BENDPOINTS_CHANGED, connectionA, connectionB, VersionedConnection::getBends);
    addIfDifferent(differences, DifferenceType.DESTINATION_CHANGED, connectionA, connectionB, VersionedConnection::getDestination);
    addIfDifferent(differences, DifferenceType.FLOWFILE_EXPIRATION_CHANGED, connectionA, connectionB, VersionedConnection::getFlowFileExpiration);
    addIfDifferent(differences, DifferenceType.PRIORITIZERS_CHANGED, connectionA, connectionB, VersionedConnection::getPrioritizers);
    addIfDifferent(differences, DifferenceType.SELECTED_RELATIONSHIPS_CHANGED, connectionA, connectionB, VersionedConnection::getSelectedRelationships);
    addIfDifferent(differences, DifferenceType.SOURCE_CHANGED, connectionA, connectionB, c -> c.getSource().getId());

    addIfDifferent(differences, DifferenceType.LOAD_BALANCE_STRATEGY_CHANGED, connectionA, connectionB,
            conn -> conn.getLoadBalanceStrategy() == null ? DEFAULT_LOAD_BALANCE_STRATEGY : conn.getLoadBalanceStrategy());

    addIfDifferent(differences, DifferenceType.PARTITIONING_ATTRIBUTE_CHANGED, connectionA, connectionB,
            conn -> conn.getPartitioningAttribute() == null ? DEFAULT_PARTITIONING_ATTRIBUTE : conn.getPartitioningAttribute());

    addIfDifferent(differences, DifferenceType.LOAD_BALANCE_COMPRESSION_CHANGED, connectionA, connectionB,
        conn -> conn.getLoadBalanceCompression() == null ? DEFAULT_LOAD_BALANCE_COMPRESSION : conn.getLoadBalanceCompression());
}
 
Example #2
Source File: NiFiRegConnectionSchemaFunction.java    From nifi-minifi with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #3
Source File: FlowController.java    From nifi with Apache License 2.0 5 votes vote down vote up
private Set<VersionedConnection> findAllConnections(final VersionedProcessGroup group) {
    final Set<VersionedConnection> conns = new HashSet<>();
    for (final VersionedConnection connection : group.getConnections()) {
        conns.add(connection);
    }

    for (final VersionedProcessGroup childGroup : group.getProcessGroups()) {
        conns.addAll(findAllConnections(childGroup));
    }
    return conns;
}
 
Example #4
Source File: FlowDifferenceFilters.java    From nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Determines whether or not the given Process Group has a Connection whose source is the given Processor and that contains the given relationship
 *
 * @param processGroup the process group
 * @param processor the source processor
 * @param relationship the relationship
 *
 * @return <code>true</code> if such a connection exists, <code>false</code> otherwise.
 */
private static boolean hasConnection(final VersionedProcessGroup processGroup, final VersionedProcessor processor, final String relationship) {
    for (final VersionedConnection connection : processGroup.getConnections()) {
        if (connection.getSource().getId().equals(processor.getIdentifier()) && connection.getSelectedRelationships().contains(relationship)) {
            return true;
        }
    }

    return false;
}
 
Example #5
Source File: NiFiRegistryFlowMapper.java    From nifi with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #6
Source File: StatelessFlow.java    From nifi with Apache License 2.0 4 votes vote down vote up
private Set<VersionedConnection> findConnectionsRecursive(final VersionedProcessGroup group) {
    final Set<VersionedConnection> connections = new HashSet<>();
    findConnectionsRecursive(group, connections);
    return connections;
}
 
Example #7
Source File: StatelessFlow.java    From nifi with Apache License 2.0 4 votes vote down vote up
private void findConnectionsRecursive(final VersionedProcessGroup group, final Set<VersionedConnection> connections) {
    connections.addAll(group.getConnections());
    group.getProcessGroups().forEach(child -> findConnectionsRecursive(child, connections));
}