Java Code Examples for org.apache.nifi.controller.status.ProcessGroupStatus#setProcessorStatus()

The following examples show how to use org.apache.nifi.controller.status.ProcessGroupStatus#setProcessorStatus() . 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: TestDataDogReportingTask.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 2
Source File: TestAzureLogAnalyticsReportingTask.java    From nifi with Apache License 2.0 6 votes vote down vote up
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);
    rootGroupStatus.setProcessorStatus(processorStatuses);

    ProcessGroupStatus groupStatus = new ProcessGroupStatus();
    groupStatus.setProcessorStatus(processorStatuses);

    Collection<ProcessGroupStatus> groupStatuses = new ArrayList<>();
    groupStatuses.add(groupStatus);
    rootGroupStatus.setProcessGroupStatus(groupStatuses);
}
 
Example 3
Source File: TestDataDogReportingTask.java    From nifi with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 4
Source File: TestMetricsService.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetProcessGroupStatusMetricsWithID() {
    ProcessGroupStatus status = new ProcessGroupStatus();
    String id = "1234";
    status.setId(id);
    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);

    // create a processor status with processing time
    ProcessorStatus procStatus = new ProcessorStatus();
    procStatus.setProcessingNanos(123456789);

    Collection<ProcessorStatus> processorStatuses = new ArrayList<>();
    processorStatuses.add(procStatus);
    status.setProcessorStatus(processorStatuses);

    // create a group status with processing time
    ProcessGroupStatus groupStatus = new ProcessGroupStatus();
    groupStatus.setProcessorStatus(processorStatuses);

    Collection<ProcessGroupStatus> groupStatuses = new ArrayList<>();
    groupStatuses.add(groupStatus);
    status.setProcessGroupStatus(groupStatuses);

    final MetricsService service = new MetricsService();

    final Map<String,String> metrics = service.getMetrics(status, true);

    Assert.assertTrue(metrics.containsKey(MetricNames.FLOW_FILES_RECEIVED + MetricNames.METRIC_NAME_SEPARATOR + id));
}
 
Example 5
Source File: TestAmbariReportingTask.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
    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);

    // create a processor status with processing time
    ProcessorStatus procStatus = new ProcessorStatus();
    procStatus.setProcessingNanos(123456789);

    Collection<ProcessorStatus> processorStatuses = new ArrayList<>();
    processorStatuses.add(procStatus);
    status.setProcessorStatus(processorStatuses);

    // create a group status with processing time
    ProcessGroupStatus groupStatus = new ProcessGroupStatus();
    groupStatus.setProcessorStatus(processorStatuses);

    Collection<ProcessGroupStatus> groupStatuses = new ArrayList<>();
    groupStatuses.add(groupStatus);
    status.setProcessGroupStatus(groupStatuses);
}
 
Example 6
Source File: TestMetricsService.java    From nifi-prometheus-reporter with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetProcessGroupStatusMetricsWithID() {
    ProcessGroupStatus status = new ProcessGroupStatus();
    String id = "1234";
    status.setId(id);
    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);

    // create a processor status with processing time
    ProcessorStatus procStatus = new ProcessorStatus();
    procStatus.setProcessingNanos(123456789);

    Collection<ProcessorStatus> processorStatuses = new ArrayList<>();
    processorStatuses.add(procStatus);
    status.setProcessorStatus(processorStatuses);

    // create a group status with processing time
    ProcessGroupStatus groupStatus = new ProcessGroupStatus();
    groupStatus.setProcessorStatus(processorStatuses);

    Collection<ProcessGroupStatus> groupStatuses = new ArrayList<>();
    groupStatuses.add(groupStatus);
    status.setProcessGroupStatus(groupStatuses);

    final MetricsService service = new MetricsService();

    final Map<String, String> metrics = service.getMetrics(status, true);

    Assert.assertTrue(metrics.containsKey(MetricNames.FLOW_FILES_RECEIVED + MetricNames.METRIC_NAME_SEPARATOR + id));
}
 
