Search in sources :

Example 1 with RemoteProcessGroupHealth

use of org.apache.nifi.minifi.commons.status.rpg.RemoteProcessGroupHealth in project nifi-minifi by apache.

the class StatusReportPopulator method addExpectedRemoteProcessGroupStatus.

public static void addExpectedRemoteProcessGroupStatus(FlowStatusReport flowStatusReport, boolean addHealth, boolean addInputPort, boolean addOutputPort, boolean addStats, boolean addBulletins, boolean populateBulletins) {
    RemoteProcessGroupStatusBean expectedRemoteProcessGroupStatus = new RemoteProcessGroupStatusBean();
    expectedRemoteProcessGroupStatus.setName("rpg1");
    if (addHealth) {
        RemoteProcessGroupHealth remoteProcessGroupHealth = new RemoteProcessGroupHealth();
        remoteProcessGroupHealth.setTransmissionStatus("Transmitting");
        remoteProcessGroupHealth.setHasBulletins(populateBulletins);
        remoteProcessGroupHealth.setActivePortCount(1);
        remoteProcessGroupHealth.setInactivePortCount(2);
        expectedRemoteProcessGroupStatus.setRemoteProcessGroupHealth(remoteProcessGroupHealth);
    }
    if (addBulletins) {
        if (populateBulletins) {
            BulletinStatus bulletinStatus = new BulletinStatus();
            bulletinStatus.setMessage("Bulletin message");
            bulletinStatus.setTimestamp(new Date(1464019245000L));
            expectedRemoteProcessGroupStatus.setBulletinList(Collections.singletonList(bulletinStatus));
        } else {
            expectedRemoteProcessGroupStatus.setBulletinList(Collections.EMPTY_LIST);
        }
    }
    if (addInputPort) {
        PortStatus expectedInputPortStatus = new PortStatus();
        expectedInputPortStatus.setName("inputPort");
        expectedInputPortStatus.setTargetExists(true);
        expectedInputPortStatus.setTargetRunning(false);
        expectedRemoteProcessGroupStatus.setInputPortStatusList(Collections.singletonList(expectedInputPortStatus));
    }
    if (addOutputPort) {
        PortStatus expectedOutputPortStatus = new PortStatus();
        expectedOutputPortStatus.setName("outputPort");
        expectedOutputPortStatus.setTargetExists(true);
        expectedOutputPortStatus.setTargetRunning(false);
        expectedRemoteProcessGroupStatus.setOutputPortStatusList(Collections.singletonList(expectedOutputPortStatus));
    }
    if (addStats) {
        RemoteProcessGroupStats remoteProcessGroupStats = new RemoteProcessGroupStats();
        remoteProcessGroupStats.setActiveThreads(3);
        remoteProcessGroupStats.setSentContentSize(4L);
        remoteProcessGroupStats.setSentCount(5);
        expectedRemoteProcessGroupStatus.setRemoteProcessGroupStats(remoteProcessGroupStats);
    }
    flowStatusReport.setRemoteProcessGroupStatusList(Collections.singletonList(expectedRemoteProcessGroupStatus));
}
Also used : RemoteProcessGroupStatusBean(org.apache.nifi.minifi.commons.status.rpg.RemoteProcessGroupStatusBean) RemoteProcessGroupStats(org.apache.nifi.minifi.commons.status.rpg.RemoteProcessGroupStats) PortStatus(org.apache.nifi.minifi.commons.status.rpg.PortStatus) RemoteProcessGroupHealth(org.apache.nifi.minifi.commons.status.rpg.RemoteProcessGroupHealth) BulletinStatus(org.apache.nifi.minifi.commons.status.common.BulletinStatus) Date(java.util.Date)

Example 2 with RemoteProcessGroupHealth

use of org.apache.nifi.minifi.commons.status.rpg.RemoteProcessGroupHealth in project nifi-minifi by apache.

the class StatusRequestParser method parseRemoteProcessGroupStatusRequest.

