Search in sources :

Example 1 with InstanceStats

use of org.apache.nifi.minifi.commons.status.instance.InstanceStats in project nifi-minifi by apache.

the class StatusReportPopulator method addInstanceStatus.

public static void addInstanceStatus(FlowStatusReport flowStatusReport, boolean addHealth, boolean addStats, boolean addBulletins, boolean populateBulletins) {
    InstanceStatus instanceStatus = new InstanceStatus();
    if (addHealth) {
        InstanceHealth instanceHealth = new InstanceHealth();
        instanceHealth.setQueuedContentSize(1L);
        instanceHealth.setQueuedCount(2);
        instanceHealth.setActiveThreads(3);
        instanceHealth.setHasBulletins(populateBulletins);
        instanceStatus.setInstanceHealth(instanceHealth);
    }
    if (addBulletins) {
        if (populateBulletins) {
            BulletinStatus bulletinStatus = new BulletinStatus();
            bulletinStatus.setMessage("Bulletin message");
            bulletinStatus.setTimestamp(new Date(1464019245000L));
            instanceStatus.setBulletinList(Collections.singletonList(bulletinStatus));
        } else {
            instanceStatus.setBulletinList(Collections.EMPTY_LIST);
        }
    }
    if (addStats) {
        InstanceStats instanceStats = new InstanceStats();
        instanceStats.setBytesRead(1L);
        instanceStats.setBytesWritten(2L);
        instanceStats.setBytesSent(3L);
        instanceStats.setFlowfilesSent(4);
        instanceStats.setBytesTransferred(5L);
        instanceStats.setFlowfilesTransferred(6);
        instanceStats.setBytesReceived(7L);
        instanceStats.setFlowfilesReceived(8);
        instanceStatus.setInstanceStats(instanceStats);
    }
    flowStatusReport.setInstanceStatus(instanceStatus);
}
Also used : InstanceStats(org.apache.nifi.minifi.commons.status.instance.InstanceStats) InstanceStatus(org.apache.nifi.minifi.commons.status.instance.InstanceStatus) InstanceHealth(org.apache.nifi.minifi.commons.status.instance.InstanceHealth) BulletinStatus(org.apache.nifi.minifi.commons.status.common.BulletinStatus) Date(java.util.Date)

Example 2 with InstanceStats

use of org.apache.nifi.minifi.commons.status.instance.InstanceStats in project nifi-minifi by apache.

the class StatusRequestParser method parseInstanceRequest.

static InstanceStatus parseInstanceRequest(String statusTypes, FlowController flowController, ProcessGroupStatus rootGroupStatus) {
    InstanceStatus instanceStatus = new InstanceStatus();
    flowController.getAllControllerServices();
    List<Bulletin> bulletinList = flowController.getBulletinRepository().findBulletinsForController();
    String[] statusSplits = statusTypes.split(",");
    for (String statusType : statusSplits) {
        switch(statusType.toLowerCase().trim()) {
            case "health":
                InstanceHealth instanceHealth = new InstanceHealth();
                instanceHealth.setQueuedCount(rootGroupStatus.getQueuedCount());
                instanceHealth.setQueuedContentSize(rootGroupStatus.getQueuedContentSize());
                instanceHealth.setHasBulletins(!bulletinList.isEmpty());
                instanceHealth.setActiveThreads(rootGroupStatus.getActiveThreadCount());
                instanceStatus.setInstanceHealth(instanceHealth);
                break;
            case "bulletins":
                instanceStatus.setBulletinList(transformBulletins(flowController.getBulletinRepository().findBulletinsForController()));
                break;
            case "stats":
                InstanceStats instanceStats = new InstanceStats();
                instanceStats.setBytesRead(rootGroupStatus.getBytesRead());
                instanceStats.setBytesWritten(rootGroupStatus.getBytesWritten());
                instanceStats.setBytesSent(rootGroupStatus.getBytesSent());
                instanceStats.setFlowfilesSent(rootGroupStatus.getFlowFilesSent());
                instanceStats.setBytesTransferred(rootGroupStatus.getBytesTransferred());
                instanceStats.setFlowfilesTransferred(rootGroupStatus.getFlowFilesTransferred());
                instanceStats.setBytesReceived(rootGroupStatus.getBytesReceived());
                instanceStats.setFlowfilesReceived(rootGroupStatus.getFlowFilesReceived());
                instanceStatus.setInstanceStats(instanceStats);
                break;
        }
    }
    return instanceStatus;
}
Also used : Bulletin(org.apache.nifi.reporting.Bulletin) InstanceStats(org.apache.nifi.minifi.commons.status.instance.InstanceStats) InstanceStatus(org.apache.nifi.minifi.commons.status.instance.InstanceStatus) InstanceHealth(org.apache.nifi.minifi.commons.status.instance.InstanceHealth)

Aggregations

InstanceHealth (org.apache.nifi.minifi.commons.status.instance.InstanceHealth)2 InstanceStats (org.apache.nifi.minifi.commons.status.instance.InstanceStats)2 InstanceStatus (org.apache.nifi.minifi.commons.status.instance.InstanceStatus)2 Date (java.util.Date)1 BulletinStatus (org.apache.nifi.minifi.commons.status.common.BulletinStatus)1 Bulletin (org.apache.nifi.reporting.Bulletin)1