Example 7
Source File: TestPrometheusReportingTask.java    From nifi-prometheus-reporter with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
    status = new ProcessGroupStatus();
    status.setId("1234");
    status.setName("localTest");
    status.setFlowFilesReceived(5);
    status.setFlowFilesSent(10);
    status.setFlowFilesTransferred(10);
    status.setBytesReceived(10000);
    status.setBytesSent(20000);
    status.setBytesTransferred(10000);
    status.setBytesRead(60000L);
    status.setBytesWritten(80000L);
    status.setQueuedCount(100);
    status.setQueuedContentSize(1024L);
    status.setActiveThreadCount(5);
    status.setInputCount(10);
    status.setOutputCount(20);
    status.setQueuedCount(30);
    status.setInputContentSize(Integer.toUnsignedLong(0));
    status.setOutputContentSize(Integer.toUnsignedLong(0));
    status.setOutputContentSize(Integer.toUnsignedLong(0));


    // create a processor status with processing time
    ProcessorStatus procStatus = new ProcessorStatus();
    procStatus.setProcessingNanos(123456789);

    Collection<ProcessorStatus> processorStatuses = new ArrayList<>();
    processorStatuses.add(procStatus);
    status.setProcessorStatus(processorStatuses);

    // create a group status with processing time
    ProcessGroupStatus groupStatus = new ProcessGroupStatus();
    groupStatus.setProcessorStatus(processorStatuses);

    Collection<ProcessGroupStatus> groupStatuses = new ArrayList<>();
    groupStatuses.add(groupStatus);
    status.setProcessGroupStatus(groupStatuses);
}
 
Example 8
Source File: TestSiteToSiteMetricsReportingTask.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
    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(null);
    status.setBytesWritten(80000L);
    status.setActiveThreadCount(5);

    // create a processor status with processing time
    ProcessorStatus procStatus = new ProcessorStatus();
    procStatus.setProcessingNanos(123456789);

    Collection<ProcessorStatus> processorStatuses = new ArrayList<>();
    processorStatuses.add(procStatus);
    status.setProcessorStatus(processorStatuses);

    // create a group status with processing time
    ProcessGroupStatus groupStatus = new ProcessGroupStatus();
    groupStatus.setProcessorStatus(processorStatuses);

    Collection<ProcessGroupStatus> groupStatuses = new ArrayList<>();
    groupStatuses.add(groupStatus);
    status.setProcessGroupStatus(groupStatuses);
}
 
Example 9
Source File: TestMetricsService.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetProcessGroupStatusMetricsWithID() {
    ProcessGroupStatus status = new ProcessGroupStatus();
    String id = "1234";
    status.setId(id);
    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);

    // create a processor status with processing time
    ProcessorStatus procStatus = new ProcessorStatus();
    procStatus.setProcessingNanos(123456789);

    Collection<ProcessorStatus> processorStatuses = new ArrayList<>();
    processorStatuses.add(procStatus);
    status.setProcessorStatus(processorStatuses);

    // create a group status with processing time
    ProcessGroupStatus groupStatus = new ProcessGroupStatus();
    groupStatus.setProcessorStatus(processorStatuses);

    Collection<ProcessGroupStatus> groupStatuses = new ArrayList<>();
    groupStatuses.add(groupStatus);
    status.setProcessGroupStatus(groupStatuses);

    final MetricsService service = new MetricsService();

    final Map<String,String> metrics = service.getMetrics(status, true);

    Assert.assertTrue(metrics.containsKey(MetricNames.FLOW_FILES_RECEIVED + MetricNames.METRIC_NAME_SEPARATOR + id));
}
 
Example 10
Source File: TestAmbariReportingTask.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
    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);

    // create a processor status with processing time
    ProcessorStatus procStatus = new ProcessorStatus();
    procStatus.setProcessingNanos(123456789);

    Collection<ProcessorStatus> processorStatuses = new ArrayList<>();
    processorStatuses.add(procStatus);
    status.setProcessorStatus(processorStatuses);

    // create a group status with processing time
    ProcessGroupStatus groupStatus = new ProcessGroupStatus();
    groupStatus.setProcessorStatus(processorStatuses);

    Collection<ProcessGroupStatus> groupStatuses = new ArrayList<>();
    groupStatuses.add(groupStatus);
    status.setProcessGroupStatus(groupStatuses);
}
 
