Java Code Examples for org.apache.nifi.web.api.dto.PortDTO#getConcurrentlySchedulableTaskCount()

The following examples show how to use org.apache.nifi.web.api.dto.PortDTO#getConcurrentlySchedulableTaskCount() . 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: AbstractPortDAO.java    From nifi with Apache License 2.0 6 votes vote down vote up
private List<String> validateProposedConfiguration(final Port port, final PortDTO portDTO) {
    List<String> validationErrors = new ArrayList<>();

    if (isNotNull(portDTO.getName()) && portDTO.getName().trim().isEmpty()) {
        validationErrors.add("The name of the port must be specified.");
    }
    if (isNotNull(portDTO.getConcurrentlySchedulableTaskCount()) && portDTO.getConcurrentlySchedulableTaskCount() <= 0) {
        validationErrors.add("Concurrent tasks must be a positive integer.");
    }

    // Although StandardProcessGroup.addIn/OutputPort has the similar validation,
    // this validation is necessary to prevent a port becomes public with an existing port name.
    if (port instanceof PublicPort) {
        final String portName = isNotNull(portDTO.getName()) ? portDTO.getName() : port.getName();
        // If there is any port with the same name, but different identifier, throw an error.
        if (getPublicPorts().stream()
            .anyMatch(p -> portName.equals(p.getName()) && !port.getIdentifier().equals(p.getIdentifier()))) {
            throw new IllegalStateException("Public port name must be unique throughout the flow.");
        }
    }

    return validationErrors;
}
 
Example 2
Source File: StandardInputPortDAO.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
private List<String> validateProposedConfiguration(PortDTO portDTO) {
    List<String> validationErrors = new ArrayList<>();

    if (isNotNull(portDTO.getName()) && portDTO.getName().trim().isEmpty()) {
        validationErrors.add("Port name cannot be blank.");
    }
    if (isNotNull(portDTO.getConcurrentlySchedulableTaskCount()) && portDTO.getConcurrentlySchedulableTaskCount() <= 0) {
        validationErrors.add("Concurrent tasks must be a positive integer.");
    }

    return validationErrors;
}
 
Example 3
Source File: StandardOutputPortDAO.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
private List<String> validateProposedConfiguration(PortDTO portDTO) {
    List<String> validationErrors = new ArrayList<>();

    if (isNotNull(portDTO.getName()) && portDTO.getName().trim().isEmpty()) {
        validationErrors.add("Port name cannot be blank.");
    }
    if (isNotNull(portDTO.getConcurrentlySchedulableTaskCount()) && portDTO.getConcurrentlySchedulableTaskCount() <= 0) {
        validationErrors.add("Concurrent tasks must be a positive integer.");
    }

    return validationErrors;
}
 
Example 4
Source File: StandardInputPortDAO.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
@Override
public Port updatePort(PortDTO portDTO) {
    Port inputPort = locatePort(portDTO.getId());

    // ensure we can do this update
    verifyUpdate(inputPort, portDTO);

    // handle state transition
    if (isNotNull(portDTO.getState())) {
        final ScheduledState purposedScheduledState = ScheduledState.valueOf(portDTO.getState());

        // only attempt an action if it is changing
        if (!purposedScheduledState.equals(inputPort.getScheduledState())) {
            try {
                // perform the appropriate action
                switch (purposedScheduledState) {
                    case RUNNING:
                        inputPort.getProcessGroup().startInputPort(inputPort);
                        break;
                    case STOPPED:
                        switch (inputPort.getScheduledState()) {
                            case RUNNING:
                                inputPort.getProcessGroup().stopInputPort(inputPort);
                                break;
                            case DISABLED:
                                inputPort.getProcessGroup().enableInputPort(inputPort);
                                break;
                        }
                        break;
                    case DISABLED:
                        inputPort.getProcessGroup().disableInputPort(inputPort);
                        break;
                }
            } catch (IllegalStateException ise) {
                throw new NiFiCoreException(ise.getMessage(), ise);
            }
        }
    }

    if (inputPort instanceof RootGroupPort) {
        final RootGroupPort rootPort = (RootGroupPort) inputPort;
        if (isNotNull(portDTO.getGroupAccessControl())) {
            rootPort.setGroupAccessControl(portDTO.getGroupAccessControl());
        }
        if (isNotNull(portDTO.getUserAccessControl())) {
            rootPort.setUserAccessControl(portDTO.getUserAccessControl());
        }
    }

    // update the port
    final String name = portDTO.getName();
    final String comments = portDTO.getComments();
    final Integer concurrentTasks = portDTO.getConcurrentlySchedulableTaskCount();
    if (isNotNull(portDTO.getPosition())) {
        inputPort.setPosition(new Position(portDTO.getPosition().getX(), portDTO.getPosition().getY()));
    }
    if (isNotNull(name)) {
        inputPort.setName(name);
    }
    if (isNotNull(comments)) {
        inputPort.setComments(comments);
    }
    if (isNotNull(concurrentTasks)) {
        inputPort.setMaxConcurrentTasks(concurrentTasks);
    }

    return inputPort;
}
 