static RemoteProcessGroupStatusBean parseRemoteProcessGroupStatusRequest(RemoteProcessGroupStatus inputRemoteProcessGroupStatus, String statusTypes, FlowController flowController) {
    RemoteProcessGroupStatusBean remoteProcessGroupStatusBean = new RemoteProcessGroupStatusBean();
    remoteProcessGroupStatusBean.setName(inputRemoteProcessGroupStatus.getName());
    String rootGroupId = flowController.getRootGroupId();
    String[] statusSplits = statusTypes.split(",");
    List<Bulletin> bulletinList = flowController.getBulletinRepository().findBulletins(new BulletinQuery.Builder().sourceIdMatches(inputRemoteProcessGroupStatus.getId()).build());
    for (String statusType : statusSplits) {
        switch(statusType.toLowerCase().trim()) {
            case "health":
                RemoteProcessGroupHealth remoteProcessGroupHealth = new RemoteProcessGroupHealth();
                remoteProcessGroupHealth.setTransmissionStatus(inputRemoteProcessGroupStatus.getTransmissionStatus().name());
                remoteProcessGroupHealth.setActivePortCount(inputRemoteProcessGroupStatus.getActiveRemotePortCount());
                remoteProcessGroupHealth.setInactivePortCount(inputRemoteProcessGroupStatus.getInactiveRemotePortCount());
                remoteProcessGroupHealth.setHasBulletins(!bulletinList.isEmpty());
                remoteProcessGroupStatusBean.setRemoteProcessGroupHealth(remoteProcessGroupHealth);
                break;
            case "bulletins":
                remoteProcessGroupStatusBean.setBulletinList(transformBulletins(bulletinList));
                break;
            case "inputports":
                remoteProcessGroupStatusBean.setInputPortStatusList(getPortStatusList(inputRemoteProcessGroupStatus, flowController, rootGroupId, RemoteProcessGroup::getInputPorts));
                break;
            case "outputports":
                remoteProcessGroupStatusBean.setOutputPortStatusList(getPortStatusList(inputRemoteProcessGroupStatus, flowController, rootGroupId, RemoteProcessGroup::getOutputPorts));
                break;
            case "stats":
                RemoteProcessGroupStats remoteProcessGroupStats = new RemoteProcessGroupStats();
                remoteProcessGroupStats.setActiveThreads(inputRemoteProcessGroupStatus.getActiveThreadCount());
                remoteProcessGroupStats.setSentContentSize(inputRemoteProcessGroupStatus.getSentContentSize());
                remoteProcessGroupStats.setSentCount(inputRemoteProcessGroupStatus.getSentCount());
                remoteProcessGroupStatusBean.setRemoteProcessGroupStats(remoteProcessGroupStats);
                break;
        }
    }
    return remoteProcessGroupStatusBean;
}
Also used : RemoteProcessGroupStatusBean(org.apache.nifi.minifi.commons.status.rpg.RemoteProcessGroupStatusBean) Bulletin(org.apache.nifi.reporting.Bulletin) RemoteProcessGroupStats(org.apache.nifi.minifi.commons.status.rpg.RemoteProcessGroupStats) BulletinQuery(org.apache.nifi.reporting.BulletinQuery) RemoteProcessGroupHealth(org.apache.nifi.minifi.commons.status.rpg.RemoteProcessGroupHealth)

Aggregations

RemoteProcessGroupHealth (org.apache.nifi.minifi.commons.status.rpg.RemoteProcessGroupHealth)2 RemoteProcessGroupStats (org.apache.nifi.minifi.commons.status.rpg.RemoteProcessGroupStats)2 RemoteProcessGroupStatusBean (org.apache.nifi.minifi.commons.status.rpg.RemoteProcessGroupStatusBean)2 Date (java.util.Date)1 BulletinStatus (org.apache.nifi.minifi.commons.status.common.BulletinStatus)1 PortStatus (org.apache.nifi.minifi.commons.status.rpg.PortStatus)1 Bulletin (org.apache.nifi.reporting.Bulletin)1 BulletinQuery (org.apache.nifi.reporting.BulletinQuery)1