Example 11
Source File: TestMetricsService.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
@Test
public void testGetProcessGroupStatusMetrics() {
    ProcessGroupStatus 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);

    // create a processor status with processing time
    ProcessorStatus procStatus = new ProcessorStatus();
    procStatus.setProcessingNanos(123456789);

    Collection<ProcessorStatus> processorStatuses = new ArrayList<>();
    processorStatuses.add(procStatus);
    status.setProcessorStatus(processorStatuses);

    // create a group status with processing time
    ProcessGroupStatus groupStatus = new ProcessGroupStatus();
    groupStatus.setProcessorStatus(processorStatuses);

    Collection<ProcessGroupStatus> groupStatuses = new ArrayList<>();
    groupStatuses.add(groupStatus);
    status.setProcessGroupStatus(groupStatuses);

    final MetricsService service = new MetricsService();

    final Map<String,String> metrics = service.getMetrics(status, false);

    Assert.assertTrue(metrics.containsKey(MetricNames.FLOW_FILES_RECEIVED));
    Assert.assertTrue(metrics.containsKey(MetricNames.BYTES_RECEIVED));
    Assert.assertTrue(metrics.containsKey(MetricNames.FLOW_FILES_SENT));
    Assert.assertTrue(metrics.containsKey(MetricNames.BYTES_SENT));
    Assert.assertTrue(metrics.containsKey(MetricNames.FLOW_FILES_QUEUED));
    Assert.assertTrue(metrics.containsKey(MetricNames.BYTES_QUEUED));
    Assert.assertTrue(metrics.containsKey(MetricNames.BYTES_READ));
    Assert.assertTrue(metrics.containsKey(MetricNames.BYTES_WRITTEN));
    Assert.assertTrue(metrics.containsKey(MetricNames.ACTIVE_THREADS));
    Assert.assertTrue(metrics.containsKey(MetricNames.TOTAL_TASK_DURATION_SECONDS));
    Assert.assertTrue(metrics.containsKey(MetricNames.TOTAL_TASK_DURATION_NANOS));
}
 
Example 12
Source File: TestMetricsService.java    From nifi-prometheus-reporter with Apache License 2.0 4 votes vote down vote up
@Test
public void testGetProcessGroupStatusMetrics() {
    ProcessGroupStatus 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);

    // create a processor status with processing time
    ProcessorStatus procStatus = new ProcessorStatus();
    procStatus.setProcessingNanos(123456789);

    Collection<ProcessorStatus> processorStatuses = new ArrayList<>();
    processorStatuses.add(procStatus);
    status.setProcessorStatus(processorStatuses);

    // create a group status with processing time
    ProcessGroupStatus groupStatus = new ProcessGroupStatus();
    groupStatus.setProcessorStatus(processorStatuses);

    Collection<ProcessGroupStatus> groupStatuses = new ArrayList<>();
    groupStatuses.add(groupStatus);
    status.setProcessGroupStatus(groupStatuses);

    final MetricsService service = new MetricsService();

    final Map<String, String> metrics = service.getMetrics(status, false);

    Assert.assertTrue(metrics.containsKey(MetricNames.FLOW_FILES_RECEIVED));
    Assert.assertTrue(metrics.containsKey(MetricNames.BYTES_RECEIVED));
    Assert.assertTrue(metrics.containsKey(MetricNames.FLOW_FILES_SENT));
    Assert.assertTrue(metrics.containsKey(MetricNames.BYTES_SENT));
    Assert.assertTrue(metrics.containsKey(MetricNames.FLOW_FILES_QUEUED));
    Assert.assertTrue(metrics.containsKey(MetricNames.BYTES_QUEUED));
    Assert.assertTrue(metrics.containsKey(MetricNames.BYTES_READ));
    Assert.assertTrue(metrics.containsKey(MetricNames.BYTES_WRITTEN));
    Assert.assertTrue(metrics.containsKey(MetricNames.ACTIVE_THREADS));
    Assert.assertTrue(metrics.containsKey(MetricNames.TOTAL_TASK_DURATION_SECONDS));
    Assert.assertTrue(metrics.containsKey(MetricNames.TOTAL_TASK_DURATION_NANOS));
}
 
Example 13
Source File: TestSiteToSiteStatusReportingTask.java    From nifi with Apache License 2.0 4 votes vote down vote up
/***********************************
 * Test component generator methods
 ***********************************/

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.setVersionedFlowState(VersionedFlowState.UP_TO_DATE);
    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);
    pgStatus.setTerminatedThreadCount(1);

    return pgStatus;
}
 