Example 5
Source File: StandardOutputPortDAO.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
@Override
public Port updatePort(PortDTO portDTO) {
    Port outputPort = locatePort(portDTO.getId());

    // ensure we can do this update
    verifyUpdate(outputPort, portDTO);

    // handle state transition
    if (portDTO.getState() != null) {
        final ScheduledState purposedScheduledState = ScheduledState.valueOf(portDTO.getState());

        // only attempt an action if it is changing
        if (!purposedScheduledState.equals(outputPort.getScheduledState())) {
            try {
                // perform the appropriate action
                switch (purposedScheduledState) {
                    case RUNNING:
                        outputPort.getProcessGroup().startOutputPort(outputPort);
                        break;
                    case STOPPED:
                        switch (outputPort.getScheduledState()) {
                            case RUNNING:
                                outputPort.getProcessGroup().stopOutputPort(outputPort);
                                break;
                            case DISABLED:
                                outputPort.getProcessGroup().enableOutputPort(outputPort);
                                break;
                        }
                        break;
                    case DISABLED:
                        outputPort.getProcessGroup().disableOutputPort(outputPort);
                        break;
                }
            } catch (IllegalStateException ise) {
                throw new NiFiCoreException(ise.getMessage(), ise);
            }
        }
    }

    if (outputPort instanceof RootGroupPort) {
        final RootGroupPort rootPort = (RootGroupPort) outputPort;
        if (isNotNull(portDTO.getGroupAccessControl())) {
            rootPort.setGroupAccessControl(portDTO.getGroupAccessControl());
        }
        if (isNotNull(portDTO.getUserAccessControl())) {
            rootPort.setUserAccessControl(portDTO.getUserAccessControl());
        }
    }

    // perform the configuration
    final String name = portDTO.getName();
    final String comments = portDTO.getComments();
    final Integer concurrentTasks = portDTO.getConcurrentlySchedulableTaskCount();
    if (isNotNull(portDTO.getPosition())) {
        outputPort.setPosition(new Position(portDTO.getPosition().getX(), portDTO.getPosition().getY()));
    }
    if (isNotNull(name)) {
        outputPort.setName(name);
    }
    if (isNotNull(comments)) {
        outputPort.setComments(comments);
    }
    if (isNotNull(concurrentTasks)) {
        outputPort.setMaxConcurrentTasks(concurrentTasks);
    }

    return outputPort;
}
 
Example 6
Source File: AbstractPortDAO.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Override
public Port updatePort(PortDTO portDTO) {
    final Port port = locatePort(portDTO.getId());
    final ProcessGroup processGroup = port.getProcessGroup();

    // ensure we can do this update
    verifyUpdate(port, portDTO);

    // handle state transition
    if (isNotNull(portDTO.getState())) {
        final ScheduledState proposedScheduledState = ScheduledState.valueOf(portDTO.getState());

        // only attempt an action if it is changing
        if (!proposedScheduledState.equals(port.getScheduledState())) {
            try {
                handleStateTransition(port, proposedScheduledState);
            } catch (IllegalStateException ise) {
                throw new NiFiCoreException(ise.getMessage(), ise);
            }
        }
    }

    if (port instanceof PublicPort) {
        final PublicPort publicPort = (PublicPort) port;
        if (isNotNull(portDTO.getGroupAccessControl())) {
            publicPort.setGroupAccessControl(portDTO.getGroupAccessControl());
        }
        if (isNotNull(portDTO.getUserAccessControl())) {
            publicPort.setUserAccessControl(portDTO.getUserAccessControl());
        }
    }

    // update the port
    final String name = portDTO.getName();
    final String comments = portDTO.getComments();
    final Integer concurrentTasks = portDTO.getConcurrentlySchedulableTaskCount();
    if (isNotNull(portDTO.getPosition())) {
        port.setPosition(new Position(portDTO.getPosition().getX(), portDTO.getPosition().getY()));
    }
    if (isNotNull(name)) {
        port.setName(name);
    }
    if (isNotNull(comments)) {
        port.setComments(comments);
    }
    if (isNotNull(concurrentTasks)) {
        port.setMaxConcurrentTasks(concurrentTasks);
    }

    processGroup.onComponentModified();
    return port;
}
 
