Search in sources :

Example 6 with ProcessGroupStatus

use of org.apache.nifi.controller.status.ProcessGroupStatus 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 7 with ProcessGroupStatus

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

the class ControllerFacade method getProcessorStatus.

/**
 * Gets the status for the specified processor.
 *
 * @param processorId processor id
 * @return the status for the specified processor
 */
public ProcessorStatus getProcessorStatus(final String processorId) {
    final ProcessGroup root = flowController.getGroup(flowController.getRootGroupId());
    final ProcessorNode processor = root.findProcessor(processorId);
    // ensure the processor was found
    if (processor == null) {
        throw new ResourceNotFoundException(String.format("Unable to locate processor with id '%s'.", processorId));
    }
    // calculate the process group status
    final String groupId = processor.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 ProcessorStatus status = processGroupStatus.getProcessorStatus().stream().filter(processorStatus -> processorId.equals(processorStatus.getId())).findFirst().orElse(null);
    if (status == null) {
        throw new ResourceNotFoundException(String.format("Unable to locate processor with id '%s'.", processorId));
    }
    return status;
}
Also used : ProcessGroupStatus(org.apache.nifi.controller.status.ProcessGroupStatus) RemoteProcessGroupStatus(org.apache.nifi.controller.status.RemoteProcessGroupStatus) ProcessorNode(org.apache.nifi.controller.ProcessorNode) VersionedProcessGroup(org.apache.nifi.registry.flow.VersionedProcessGroup) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) ProcessGroup(org.apache.nifi.groups.ProcessGroup) ResourceNotFoundException(org.apache.nifi.web.ResourceNotFoundException) ProcessorStatus(org.apache.nifi.controller.status.ProcessorStatus)

Example 8 with ProcessGroupStatus

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

the class ControllerFacade method getRemoteProcessGroupStatus.

/**
 * Gets the status for the specified remote process group.
 *
 * @param remoteProcessGroupId remote process group id
 * @return the status for the specified remote process group
 */
public RemoteProcessGroupStatus getRemoteProcessGroupStatus(final String remoteProcessGroupId) {
    final ProcessGroup root = flowController.getGroup(flowController.getRootGroupId());
    final RemoteProcessGroup remoteProcessGroup = root.findRemoteProcessGroup(remoteProcessGroupId);
    // ensure the output port was found
    if (remoteProcessGroup == null) {
        throw new ResourceNotFoundException(String.format("Unable to locate remote process group with id '%s'.", remoteProcessGroupId));
    }
    final String groupId = remoteProcessGroup.getProcessGroup().getIdentifier();
    final ProcessGroupStatus groupStatus = flowController.getGroupStatus(groupId, NiFiUserUtils.getNiFiUser());
    if (groupStatus == null) {
        throw new ResourceNotFoundException(String.format("Unable to locate group with id '%s'.", groupId));
    }
    final RemoteProcessGroupStatus status = groupStatus.getRemoteProcessGroupStatus().stream().filter(rpgStatus -> remoteProcessGroupId.equals(rpgStatus.getId())).findFirst().orElse(null);
    if (status == null) {
        throw new ResourceNotFoundException(String.format("Unable to locate remote process group with id '%s'.", remoteProcessGroupId));
    }
    return status;
}
Also used : ProcessGroupStatus(org.apache.nifi.controller.status.ProcessGroupStatus) RemoteProcessGroupStatus(org.apache.nifi.controller.status.RemoteProcessGroupStatus) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) VersionedProcessGroup(org.apache.nifi.registry.flow.VersionedProcessGroup) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) ProcessGroup(org.apache.nifi.groups.ProcessGroup) ResourceNotFoundException(org.apache.nifi.web.ResourceNotFoundException) RemoteProcessGroupStatus(org.apache.nifi.controller.status.RemoteProcessGroupStatus)

Example 9 with ProcessGroupStatus

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

the class TestDataDogReportingTask method initProcessGroupStatus.

private void initProcessGroupStatus() {
    status = new ProcessGroupStatus();
    status.setId("1234");
    status.setFlowFilesReceived(5);
    status.setBytesReceived(10000);
    status.setFlowFilesSent(10);
    status.setBytesSent(20000);
    status.setQueuedCount(100);
    status.setQueuedContentSize(1024L);
    status.setBytesRead(60000L);
    status.setBytesWritten(80000L);
    status.setActiveThreadCount(5);
    status.setInputCount(2);
    status.setOutputCount(4);
}
Also used : ProcessGroupStatus(org.apache.nifi.controller.status.ProcessGroupStatus)

Example 10 with ProcessGroupStatus

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

the class TestDataDogReportingTask method initProcessorStatuses.

private void initProcessorStatuses() {
    procStatus = new ProcessorStatus();
    procStatus.setProcessingNanos(123456789);
    procStatus.setInputCount(2);
    procStatus.setOutputCount(4);
    procStatus.setActiveThreadCount(6);
    procStatus.setBytesSent(1256);
    procStatus.setName("sampleProcessor");
    Collection<ProcessorStatus> processorStatuses = new ArrayList<>();
    processorStatuses.add(procStatus);
    status.setProcessorStatus(processorStatuses);
    ProcessGroupStatus groupStatus = new ProcessGroupStatus();
    groupStatus.setProcessorStatus(processorStatuses);
    Collection<ProcessGroupStatus> groupStatuses = new ArrayList<>();
    groupStatuses.add(groupStatus);
    status.setProcessGroupStatus(groupStatuses);
}
Also used : ProcessGroupStatus(org.apache.nifi.controller.status.ProcessGroupStatus) ArrayList(java.util.ArrayList) ProcessorStatus(org.apache.nifi.controller.status.ProcessorStatus)

Aggregations

ProcessGroupStatus (org.apache.nifi.controller.status.ProcessGroupStatus)46 ProcessorStatus (org.apache.nifi.controller.status.ProcessorStatus)21 RemoteProcessGroupStatus (org.apache.nifi.controller.status.RemoteProcessGroupStatus)19 Test (org.junit.Test)13 ArrayList (java.util.ArrayList)12 HashMap (java.util.HashMap)12 ConnectionStatus (org.apache.nifi.controller.status.ConnectionStatus)11 ProcessGroup (org.apache.nifi.groups.ProcessGroup)11 RemoteProcessGroup (org.apache.nifi.groups.RemoteProcessGroup)11 PropertyDescriptor (org.apache.nifi.components.PropertyDescriptor)10 PortStatus (org.apache.nifi.controller.status.PortStatus)10 Port (org.apache.nifi.connectable.Port)8 RemoteGroupPort (org.apache.nifi.remote.RemoteGroupPort)8 RootGroupPort (org.apache.nifi.remote.RootGroupPort)8 Connection (org.apache.nifi.connectable.Connection)7 ProcessorNode (org.apache.nifi.controller.ProcessorNode)6 VersionedProcessGroup (org.apache.nifi.registry.flow.VersionedProcessGroup)6 IOException (java.io.IOException)5 Collection (java.util.Collection)5 Date (java.util.Date)5