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;
}
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();
}
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);
}
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);
}
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");
}
}
}
}
Aggregations