Java Code Examples for org.apache.nifi.groups.ProcessGroup#findOutputPort()

The following examples show how to use org.apache.nifi.groups.ProcessGroup#findOutputPort() . 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: ControllerFacade.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the status for the specified output port.
 *
 * @param portId output port id
 * @return the status for the specified output port
 */
public PortStatus getOutputPortStatus(final String portId) {
    final ProcessGroup root = flowController.getGroup(flowController.getRootGroupId());
    final Port port = root.findOutputPort(portId);

    // ensure the output port was found
    if (port == null) {
        throw new ResourceNotFoundException(String.format("Unable to locate output port with id '%s'.", portId));
    }

    final String groupId = port.getProcessGroup().getIdentifier();
    final ProcessGroupStatus processGroupStatus = flowController.getGroupStatus(groupId, NiFiUserUtils.getNiFiUser());
    if (processGroupStatus == null) {
        throw new ResourceNotFoundException(String.format("Unable to locate group with id '%s'.", groupId));
    }

    final PortStatus status = processGroupStatus.getOutputPortStatus().stream().filter(portStatus -> portId.equals(portStatus.getId())).findFirst().orElse(null);
    if (status == null) {
        throw new ResourceNotFoundException(String.format("Unable to locate output port with id '%s'.", portId));
    }

    return status;
}
 
Example 2
Source File: ControllerFacade.java    From nifi with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the status for the specified output port.
 *
 * @param portId output port id
 * @return the status for the specified output port
 */
public PortStatus getOutputPortStatus(final String portId) {
    final ProcessGroup root = getRootGroup();
    final Port port = root.findOutputPort(portId);

    // ensure the output port was found
    if (port == null) {
        throw new ResourceNotFoundException(String.format("Unable to locate output port with id '%s'.", portId));
    }

    final String groupId = port.getProcessGroup().getIdentifier();
    final ProcessGroupStatus processGroupStatus = flowController.getEventAccess().getGroupStatus(groupId, NiFiUserUtils.getNiFiUser(), 1);
    if (processGroupStatus == null) {
        throw new ResourceNotFoundException(String.format("Unable to locate group with id '%s'.", groupId));
    }

    final PortStatus status = processGroupStatus.getOutputPortStatus().stream().filter(portStatus -> portId.equals(portStatus.getId())).findFirst().orElse(null);
    if (status == null) {
        throw new ResourceNotFoundException(String.format("Unable to locate output port with id '%s'.", portId));
    }

    return status;
}
 
Example 3
Source File: StandardOutputPortDAO.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
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;
    }
}
 
Example 4
Source File: FlowController.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Verifies that no output port exists with the given id or name. If this
 * does not hold true, throws an IllegalStateException
 *
 * @param id port identifier
 * @throws IllegalStateException port already exists
 */
private void verifyPortIdDoesNotExist(final String id) {
    final ProcessGroup rootGroup = getRootGroup();
    Port port = rootGroup.findOutputPort(id);
    if (port != null) {
        throw new IllegalStateException("An Input Port already exists with ID " + id);
    }
    port = rootGroup.findInputPort(id);
    if (port != null) {
        throw new IllegalStateException("An Input Port already exists with ID " + id);
    }
}
 
Example 5
Source File: StandardInputPortDAO.java    From nifi with Apache License 2.0 5 votes vote down vote up
protected Port locatePort(final String portId) {
    final ProcessGroup rootGroup = flowController.getFlowManager().getRootGroup();
    Port port = rootGroup.findInputPort(portId);

    if (port == null) {
        port = rootGroup.findOutputPort(portId);
    }

    if (port == null) {
        throw new ResourceNotFoundException(String.format("Unable to find port with id '%s'.", portId));
    } else {
        return port;
    }
}
 
Example 6
Source File: StandardOutputPortDAO.java    From nifi with Apache License 2.0 5 votes vote down vote up
protected Port locatePort(final String portId) {
    final ProcessGroup rootGroup = flowController.getFlowManager().getRootGroup();
    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;
    }
}
 
Example 7
Source File: StandardFlowManager.java    From nifi with Apache License 2.0 5 votes vote down vote up
private void verifyPortIdDoesNotExist(final String id) {
    final ProcessGroup rootGroup = getRootGroup();
    Port port = rootGroup.findOutputPort(id);
    if (port != null) {
        throw new IllegalStateException("An Input Port already exists with ID " + id);
    }
    port = rootGroup.findInputPort(id);
    if (port != null) {
        throw new IllegalStateException("An Input Port already exists with ID " + id);
    }
}
 
Example 8
Source File: StandardOutputPortDAO.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
@Override
public boolean hasPort(String portId) {
    final ProcessGroup rootGroup = flowController.getGroup(flowController.getRootGroupId());
    return rootGroup.findOutputPort(portId) != null;
}
 
Example 9
Source File: StandardInputPortDAO.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Override
public boolean hasPort(String portId) {
    final ProcessGroup rootGroup = flowController.getFlowManager().getRootGroup();
    return rootGroup.findInputPort(portId) != null || rootGroup.findOutputPort(portId) != null;
}
 
Example 10
Source File: StandardOutputPortDAO.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Override
public boolean hasPort(String portId) {
    final ProcessGroup rootGroup = flowController.getFlowManager().getRootGroup();
    return rootGroup.findOutputPort(portId) != null;
}