Search in sources :

Example 66 with Port

use of org.apache.nifi.connectable.Port in project nifi by apache.

the class StandardInputPortDAO method verifyUpdate.

@Override
public void verifyUpdate(PortDTO portDTO) {
    final Port inputPort = locatePort(portDTO.getId());
    verifyUpdate(inputPort, portDTO);
}
Also used : Port(org.apache.nifi.connectable.Port) RootGroupPort(org.apache.nifi.remote.RootGroupPort)

Example 67 with Port

use of org.apache.nifi.connectable.Port in project nifi by apache.

the class StandardOutputPortDAO method locatePort.

private Port locatePort(final String portId) {
    final ProcessGroup rootGroup = flowController.getGroup(flowController.getRootGroupId());
    final Port port = rootGroup.findOutputPort(portId);
    if (port == null) {
        throw new ResourceNotFoundException(String.format("Unable to find port with id '%s'.", portId));
    } else {
        return port;
    }
}
Also used : Port(org.apache.nifi.connectable.Port) RootGroupPort(org.apache.nifi.remote.RootGroupPort) ProcessGroup(org.apache.nifi.groups.ProcessGroup) ResourceNotFoundException(org.apache.nifi.web.ResourceNotFoundException)

Example 68 with Port

use of org.apache.nifi.connectable.Port in project nifi by apache.

the class StandardOutputPortDAO method updatePort.

@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);
    }
    outputPort.getProcessGroup().onComponentModified();
    return outputPort;
}
Also used : NiFiCoreException(org.apache.nifi.web.NiFiCoreException) ScheduledState(org.apache.nifi.controller.ScheduledState) RootGroupPort(org.apache.nifi.remote.RootGroupPort) Position(org.apache.nifi.connectable.Position) Port(org.apache.nifi.connectable.Port) RootGroupPort(org.apache.nifi.remote.RootGroupPort)

Example 69 with Port

use of org.apache.nifi.connectable.Port in project nifi by apache.

the class StandardOutputPortDAO method verifyDelete.

@Override
public void verifyDelete(final String portId) {
    final Port outputPort = locatePort(portId);
    outputPort.verifyCanDelete();
}
Also used : Port(org.apache.nifi.connectable.Port) RootGroupPort(org.apache.nifi.remote.RootGroupPort)

Example 70 with Port

use of org.apache.nifi.connectable.Port in project nifi by apache.

the class StandardOutputPortDAO method createPort.

@Override
public Port createPort(String groupId, PortDTO portDTO) {
    if (isNotNull(portDTO.getParentGroupId()) && !flowController.areGroupsSame(groupId, portDTO.getParentGroupId())) {
        throw new IllegalArgumentException("Cannot specify a different Parent Group ID than the Group to which the OutputPort is being added.");
    }
    // ensure the name has been specified
    if (portDTO.getName() == null) {
        throw new IllegalArgumentException("Port name must be specified.");
    }
    // get the desired group
    ProcessGroup group = locateProcessGroup(flowController, groupId);
    // determine if this is the root group
    Port port;
    if (group.getParent() == null) {
        port = flowController.createRemoteOutputPort(portDTO.getId(), portDTO.getName());
    } else {
        port = flowController.createLocalOutputPort(portDTO.getId(), portDTO.getName());
    }
    // ensure we can perform the update before we add the processor to the flow
    verifyUpdate(port, portDTO);
    // configure
    if (portDTO.getPosition() != null) {
        port.setPosition(new Position(portDTO.getPosition().getX(), portDTO.getPosition().getY()));
    }
    port.setComments(portDTO.getComments());
    // add the port
    group.addOutputPort(port);
    return port;
}
Also used : Position(org.apache.nifi.connectable.Position) Port(org.apache.nifi.connectable.Port) RootGroupPort(org.apache.nifi.remote.RootGroupPort) ProcessGroup(org.apache.nifi.groups.ProcessGroup)

Aggregations

Port (org.apache.nifi.connectable.Port)71 RootGroupPort (org.apache.nifi.remote.RootGroupPort)63 RemoteGroupPort (org.apache.nifi.remote.RemoteGroupPort)46 ProcessGroup (org.apache.nifi.groups.ProcessGroup)34 RemoteProcessGroup (org.apache.nifi.groups.RemoteProcessGroup)30 Connection (org.apache.nifi.connectable.Connection)27 ProcessorNode (org.apache.nifi.controller.ProcessorNode)27 ArrayList (java.util.ArrayList)26 HashSet (java.util.HashSet)25 Funnel (org.apache.nifi.connectable.Funnel)25 VersionedProcessGroup (org.apache.nifi.registry.flow.VersionedProcessGroup)24 Label (org.apache.nifi.controller.label.Label)20 LinkedHashSet (java.util.LinkedHashSet)19 ControllerServiceNode (org.apache.nifi.controller.service.ControllerServiceNode)19 Connectable (org.apache.nifi.connectable.Connectable)18 VersionControlInformation (org.apache.nifi.registry.flow.VersionControlInformation)18 HashMap (java.util.HashMap)16 Map (java.util.Map)16 Snippet (org.apache.nifi.controller.Snippet)16 Collections (java.util.Collections)15