Search in sources :

Example 1 with RemoteProcessGroupStatusBean

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

the class StatusConfigReporter method getStatus.

public static FlowStatusReport getStatus(FlowController flowController, String statusRequest, Logger logger) throws StatusRequestException {
    if (statusRequest == null) {
        logger.error("Received a status request which was null");
        throw new StatusRequestException("Cannot complete status request because the statusRequest is null");
    }
    if (flowController == null) {
        logger.error("Received a status but the Flow Controller is null");
        throw new StatusRequestException("Cannot complete status request because the Flow Controller is null");
    }
    FlowStatusReport flowStatusReport = new FlowStatusReport();
    List<String> errorsGeneratingReport = new LinkedList<>();
    flowStatusReport.setErrorsGeneratingReport(errorsGeneratingReport);
    String[] itemsToReport = statusRequest.split(";");
    ProcessGroupStatus rootGroupStatus = flowController.getControllerStatus();
    Map<String, ProcessorStatus> processorStatusMap = null;
    Map<String, ConnectionStatus> connectionStatusMap = null;
    Map<String, RemoteProcessGroupStatus> remoteProcessGroupStatusMap = null;
    for (String item : itemsToReport) {
        String[] sections = item.split(":");
        try {
            switch(sections[0].toLowerCase().trim()) {
                case "systemdiagnostics":
                    SystemDiagnosticsStatus systemDiagnosticsStatus = parseSystemDiagnosticsRequest(flowController.getSystemDiagnostics(), sections[1]);
                    flowStatusReport.setSystemDiagnosticsStatus(systemDiagnosticsStatus);
                    break;
                case "instance":
                    InstanceStatus instanceStatus = parseInstanceRequest(sections[1], flowController, rootGroupStatus);
                    flowStatusReport.setInstanceStatus(instanceStatus);
                    break;
                case "remoteprocessgroup":
                    if (flowStatusReport.getRemoteProcessGroupStatusList() == null) {
                        List<RemoteProcessGroupStatusBean> remoteProcessGroupStatusList = new LinkedList<>();
                        flowStatusReport.setRemoteProcessGroupStatusList(remoteProcessGroupStatusList);
                    }
                    handleRemoteProcessGroupRequest(sections, rootGroupStatus, flowController, flowStatusReport.getRemoteProcessGroupStatusList(), remoteProcessGroupStatusMap, logger);
                    break;
                case "processor":
                    if (flowStatusReport.getProcessorStatusList() == null) {
                        List<ProcessorStatusBean> processorStatusList = new LinkedList<>();
                        flowStatusReport.setProcessorStatusList(processorStatusList);
                    }
                    handleProcessorRequest(sections, rootGroupStatus, flowController, flowStatusReport.getProcessorStatusList(), processorStatusMap, logger);
                    break;
                case "connection":
                    if (flowStatusReport.getConnectionStatusList() == null) {
                        List<ConnectionStatusBean> connectionStatusList = new LinkedList<>();
                        flowStatusReport.setConnectionStatusList(connectionStatusList);
                    }
                    handleConnectionRequest(sections, rootGroupStatus, flowStatusReport.getConnectionStatusList(), connectionStatusMap, logger);
                    break;
                case "provenancereporting":
                    if (flowStatusReport.getRemoteProcessGroupStatusList() == null) {
                        List<ReportingTaskStatus> reportingTaskStatusList = new LinkedList<>();
                        flowStatusReport.setReportingTaskStatusList(reportingTaskStatusList);
                    }
                    handleReportingTaskRequest(sections, flowController, flowStatusReport.getReportingTaskStatusList(), logger);
                    break;
                case "controllerservices":
                    if (flowStatusReport.getControllerServiceStatusList() == null) {
                        List<ControllerServiceStatus> controllerServiceStatusList = new LinkedList<>();
                        flowStatusReport.setControllerServiceStatusList(controllerServiceStatusList);
                    }
                    handleControllerServices(sections, flowController, flowStatusReport.getControllerServiceStatusList(), logger);
                    break;
            }
        } catch (Exception e) {
            logger.error("Hit exception while requesting status for item '" + item + "'", e);
            errorsGeneratingReport.add("Unable to get status for request '" + item + "' due to:" + e);
        }
    }
    return flowStatusReport;
}
Also used : ConnectionStatusBean(org.apache.nifi.minifi.commons.status.connection.ConnectionStatusBean) InstanceStatus(org.apache.nifi.minifi.commons.status.instance.InstanceStatus) ProcessorStatusBean(org.apache.nifi.minifi.commons.status.processor.ProcessorStatusBean) ConnectionStatus(org.apache.nifi.controller.status.ConnectionStatus) ReportingTaskStatus(org.apache.nifi.minifi.commons.status.reportingTask.ReportingTaskStatus) ProcessGroupStatus(org.apache.nifi.controller.status.ProcessGroupStatus) RemoteProcessGroupStatus(org.apache.nifi.controller.status.RemoteProcessGroupStatus) FlowStatusReport(org.apache.nifi.minifi.commons.status.FlowStatusReport) RemoteProcessGroupStatus(org.apache.nifi.controller.status.RemoteProcessGroupStatus) ProcessorStatus(org.apache.nifi.controller.status.ProcessorStatus) LinkedList(java.util.LinkedList) RemoteProcessGroupStatusBean(org.apache.nifi.minifi.commons.status.rpg.RemoteProcessGroupStatusBean) ControllerServiceStatus(org.apache.nifi.minifi.commons.status.controllerservice.ControllerServiceStatus) SystemDiagnosticsStatus(org.apache.nifi.minifi.commons.status.system.SystemDiagnosticsStatus)

