Search in sources :

Example 1 with PortStatus

use of org.apache.nifi.controller.status.PortStatus in project nifi by apache.

the class ControllerFacade method getOutputPortStatus.

/**
 * 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;
}
Also used : ProcessGroupStatus(org.apache.nifi.controller.status.ProcessGroupStatus) RemoteProcessGroupStatus(org.apache.nifi.controller.status.RemoteProcessGroupStatus) RootGroupPort(org.apache.nifi.remote.RootGroupPort) Port(org.apache.nifi.connectable.Port) RemoteGroupPort(org.apache.nifi.remote.RemoteGroupPort) VersionedProcessGroup(org.apache.nifi.registry.flow.VersionedProcessGroup) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) ProcessGroup(org.apache.nifi.groups.ProcessGroup) PortStatus(org.apache.nifi.controller.status.PortStatus) ResourceNotFoundException(org.apache.nifi.web.ResourceNotFoundException)

Example 2 with PortStatus

use of org.apache.nifi.controller.status.PortStatus in project nifi by apache.

the class ControllerFacade method getInputPortStatus.

/**
 * Gets the status for the specified input port.
 *
 * @param portId input port id
 * @return the status for the specified input port
 */
public PortStatus getInputPortStatus(final String portId) {
    final ProcessGroup root = flowController.getGroup(flowController.getRootGroupId());
    final Port port = root.findInputPort(portId);
    // ensure the input port was found
    if (port == null) {
        throw new ResourceNotFoundException(String.format("Unable to locate input 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.getInputPortStatus().stream().filter(portStatus -> portId.equals(portStatus.getId())).findFirst().orElse(null);
    if (status == null) {
        throw new ResourceNotFoundException(String.format("Unable to locate input port with id '%s'.", portId));
    }
    return status;
}
Also used : ProcessGroupStatus(org.apache.nifi.controller.status.ProcessGroupStatus) RemoteProcessGroupStatus(org.apache.nifi.controller.status.RemoteProcessGroupStatus) RootGroupPort(org.apache.nifi.remote.RootGroupPort) Port(org.apache.nifi.connectable.Port) RemoteGroupPort(org.apache.nifi.remote.RemoteGroupPort) VersionedProcessGroup(org.apache.nifi.registry.flow.VersionedProcessGroup) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) ProcessGroup(org.apache.nifi.groups.ProcessGroup) PortStatus(org.apache.nifi.controller.status.PortStatus) ResourceNotFoundException(org.apache.nifi.web.ResourceNotFoundException)

Example 3 with PortStatus

use of org.apache.nifi.controller.status.PortStatus in project nifi by apache.

the class SiteToSiteStatusReportingTask method serializeProcessGroupStatus.

/**
 * Serialize the ProcessGroupStatus and add it to the JsonArrayBuilder.
 * @param arrayBuilder
 *            The JSON Array builder
 * @param factory
 *            The JSON Builder Factory
 * @param status
 *            The ProcessGroupStatus
 * @param df
 *            A date format
 * @param hostname
 *            The current hostname
 * @param applicationName
 *            The root process group name
 * @param platform
 *            The configured platform
 * @param parentId
 *            The parent's component id
 */
void serializeProcessGroupStatus(final JsonArrayBuilder arrayBuilder, final JsonBuilderFactory factory, final ProcessGroupStatus status, final DateFormat df, final String hostname, final String applicationName, final String platform, final String parentId, final Date currentDate) {
    final JsonObjectBuilder builder = factory.createObjectBuilder();
    final String componentType = (parentId == null) ? "RootProcessGroup" : "ProcessGroup";
    final String componentName = status.getName();
    if (componentMatchesFilters(componentType, componentName)) {
        addCommonFields(builder, df, hostname, applicationName, platform, parentId, currentDate, componentType, componentName);
        addField(builder, "componentId", status.getId());
        addField(builder, "bytesRead", status.getBytesRead());
        addField(builder, "bytesWritten", status.getBytesWritten());
        addField(builder, "bytesReceived", status.getBytesReceived());
        addField(builder, "bytesSent", status.getBytesSent());
        addField(builder, "bytesTransferred", status.getBytesTransferred());
        addField(builder, "flowFilesReceived", status.getFlowFilesReceived());
        addField(builder, "flowFilesSent", status.getFlowFilesSent());
        addField(builder, "flowFilesTransferred", status.getFlowFilesTransferred());
        addField(builder, "inputContentSize", status.getInputContentSize());
        addField(builder, "inputCount", status.getInputCount());
        addField(builder, "outputContentSize", status.getOutputContentSize());
        addField(builder, "outputCount", status.getOutputCount());
        addField(builder, "queuedContentSize", status.getQueuedContentSize());
        addField(builder, "activeThreadCount", status.getActiveThreadCount());
        addField(builder, "queuedCount", status.getQueuedCount());
        arrayBuilder.add(builder.build());
    }
    for (ProcessGroupStatus childGroupStatus : status.getProcessGroupStatus()) {
        serializeProcessGroupStatus(arrayBuilder, factory, childGroupStatus, df, hostname, applicationName, platform, status.getId(), currentDate);
    }
    for (ProcessorStatus processorStatus : status.getProcessorStatus()) {
        serializeProcessorStatus(arrayBuilder, factory, processorStatus, df, hostname, applicationName, platform, status.getId(), currentDate);
    }
    for (ConnectionStatus connectionStatus : status.getConnectionStatus()) {
        serializeConnectionStatus(arrayBuilder, factory, connectionStatus, df, hostname, applicationName, platform, status.getId(), currentDate);
    }
    for (PortStatus portStatus : status.getInputPortStatus()) {
        serializePortStatus("InputPort", arrayBuilder, factory, portStatus, df, hostname, applicationName, platform, status.getId(), currentDate);
    }
    for (PortStatus portStatus : status.getOutputPortStatus()) {
        serializePortStatus("OutputPort", arrayBuilder, factory, portStatus, df, hostname, applicationName, platform, status.getId(), currentDate);
    }
    for (RemoteProcessGroupStatus remoteProcessGroupStatus : status.getRemoteProcessGroupStatus()) {
        serializeRemoteProcessGroupStatus(arrayBuilder, factory, remoteProcessGroupStatus, df, hostname, applicationName, platform, status.getId(), currentDate);
    }
}
Also used : ProcessGroupStatus(org.apache.nifi.controller.status.ProcessGroupStatus) RemoteProcessGroupStatus(org.apache.nifi.controller.status.RemoteProcessGroupStatus) PortStatus(org.apache.nifi.controller.status.PortStatus) JsonObjectBuilder(javax.json.JsonObjectBuilder) ConnectionStatus(org.apache.nifi.controller.status.ConnectionStatus) RemoteProcessGroupStatus(org.apache.nifi.controller.status.RemoteProcessGroupStatus) ProcessorStatus(org.apache.nifi.controller.status.ProcessorStatus)

Example 4 with PortStatus

use of org.apache.nifi.controller.status.PortStatus in project nifi by apache.

the class TestSiteToSiteStatusReportingTask method generateProcessGroupStatus.

public static ProcessGroupStatus generateProcessGroupStatus(String id, String namePrefix, int maxRecursion, int currentDepth) {
    Collection<ConnectionStatus> cStatus = new ArrayList<>();
    Collection<PortStatus> ipStatus = new ArrayList<>();
    Collection<PortStatus> opStatus = new ArrayList<>();
    Collection<ProcessorStatus> pStatus = new ArrayList<>();
    Collection<RemoteProcessGroupStatus> rpgStatus = new ArrayList<>();
    Collection<ProcessGroupStatus> childPgStatus = new ArrayList<>();
    if (currentDepth < maxRecursion) {
        for (int i = 1; i < 4; i++) {
            childPgStatus.add(generateProcessGroupStatus(id + "." + i, namePrefix + "." + i, maxRecursion, currentDepth + 1));
        }
    }
    for (int i = 1; i < 4; i++) {
        pStatus.add(generateProcessorStatus(id + ".processor." + i, namePrefix + ".processor." + i));
    }
    for (int i = 1; i < 4; i++) {
        cStatus.add(generateConnectionStatus(id + ".connection." + i, namePrefix + ".connection." + i));
    }
    for (int i = 1; i < 4; i++) {
        rpgStatus.add(generateRemoteProcessGroupStatus(id + ".rpg." + i, namePrefix + ".rpg." + i));
    }
    for (int i = 1; i < 4; i++) {
        ipStatus.add(generatePortStatus(id + ".ip." + i, namePrefix + ".ip." + i));
    }
    for (int i = 1; i < 4; i++) {
        opStatus.add(generatePortStatus(id + ".op." + i, namePrefix + ".op." + i));
    }
    ProcessGroupStatus pgStatus = new ProcessGroupStatus();
    pgStatus.setId(id);
    pgStatus.setName(namePrefix + "-" + UUID.randomUUID().toString());
    pgStatus.setInputPortStatus(ipStatus);
    pgStatus.setOutputPortStatus(opStatus);
    pgStatus.setProcessGroupStatus(childPgStatus);
    pgStatus.setRemoteProcessGroupStatus(rpgStatus);
    pgStatus.setProcessorStatus(pStatus);
    pgStatus.setActiveThreadCount(1);
    pgStatus.setBytesRead(2L);
    pgStatus.setBytesReceived(3l);
    pgStatus.setBytesSent(4l);
    pgStatus.setBytesTransferred(5l);
    pgStatus.setBytesWritten(6l);
    pgStatus.setConnectionStatus(cStatus);
    pgStatus.setFlowFilesReceived(7);
    pgStatus.setFlowFilesSent(8);
    pgStatus.setFlowFilesTransferred(9);
    pgStatus.setInputContentSize(10l);
    pgStatus.setInputCount(11);
    pgStatus.setOutputContentSize(12l);
    pgStatus.setOutputCount(13);
    pgStatus.setQueuedContentSize(14l);
    pgStatus.setQueuedCount(15);
    return pgStatus;
}
Also used : ProcessGroupStatus(org.apache.nifi.controller.status.ProcessGroupStatus) RemoteProcessGroupStatus(org.apache.nifi.controller.status.RemoteProcessGroupStatus) ArrayList(java.util.ArrayList) PortStatus(org.apache.nifi.controller.status.PortStatus) ConnectionStatus(org.apache.nifi.controller.status.ConnectionStatus) RemoteProcessGroupStatus(org.apache.nifi.controller.status.RemoteProcessGroupStatus) ProcessorStatus(org.apache.nifi.controller.status.ProcessorStatus)

Example 5 with PortStatus

use of org.apache.nifi.controller.status.PortStatus in project nifi by apache.

the class TestSiteToSiteStatusReportingTask method generatePortStatus.

public static PortStatus generatePortStatus(String id, String namePrefix) {
    PortStatus pStatus = new PortStatus();
    pStatus.setId(id);
    pStatus.setName(namePrefix + "-" + UUID.randomUUID().toString());
    pStatus.setActiveThreadCount(0);
    pStatus.setBytesReceived(1l);
    pStatus.setBytesSent(2l);
    pStatus.setFlowFilesReceived(3);
    pStatus.setFlowFilesSent(4);
    pStatus.setInputBytes(5l);
    pStatus.setInputCount(6);
    pStatus.setOutputBytes(7l);
    pStatus.setOutputCount(8);
    return pStatus;
}
Also used : PortStatus(org.apache.nifi.controller.status.PortStatus)

Aggregations

PortStatus (org.apache.nifi.controller.status.PortStatus)10 ProcessGroupStatus (org.apache.nifi.controller.status.ProcessGroupStatus)8 ConnectionStatus (org.apache.nifi.controller.status.ConnectionStatus)7 ProcessorStatus (org.apache.nifi.controller.status.ProcessorStatus)7 RemoteProcessGroupStatus (org.apache.nifi.controller.status.RemoteProcessGroupStatus)7 ArrayList (java.util.ArrayList)4 Port (org.apache.nifi.connectable.Port)4 ProcessGroup (org.apache.nifi.groups.ProcessGroup)4 RemoteProcessGroup (org.apache.nifi.groups.RemoteProcessGroup)4 RemoteGroupPort (org.apache.nifi.remote.RemoteGroupPort)4 RootGroupPort (org.apache.nifi.remote.RootGroupPort)4 VersionedProcessGroup (org.apache.nifi.registry.flow.VersionedProcessGroup)3 NodeConnectionStatus (org.apache.nifi.cluster.coordination.node.NodeConnectionStatus)2 Connection (org.apache.nifi.connectable.Connection)2 ResourceNotFoundException (org.apache.nifi.web.ResourceNotFoundException)2 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Function (java.util.function.Function)1