Java Code Examples for org.apache.nifi.web.api.dto.ConnectionDTO#getPrioritizers()

The following examples show how to use org.apache.nifi.web.api.dto.ConnectionDTO#getPrioritizers() . 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: RelationshipAuditor.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
/**
 * Extracts configured settings from the specified connection only if they have also been specified in the connectionDTO.
 *
 * @param connection connection
 * @param connectionDTO dto
 * @return properties
 */
private Map<String, String> extractConfiguredPropertyValues(Connection connection, ConnectionDTO connectionDTO) {
    Map<String, String> values = new HashMap<>();

    if (connectionDTO.getName() != null) {
        values.put(NAME, connection.getName());
    }
    if (connectionDTO.getFlowFileExpiration() != null) {
        values.put(FLOW_FILE_EXPIRATION, String.valueOf(connection.getFlowFileQueue().getFlowFileExpiration()));
    }
    if (connectionDTO.getBackPressureObjectThreshold() != null) {
        values.put(BACK_PRESSURE_OBJECT_THRESHOLD, String.valueOf(connection.getFlowFileQueue().getBackPressureObjectThreshold()));
    }
    if (connectionDTO.getBackPressureDataSizeThreshold() != null) {
        values.put(BACK_PRESSURE_DATA_SIZE_THRESHOLD, String.valueOf(connection.getFlowFileQueue().getBackPressureDataSizeThreshold()));
    }
    if (connectionDTO.getPrioritizers() != null) {
        List<String> prioritizers = new ArrayList<>();
        for (FlowFilePrioritizer prioritizer : connection.getFlowFileQueue().getPriorities()) {
            prioritizers.add(prioritizer.getClass().getCanonicalName());
        }
        values.put(PRIORITIZERS, StringUtils.join(prioritizers, ", "));
    }

    return values;
}
 
Example 2
Source File: RelationshipAuditor.java    From nifi with Apache License 2.0 6 votes vote down vote up
/**
 * Extracts configured settings from the specified connection only if they have also been specified in the connectionDTO.
 *
 * @param connection connection
 * @param connectionDTO dto
 * @return properties
 */
private Map<String, String> extractConfiguredPropertyValues(Connection connection, ConnectionDTO connectionDTO) {
    Map<String, String> values = new HashMap<>();

    if (connectionDTO.getName() != null) {
        values.put(NAME, connection.getName());
    }
    if (connectionDTO.getFlowFileExpiration() != null) {
        values.put(FLOW_FILE_EXPIRATION, String.valueOf(connection.getFlowFileQueue().getFlowFileExpiration()));
    }
    if (connectionDTO.getBackPressureObjectThreshold() != null) {
        values.put(BACK_PRESSURE_OBJECT_THRESHOLD, String.valueOf(connection.getFlowFileQueue().getBackPressureObjectThreshold()));
    }
    if (connectionDTO.getBackPressureDataSizeThreshold() != null) {
        values.put(BACK_PRESSURE_DATA_SIZE_THRESHOLD, String.valueOf(connection.getFlowFileQueue().getBackPressureDataSizeThreshold()));
    }
    if (connectionDTO.getPrioritizers() != null) {
        List<String> prioritizers = new ArrayList<>();
        for (FlowFilePrioritizer prioritizer : connection.getFlowFileQueue().getPriorities()) {
            prioritizers.add(prioritizer.getClass().getCanonicalName());
        }
        values.put(PRIORITIZERS, StringUtils.join(prioritizers, ", "));
    }

    return values;
}
 
Example 3
Source File: StandardConnectionDAO.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
/**
 * Configures the specified connection using the specified dto.
 */
