Search in sources :

Example 21 with RootGroupPort

use of org.apache.nifi.remote.RootGroupPort 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)

Aggregations

RootGroupPort (org.apache.nifi.remote.RootGroupPort)21 Port (org.apache.nifi.connectable.Port)13 ProcessGroup (org.apache.nifi.groups.ProcessGroup)11 RemoteProcessGroup (org.apache.nifi.groups.RemoteProcessGroup)8 ArrayList (java.util.ArrayList)7 HashSet (java.util.HashSet)7 Connection (org.apache.nifi.connectable.Connection)7 RemoteGroupPort (org.apache.nifi.remote.RemoteGroupPort)7 PortAuthorizationResult (org.apache.nifi.remote.PortAuthorizationResult)6 NiFiUser (org.apache.nifi.authorization.user.NiFiUser)5 VersionedProcessGroup (org.apache.nifi.registry.flow.VersionedProcessGroup)5 Peer (org.apache.nifi.remote.Peer)5 Connectable (org.apache.nifi.connectable.Connectable)4 Funnel (org.apache.nifi.connectable.Funnel)4 Position (org.apache.nifi.connectable.Position)4 HttpServerCommunicationsSession (org.apache.nifi.remote.io.http.HttpServerCommunicationsSession)4 BundleCoordinate (org.apache.nifi.bundle.BundleCoordinate)3 ScheduledState (org.apache.nifi.controller.ScheduledState)3 Label (org.apache.nifi.controller.label.Label)3 ControllerServiceNode (org.apache.nifi.controller.service.ControllerServiceNode)3