Example 14
Source File: TestQueryNiFiReportingTask.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Before
public void setup() {
    mockRecordSinkService = new MockRecordSinkService();
    status = new ProcessGroupStatus();
    status.setId("1234");
    status.setFlowFilesReceived(5);
    status.setBytesReceived(10000);
    status.setFlowFilesSent(10);
    status.setBytesRead(20000L);
    status.setBytesSent(20000);
    status.setQueuedCount(100);
    status.setQueuedContentSize(1024L);
    status.setBytesWritten(80000L);
    status.setActiveThreadCount(5);

    // create a processor status with processing time
    ProcessorStatus procStatus = new ProcessorStatus();
    procStatus.setId("proc");
    procStatus.setProcessingNanos(123456789);

    Collection<ProcessorStatus> processorStatuses = new ArrayList<>();
    processorStatuses.add(procStatus);
    status.setProcessorStatus(processorStatuses);

    ConnectionStatus root1ConnectionStatus = new ConnectionStatus();
    root1ConnectionStatus.setId("root1");
    root1ConnectionStatus.setQueuedCount(1000);
    root1ConnectionStatus.setBackPressureObjectThreshold(1000);

    ConnectionStatus root2ConnectionStatus = new ConnectionStatus();
    root2ConnectionStatus.setId("root2");
    root2ConnectionStatus.setQueuedCount(500);
    root2ConnectionStatus.setBackPressureObjectThreshold(1000);

    Collection<ConnectionStatus> rootConnectionStatuses = new ArrayList<>();
    rootConnectionStatuses.add(root1ConnectionStatus);
    rootConnectionStatuses.add(root2ConnectionStatus);
    status.setConnectionStatus(rootConnectionStatuses);

    // create a group status with processing time
    ProcessGroupStatus groupStatus1 = new ProcessGroupStatus();
    groupStatus1.setProcessorStatus(processorStatuses);
    groupStatus1.setBytesRead(1234L);

    // Create a nested group status with a connection
    ProcessGroupStatus groupStatus2 = new ProcessGroupStatus();
    groupStatus2.setProcessorStatus(processorStatuses);
    groupStatus2.setBytesRead(12345L);
    ConnectionStatus nestedConnectionStatus = new ConnectionStatus();
    nestedConnectionStatus.setId("nested");
    nestedConnectionStatus.setQueuedCount(1001);
    Collection<ConnectionStatus> nestedConnectionStatuses = new ArrayList<>();
    nestedConnectionStatuses.add(nestedConnectionStatus);
    groupStatus2.setConnectionStatus(nestedConnectionStatuses);
    Collection<ProcessGroupStatus> nestedGroupStatuses = new ArrayList<>();
    nestedGroupStatuses.add(groupStatus2);
    groupStatus1.setProcessGroupStatus(nestedGroupStatuses);

    ProcessGroupStatus groupStatus3 = new ProcessGroupStatus();
    groupStatus3.setBytesRead(1L);
    ConnectionStatus nestedConnectionStatus2 = new ConnectionStatus();
    nestedConnectionStatus2.setId("nested2");
    nestedConnectionStatus2.setQueuedCount(3);
    Collection<ConnectionStatus> nestedConnectionStatuses2 = new ArrayList<>();
    nestedConnectionStatuses2.add(nestedConnectionStatus2);
    groupStatus3.setConnectionStatus(nestedConnectionStatuses2);
    Collection<ProcessGroupStatus> nestedGroupStatuses2 = new ArrayList<>();
    nestedGroupStatuses2.add(groupStatus3);

    Collection<ProcessGroupStatus> groupStatuses = new ArrayList<>();
    groupStatuses.add(groupStatus1);
    groupStatuses.add(groupStatus3);
    status.setProcessGroupStatus(groupStatuses);

}
 