Example 7
Source File: StandardFlowSynchronizer.java    From nifi with Apache License 2.0 4 votes vote down vote up
private void addInputPorts(final Element processGroupElement, final ProcessGroup processGroup, final FlowController flowController) {
    final FlowManager flowManager = flowController.getFlowManager();
    final List<Element> inputPortNodeList = getChildrenByTagName(processGroupElement, "inputPort");
    for (final Element inputPortElement : inputPortNodeList) {
        final PortDTO portDTO = FlowFromDOMFactory.getPort(inputPortElement);

        final Port port;
        if (processGroup.isRootGroup() || Boolean.TRUE.equals(portDTO.getAllowRemoteAccess())) {
            port = flowManager.createPublicInputPort(portDTO.getId(), portDTO.getName());
        } else {
            port = flowManager.createLocalInputPort(portDTO.getId(), portDTO.getName());
        }

        port.setVersionedComponentId(portDTO.getVersionedComponentId());
        port.setPosition(toPosition(portDTO.getPosition()));
        port.setComments(portDTO.getComments());
        port.setProcessGroup(processGroup);

        final Set<String> userControls = portDTO.getUserAccessControl();
        if (userControls != null && !userControls.isEmpty()) {
            if (!(port instanceof PublicPort)) {
                throw new IllegalStateException("Attempting to add User Access Controls to " + port.getIdentifier() + ", but it is not a RootGroupPort");
            }
            ((PublicPort) port).setUserAccessControl(userControls);
        }
        final Set<String> groupControls = portDTO.getGroupAccessControl();
        if (groupControls != null && !groupControls.isEmpty()) {
            if (!(port instanceof PublicPort)) {
                throw new IllegalStateException("Attempting to add Group Access Controls to " + port.getIdentifier() + ", but it is not a RootGroupPort");
            }
            ((PublicPort) port).setGroupAccessControl(groupControls);
        }

        processGroup.addInputPort(port);
        if (portDTO.getConcurrentlySchedulableTaskCount() != null) {
            port.setMaxConcurrentTasks(portDTO.getConcurrentlySchedulableTaskCount());
        }

        final ScheduledState scheduledState = ScheduledState.valueOf(portDTO.getState());
        if (ScheduledState.RUNNING.equals(scheduledState)) {
            flowController.startConnectable(port);
        } else if (ScheduledState.DISABLED.equals(scheduledState)) {
            processGroup.disableInputPort(port);
        }
    }
}
 
Example 8
Source File: StandardFlowSynchronizer.java    From nifi with Apache License 2.0 4 votes vote down vote up
private void addOutputPorts(final Element processGroupElement, final ProcessGroup processGroup, final FlowController flowController) {
    final FlowManager flowManager = flowController.getFlowManager();
    final List<Element> outputPortNodeList = getChildrenByTagName(processGroupElement, "outputPort");
    for (final Element outputPortElement : outputPortNodeList) {
        final PortDTO portDTO = FlowFromDOMFactory.getPort(outputPortElement);

        final Port port;
        if (processGroup.isRootGroup() || Boolean.TRUE.equals(portDTO.getAllowRemoteAccess())) {
            port = flowManager.createPublicOutputPort(portDTO.getId(), portDTO.getName());
        } else {
            port = flowManager.createLocalOutputPort(portDTO.getId(), portDTO.getName());
        }

        port.setVersionedComponentId(portDTO.getVersionedComponentId());
        port.setPosition(toPosition(portDTO.getPosition()));
        port.setComments(portDTO.getComments());
        port.setProcessGroup(processGroup);

        final Set<String> userControls = portDTO.getUserAccessControl();
        if (userControls != null && !userControls.isEmpty()) {
            if (!(port instanceof PublicPort)) {
                throw new IllegalStateException("Attempting to add User Access Controls to " + port.getIdentifier() + ", but it is not a RootGroupPort");
            }
            ((PublicPort) port).setUserAccessControl(userControls);
        }
        final Set<String> groupControls = portDTO.getGroupAccessControl();
        if (groupControls != null && !groupControls.isEmpty()) {
            if (!(port instanceof PublicPort)) {
                throw new IllegalStateException("Attempting to add Group Access Controls to " + port.getIdentifier() + ", but it is not a RootGroupPort");
            }
            ((PublicPort) port).setGroupAccessControl(groupControls);
        }

        processGroup.addOutputPort(port);
        if (portDTO.getConcurrentlySchedulableTaskCount() != null) {
            port.setMaxConcurrentTasks(portDTO.getConcurrentlySchedulableTaskCount());
        }

        final ScheduledState scheduledState = ScheduledState.valueOf(portDTO.getState());
        if (ScheduledState.RUNNING.equals(scheduledState)) {
            flowController.startConnectable(port);
        } else if (ScheduledState.DISABLED.equals(scheduledState)) {
            processGroup.disableOutputPort(port);
        }
    }
}