Example 2 with RemoteProcessGroupStatusBean

use of org.apache.nifi.minifi.commons.status.rpg.RemoteProcessGroupStatusBean 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 3 with RemoteProcessGroupStatusBean

use of org.apache.nifi.minifi.commons.status.rpg.RemoteProcessGroupStatusBean 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

RemoteProcessGroupStatusBean (org.apache.nifi.minifi.commons.status.rpg.RemoteProcessGroupStatusBean)3 RemoteProcessGroupHealth (org.apache.nifi.minifi.commons.status.rpg.RemoteProcessGroupHealth)2 RemoteProcessGroupStats (org.apache.nifi.minifi.commons.status.rpg.RemoteProcessGroupStats)2 Date (java.util.Date)1 LinkedList (java.util.LinkedList)1 ConnectionStatus (org.apache.nifi.controller.status.ConnectionStatus)1 ProcessGroupStatus (org.apache.nifi.controller.status.ProcessGroupStatus)1 ProcessorStatus (org.apache.nifi.controller.status.ProcessorStatus)1 RemoteProcessGroupStatus (org.apache.nifi.controller.status.RemoteProcessGroupStatus)1 FlowStatusReport (org.apache.nifi.minifi.commons.status.FlowStatusReport)1 BulletinStatus (org.apache.nifi.minifi.commons.status.common.BulletinStatus)1 ConnectionStatusBean (org.apache.nifi.minifi.commons.status.connection.ConnectionStatusBean)1 ControllerServiceStatus (org.apache.nifi.minifi.commons.status.controllerservice.ControllerServiceStatus)1 InstanceStatus (org.apache.nifi.minifi.commons.status.instance.InstanceStatus)1 ProcessorStatusBean (org.apache.nifi.minifi.commons.status.processor.ProcessorStatusBean)1 ReportingTaskStatus (org.apache.nifi.minifi.commons.status.reportingTask.ReportingTaskStatus)1 PortStatus (org.apache.nifi.minifi.commons.status.rpg.PortStatus)1 SystemDiagnosticsStatus (org.apache.nifi.minifi.commons.status.system.SystemDiagnosticsStatus)1 Bulletin (org.apache.nifi.reporting.Bulletin)1 BulletinQuery (org.apache.nifi.reporting.BulletinQuery)1