Example 15
Source File: TestMetricsEventReportingTask.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Before
public void setup() {
    status = new ProcessGroupStatus();
    actionHandler = new MockPropertyContextActionHandler();
    status.setId("1234");
    status.setFlowFilesReceived(5);
    status.setBytesReceived(10000);
    status.setFlowFilesSent(10);
    status.setBytesRead(20000L);
    status.setBytesSent(20000);
    status.setQueuedCount(100);
    status.setQueuedContentSize(1024L);
    status.setBytesWritten(80000L);
    status.setActiveThreadCount(5);

    // create a processor status with processing time
    ProcessorStatus procStatus = new ProcessorStatus();
    procStatus.setId("proc");
    procStatus.setProcessingNanos(123456789);

    Collection<ProcessorStatus> processorStatuses = new ArrayList<>();
    processorStatuses.add(procStatus);
    status.setProcessorStatus(processorStatuses);

    ConnectionStatusPredictions connectionStatusPredictions = new ConnectionStatusPredictions();
    connectionStatusPredictions.setPredictedTimeToCountBackpressureMillis(1000);
    connectionStatusPredictions.setPredictedTimeToBytesBackpressureMillis(1000);
    connectionStatusPredictions.setNextPredictedQueuedCount(1000000000);
    connectionStatusPredictions.setNextPredictedQueuedBytes(1000000000000000L);

    ConnectionStatus root1ConnectionStatus = new ConnectionStatus();
    root1ConnectionStatus.setId("root1");
    root1ConnectionStatus.setQueuedCount(1000);
    root1ConnectionStatus.setPredictions(connectionStatusPredictions);

    ConnectionStatus root2ConnectionStatus = new ConnectionStatus();
    root2ConnectionStatus.setId("root2");
    root2ConnectionStatus.setQueuedCount(500);
    root2ConnectionStatus.setPredictions(connectionStatusPredictions);

    Collection<ConnectionStatus> rootConnectionStatuses = new ArrayList<>();
    rootConnectionStatuses.add(root1ConnectionStatus);
    rootConnectionStatuses.add(root2ConnectionStatus);
    status.setConnectionStatus(rootConnectionStatuses);

    // create a group status with processing time
    ProcessGroupStatus groupStatus1 = new ProcessGroupStatus();
    groupStatus1.setProcessorStatus(processorStatuses);
    groupStatus1.setBytesRead(1234L);

    // Create a nested group status with a connection
    ProcessGroupStatus groupStatus2 = new ProcessGroupStatus();
    groupStatus2.setProcessorStatus(processorStatuses);
    groupStatus2.setBytesRead(12345L);
    ConnectionStatus nestedConnectionStatus = new ConnectionStatus();
    nestedConnectionStatus.setId("nested");
    nestedConnectionStatus.setQueuedCount(1001);
    Collection<ConnectionStatus> nestedConnectionStatuses = new ArrayList<>();
    nestedConnectionStatuses.add(nestedConnectionStatus);
    groupStatus2.setConnectionStatus(nestedConnectionStatuses);
    Collection<ProcessGroupStatus> nestedGroupStatuses = new ArrayList<>();
    nestedGroupStatuses.add(groupStatus2);
    groupStatus1.setProcessGroupStatus(nestedGroupStatuses);

    ProcessGroupStatus groupStatus3 = new ProcessGroupStatus();
    groupStatus3.setBytesRead(1L);
    ConnectionStatus nestedConnectionStatus2 = new ConnectionStatus();
    nestedConnectionStatus2.setId("nested2");
    nestedConnectionStatus2.setQueuedCount(3);
    Collection<ConnectionStatus> nestedConnectionStatuses2 = new ArrayList<>();
    nestedConnectionStatuses2.add(nestedConnectionStatus2);
    groupStatus3.setConnectionStatus(nestedConnectionStatuses2);
    Collection<ProcessGroupStatus> nestedGroupStatuses2 = new ArrayList<>();
    nestedGroupStatuses2.add(groupStatus3);

    Collection<ProcessGroupStatus> groupStatuses = new ArrayList<>();
    groupStatuses.add(groupStatus1);
    groupStatuses.add(groupStatus3);
    status.setProcessGroupStatus(groupStatuses);

}
 
Example 16
Source File: TestMetricsService.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Test
public void testGetProcessGroupStatusMetrics() {
    ProcessGroupStatus 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);

    // create a processor status with processing time
    ProcessorStatus procStatus = new ProcessorStatus();
    procStatus.setProcessingNanos(123456789);

    Collection<ProcessorStatus> processorStatuses = new ArrayList<>();
    processorStatuses.add(procStatus);
    status.setProcessorStatus(processorStatuses);

    // create a group status with processing time
    ProcessGroupStatus groupStatus = new ProcessGroupStatus();
    groupStatus.setProcessorStatus(processorStatuses);

    Collection<ProcessGroupStatus> groupStatuses = new ArrayList<>();
    groupStatuses.add(groupStatus);
    status.setProcessGroupStatus(groupStatuses);

    final MetricsService service = new MetricsService();

    final Map<String,String> metrics = service.getMetrics(status, false);

    Assert.assertTrue(metrics.containsKey(MetricNames.FLOW_FILES_RECEIVED));
    Assert.assertTrue(metrics.containsKey(MetricNames.BYTES_RECEIVED));
    Assert.assertTrue(metrics.containsKey(MetricNames.FLOW_FILES_SENT));
    Assert.assertTrue(metrics.containsKey(MetricNames.BYTES_SENT));
    Assert.assertTrue(metrics.containsKey(MetricNames.FLOW_FILES_QUEUED));
    Assert.assertTrue(metrics.containsKey(MetricNames.BYTES_QUEUED));
    Assert.assertTrue(metrics.containsKey(MetricNames.BYTES_READ));
    Assert.assertTrue(metrics.containsKey(MetricNames.BYTES_WRITTEN));
    Assert.assertTrue(metrics.containsKey(MetricNames.ACTIVE_THREADS));
    Assert.assertTrue(metrics.containsKey(MetricNames.TOTAL_TASK_DURATION_SECONDS));
    Assert.assertTrue(metrics.containsKey(MetricNames.TOTAL_TASK_DURATION_NANOS));
}