private void configureConnection(Connection connection, ConnectionDTO connectionDTO) {
    // validate flow file comparators/prioritizers
    List<FlowFilePrioritizer> newPrioritizers = null;
    final List<String> prioritizers = connectionDTO.getPrioritizers();
    if (isNotNull(prioritizers)) {
        final List<String> newPrioritizersClasses = new ArrayList<>(prioritizers);
        newPrioritizers = new ArrayList<>();
        for (final String className : newPrioritizersClasses) {
            try {
                newPrioritizers.add(flowController.createPrioritizer(className));
            } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException e) {
                throw new IllegalArgumentException("Unable to set prioritizer " + className + ": " + e);
            }
        }
    }

    // update connection queue
    if (isNotNull(connectionDTO.getFlowFileExpiration())) {
        connection.getFlowFileQueue().setFlowFileExpiration(connectionDTO.getFlowFileExpiration());
    }
    if (isNotNull(connectionDTO.getBackPressureObjectThreshold())) {
        connection.getFlowFileQueue().setBackPressureObjectThreshold(connectionDTO.getBackPressureObjectThreshold());
    }
    if (isNotNull(connectionDTO.getBackPressureDataSizeThreshold())) {
        connection.getFlowFileQueue().setBackPressureDataSizeThreshold(connectionDTO.getBackPressureDataSizeThreshold());
    }
    if (isNotNull(newPrioritizers)) {
        connection.getFlowFileQueue().setPriorities(newPrioritizers);
    }

    // update the connection state
    if (isNotNull(connectionDTO.getBends())) {
        final List<Position> bendPoints = new ArrayList<>();
        for (final PositionDTO bend : connectionDTO.getBends()) {
            if (bend != null) {
                bendPoints.add(new Position(bend.getX(), bend.getY()));
            }
        }
        connection.setBendPoints(bendPoints);
    }
    if (isNotNull(connectionDTO.getName())) {
        connection.setName(connectionDTO.getName());
    }
    if (isNotNull(connectionDTO.getLabelIndex())) {
        connection.setLabelIndex(connectionDTO.getLabelIndex());
    }
    if (isNotNull(connectionDTO.getzIndex())) {
        connection.setZIndex(connectionDTO.getzIndex());
    }
}
 
Example 4
Source File: StandardConnectionDAO.java    From nifi with Apache License 2.0 4 votes vote down vote up
/**
 * Configures the specified connection using the specified dto.
 */
private void configureConnection(Connection connection, ConnectionDTO connectionDTO) {
    // validate flow file comparators/prioritizers
    List<FlowFilePrioritizer> newPrioritizers = null;
    final List<String> prioritizers = connectionDTO.getPrioritizers();
    if (isNotNull(prioritizers)) {
        final List<String> newPrioritizersClasses = new ArrayList<>(prioritizers);
        newPrioritizers = new ArrayList<>();
        for (final String className : newPrioritizersClasses) {
            try {
                newPrioritizers.add(flowController.getFlowManager().createPrioritizer(className));
            } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException e) {
                throw new IllegalArgumentException("Unable to set prioritizer " + className + ": " + e);
            }
        }
    }

    // update connection queue
    if (isNotNull(connectionDTO.getFlowFileExpiration())) {
        connection.getFlowFileQueue().setFlowFileExpiration(connectionDTO.getFlowFileExpiration());
    }
    if (isNotNull(connectionDTO.getBackPressureObjectThreshold())) {
        connection.getFlowFileQueue().setBackPressureObjectThreshold(connectionDTO.getBackPressureObjectThreshold());
    }
    if (isNotNull(connectionDTO.getBackPressureDataSizeThreshold())) {
        connection.getFlowFileQueue().setBackPressureDataSizeThreshold(connectionDTO.getBackPressureDataSizeThreshold());
    }
    if (isNotNull(newPrioritizers)) {
        connection.getFlowFileQueue().setPriorities(newPrioritizers);
    }

    final String loadBalanceStrategyName = connectionDTO.getLoadBalanceStrategy();
    final String loadBalancePartitionAttribute = connectionDTO.getLoadBalancePartitionAttribute();
    if (isNotNull(loadBalanceStrategyName)) {
        final LoadBalanceStrategy loadBalanceStrategy = LoadBalanceStrategy.valueOf(loadBalanceStrategyName);
        connection.getFlowFileQueue().setLoadBalanceStrategy(loadBalanceStrategy, loadBalancePartitionAttribute);
    }

    final String loadBalanceCompressionName = connectionDTO.getLoadBalanceCompression();
    if (isNotNull(loadBalanceCompressionName)) {
        connection.getFlowFileQueue().setLoadBalanceCompression(LoadBalanceCompression.valueOf(loadBalanceCompressionName));
    }

    // update the connection state
    if (isNotNull(connectionDTO.getBends())) {
        final List<Position> bendPoints = new ArrayList<>();
        for (final PositionDTO bend : connectionDTO.getBends()) {
            if (bend != null) {
                bendPoints.add(new Position(bend.getX(), bend.getY()));
            }
        }
        connection.setBendPoints(bendPoints);
    }
    if (isNotNull(connectionDTO.getName())) {
        connection.setName(connectionDTO.getName());
    }
    if (isNotNull(connectionDTO.getLabelIndex())) {
        connection.setLabelIndex(connectionDTO.getLabelIndex());
    }
    if (isNotNull(connectionDTO.getzIndex())) {
        connection.setZIndex(connectionDTO.getzIndex());
    }
}