Search in sources :

Example 21 with Port

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

the class StandardInputPortDAO 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 InputPort 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.createRemoteInputPort(portDTO.getId(), portDTO.getName());
    } else {
        port = flowController.createLocalInputPort(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.addInputPort(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)

Example 22 with Port

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

the class StandardInputPortDAO method verifyDelete.

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

Example 23 with Port

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

the class StandardOutputPortDAO method deletePort.

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

Example 24 with Port

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

the class StandardOutputPortDAO method verifyUpdate.

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

Example 25 with Port

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

the class AbstractFlowFileServerProtocol method checkPortStatus.

protected void checkPortStatus(final Peer peer, String portId) throws HandshakeException {
    Port receivedPort = rootGroup.getInputPort(portId);
    if (receivedPort == null) {
        receivedPort = rootGroup.getOutputPort(portId);
    }
    if (receivedPort == null) {
        logger.debug("Responding with ResponseCode UNKNOWN_PORT for identifier {}", portId);
        throw new HandshakeException(ResponseCode.UNKNOWN_PORT, "Received unknown port identifier: " + portId);
    }
    if (!(receivedPort instanceof RootGroupPort)) {
        logger.debug("Responding with ResponseCode UNKNOWN_PORT for identifier {}", portId);
        throw new HandshakeException(ResponseCode.UNKNOWN_PORT, "Received port identifier " + portId + ", but this Port is not a RootGroupPort");
    }
    this.port = (RootGroupPort) receivedPort;
    final PortAuthorizationResult portAuthResult = this.port.checkUserAuthorization(peer.getCommunicationsSession().getUserDn());
    if (!portAuthResult.isAuthorized()) {
        logger.debug("Responding with ResponseCode UNAUTHORIZED: ", portAuthResult.getExplanation());
        throw new HandshakeException(ResponseCode.UNAUTHORIZED, portAuthResult.getExplanation());
    }
    if (!receivedPort.isValid()) {
        logger.debug("Responding with ResponseCode PORT_NOT_IN_VALID_STATE for {}", receivedPort);
        throw new HandshakeException(ResponseCode.PORT_NOT_IN_VALID_STATE, "Port is not valid");
    }
    if (!receivedPort.isRunning()) {
        logger.debug("Responding with ResponseCode PORT_NOT_IN_VALID_STATE for {}", receivedPort);
        throw new HandshakeException(ResponseCode.PORT_NOT_IN_VALID_STATE, "Port not running");
    }
    // we we will simply not service the request but the sender will timeout
    if (getVersionNegotiator().getVersion() > 1) {
        for (final Connection connection : port.getConnections()) {
            if (connection.getFlowFileQueue().isFull()) {
                logger.debug("Responding with ResponseCode PORTS_DESTINATION_FULL for {}", port);
                throw new HandshakeException(ResponseCode.PORTS_DESTINATION_FULL, "Received port identifier " + portId + ", but its destination is full");
            }
        }
    }
}
Also used : RootGroupPort(org.apache.nifi.remote.RootGroupPort) Port(org.apache.nifi.connectable.Port) RootGroupPort(org.apache.nifi.remote.RootGroupPort) Connection(org.apache.nifi.connectable.Connection) HandshakeException(org.apache.nifi.remote.exception.HandshakeException) PortAuthorizationResult(org.apache.nifi.remote.PortAuthorizationResult)

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