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

The following examples show how to use org.apache.nifi.controller.status.ProcessGroupStatus#setBytesRead() . 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: TestAzureLogAnalyticsReportingTask.java    From nifi with Apache License 2.0 6 votes vote down vote up
private void initTestGroup2Statuses() {
    testGroupStatus2 = new ProcessGroupStatus();
    testGroupStatus2.setId(TEST_GROUP2_ID);
    testGroupStatus2.setFlowFilesReceived(5);
    testGroupStatus2.setBytesReceived(10000);
    testGroupStatus2.setFlowFilesSent(10);
    testGroupStatus2.setBytesSent(20000);
    testGroupStatus2.setQueuedCount(100);
    testGroupStatus2.setQueuedContentSize(1024L);
    testGroupStatus2.setBytesRead(60000L);
    testGroupStatus2.setBytesWritten(80000L);
    testGroupStatus2.setActiveThreadCount(5);
    testGroupStatus2.setName(TEST_GROUP2_ID);
    testGroupStatus2.setFlowFilesTransferred(5);
    testGroupStatus2.setBytesTransferred(10000);
    testGroupStatus2.setOutputContentSize(1000L);
    testGroupStatus2.setInputContentSize(1000L);
    testGroupStatus2.setOutputCount(100);
    testGroupStatus2.setInputCount(1000);
}
 
Example 2
Source File: TestAzureLogAnalyticsReportingTask.java    From nifi with Apache License 2.0 6 votes vote down vote up
private void initTestGroupStatuses() {
    testGroupStatus = new ProcessGroupStatus();
    testGroupStatus.setId(TEST_GROUP1_ID);
    testGroupStatus.setFlowFilesReceived(5);
    testGroupStatus.setBytesReceived(10000);
    testGroupStatus.setFlowFilesSent(10);
    testGroupStatus.setBytesSent(20000);
    testGroupStatus.setQueuedCount(100);
    testGroupStatus.setQueuedContentSize(1024L);
    testGroupStatus.setBytesRead(60000L);
    testGroupStatus.setBytesWritten(80000L);
    testGroupStatus.setActiveThreadCount(5);
    testGroupStatus.setName(TEST_GROUP1_ID);
    testGroupStatus.setFlowFilesTransferred(5);
    testGroupStatus.setBytesTransferred(10000);
    testGroupStatus.setOutputContentSize(1000L);
    testGroupStatus.setInputContentSize(1000L);
    testGroupStatus.setOutputCount(100);
    testGroupStatus.setInputCount(1000);
}
 
Example 3
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 4
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 5
Source File: TestDataDogReportingTask.java    From nifi with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 6
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 7
Source File: TestMetricsFactory.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Before
public void init() {
    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);
}
 
Example 8
Source File: TestMetricsService.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Before
public void init() {
    status = new ProcessGroupStatus();
    metricsService = new MetricsService();
    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);
}
 
Example 9
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 10
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 11
Source File: TestDataDogReportingTask.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 12
Source File: TestMetricsService.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@Before
public void init() {
    status = new ProcessGroupStatus();
    metricsService = new MetricsService();
    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);
}
 
Example 13
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 14
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 15
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 16
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 17
Source File: TestPrometheusReportingTask.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Before
public void setup() {
    testedReportingTask = new PrometheusReportingTask();
    rootGroupStatus = new ProcessGroupStatus();
    reportingInitContextStub = new MockReportingInitializationContext(TEST_INIT_CONTEXT_ID, TEST_INIT_CONTEXT_NAME,
            new MockComponentLog(TEST_TASK_ID, testedReportingTask));

    reportingContextStub = new MockReportingContext(Collections.emptyMap(),
            new MockStateManager(testedReportingTask), new MockVariableRegistry());

    reportingContextStub.setProperty(PrometheusMetricsUtil.INSTANCE_ID.getName(), "localhost");

    configurationContextStub = new MockConfigurationContext(reportingContextStub.getProperties(),
            reportingContextStub.getControllerServiceLookup());

    rootGroupStatus.setId("1234");
    rootGroupStatus.setFlowFilesReceived(5);
    rootGroupStatus.setBytesReceived(10000);
    rootGroupStatus.setFlowFilesSent(10);
    rootGroupStatus.setBytesSent(20000);
    rootGroupStatus.setQueuedCount(100);
    rootGroupStatus.setQueuedContentSize(1024L);
    rootGroupStatus.setBytesRead(60000L);
    rootGroupStatus.setBytesWritten(80000L);
    rootGroupStatus.setActiveThreadCount(5);
    rootGroupStatus.setName("root");
    rootGroupStatus.setFlowFilesTransferred(5);
    rootGroupStatus.setBytesTransferred(10000);
    rootGroupStatus.setOutputContentSize(1000L);
    rootGroupStatus.setInputContentSize(1000L);
    rootGroupStatus.setOutputCount(100);
    rootGroupStatus.setInputCount(1000);

    PortStatus outputPortStatus = new PortStatus();
    outputPortStatus.setId("9876");
    outputPortStatus.setName("out");
    outputPortStatus.setGroupId("1234");
    outputPortStatus.setRunStatus(RunStatus.Stopped);
    outputPortStatus.setActiveThreadCount(1);

    rootGroupStatus.setOutputPortStatus(Collections.singletonList(outputPortStatus));
    // Create a nested group status
    ProcessGroupStatus groupStatus2 = new ProcessGroupStatus();
    groupStatus2.setFlowFilesReceived(5);
    groupStatus2.setBytesReceived(10000);
    groupStatus2.setFlowFilesSent(10);
    groupStatus2.setBytesSent(20000);
    groupStatus2.setQueuedCount(100);
    groupStatus2.setQueuedContentSize(1024L);
    groupStatus2.setActiveThreadCount(2);
    groupStatus2.setBytesRead(12345L);
    groupStatus2.setBytesWritten(11111L);
    groupStatus2.setFlowFilesTransferred(5);
    groupStatus2.setBytesTransferred(10000);
    groupStatus2.setOutputContentSize(1000L);
    groupStatus2.setInputContentSize(1000L);
    groupStatus2.setOutputCount(100);
    groupStatus2.setInputCount(1000);
    groupStatus2.setId("3378");
    groupStatus2.setName("nestedPG");
    Collection<ProcessGroupStatus> nestedGroupStatuses = new ArrayList<>();
    nestedGroupStatuses.add(groupStatus2);
    rootGroupStatus.setProcessGroupStatus(nestedGroupStatuses);
}
 
Example 18
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 19
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 20
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));
}