Search in sources :

Example 1 with ProcessorStatusBean

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

use of org.apache.nifi.minifi.commons.status.processor.ProcessorStatusBean in project nifi-minifi by apache.

the class StatusRequestParser method parseProcessorStatusRequest.

static ProcessorStatusBean parseProcessorStatusRequest(ProcessorStatus inputProcessorStatus, String statusTypes, FlowController flowController, Collection<ValidationResult> validationResults) {
    ProcessorStatusBean processorStatusBean = new ProcessorStatusBean();
    processorStatusBean.setName(inputProcessorStatus.getName());
    String[] statusSplits = statusTypes.split(",");
    List<Bulletin> bulletinList = flowController.getBulletinRepository().findBulletins(new BulletinQuery.Builder().sourceIdMatches(inputProcessorStatus.getId()).build());
    for (String statusType : statusSplits) {
        switch(statusType.toLowerCase().trim()) {
            case "health":
                ProcessorHealth processorHealth = new ProcessorHealth();
                processorHealth.setRunStatus(inputProcessorStatus.getRunStatus().name());
                processorHealth.setHasBulletins(!bulletinList.isEmpty());
                processorHealth.setValidationErrorList(transformValidationResults(validationResults));
                processorStatusBean.setProcessorHealth(processorHealth);
                break;
            case "bulletins":
                processorStatusBean.setBulletinList(transformBulletins(bulletinList));
                break;
            case "stats":
                ProcessorStats processorStats = new ProcessorStats();
                processorStats.setActiveThreads(inputProcessorStatus.getActiveThreadCount());
                processorStats.setFlowfilesReceived(inputProcessorStatus.getFlowFilesReceived());
                processorStats.setBytesRead(inputProcessorStatus.getBytesRead());
                processorStats.setBytesWritten(inputProcessorStatus.getBytesWritten());
                processorStats.setFlowfilesSent(inputProcessorStatus.getFlowFilesSent());
                processorStats.setInvocations(inputProcessorStatus.getInvocations());
                processorStats.setProcessingNanos(inputProcessorStatus.getProcessingNanos());
                processorStatusBean.setProcessorStats(processorStats);
                break;
        }
    }
    return processorStatusBean;
}
Also used : Bulletin(org.apache.nifi.reporting.Bulletin) BulletinQuery(org.apache.nifi.reporting.BulletinQuery) ProcessorStatusBean(org.apache.nifi.minifi.commons.status.processor.ProcessorStatusBean) ProcessorHealth(org.apache.nifi.minifi.commons.status.processor.ProcessorHealth) ProcessorStats(org.apache.nifi.minifi.commons.status.processor.ProcessorStats) SystemProcessorStats(org.apache.nifi.minifi.commons.status.system.SystemProcessorStats)

Example 3 with ProcessorStatusBean

use of org.apache.nifi.minifi.commons.status.processor.ProcessorStatusBean in project nifi-minifi by apache.

the class StatusReportPopulator method addProcessorStatus.

public static void addProcessorStatus(FlowStatusReport flowStatusReport, boolean addHealth, boolean validationErrors, boolean addStats, boolean addBulletins, boolean populateBulletins) {
    ProcessorStatusBean expectedProcessorStatus = new ProcessorStatusBean();
    expectedProcessorStatus.setName("UpdateAttributeProcessorId");
    if (addHealth) {
        ProcessorHealth processorHealth = new ProcessorHealth();
        processorHealth.setHasBulletins(populateBulletins);
        processorHealth.setRunStatus("Stopped");
        if (validationErrors) {
            List<ValidationError> validationErrorList = new LinkedList<>();
            ValidationError validationError1 = new ValidationError();
            validationError1.setInput("input");
            validationError1.setSubject("subject");
            validationError1.setReason("is not valid");
            validationErrorList.add(validationError1);
            ValidationError validationError2 = new ValidationError();
            validationError2.setInput("input2");
            validationError2.setSubject("subject2");
            validationError2.setReason("is not valid too");
            validationErrorList.add(validationError2);
            processorHealth.setValidationErrorList(validationErrorList);
        } else {
            processorHealth.setValidationErrorList(Collections.EMPTY_LIST);
        }
        expectedProcessorStatus.setProcessorHealth(processorHealth);
    }
    if (addStats) {
        ProcessorStats expectedProcessorStats = new ProcessorStats();
        expectedProcessorStats.setActiveThreads(1);
        expectedProcessorStats.setFlowfilesReceived(2);
        expectedProcessorStats.setBytesRead(3);
        expectedProcessorStats.setBytesWritten(4);
        expectedProcessorStats.setFlowfilesSent(5);
        expectedProcessorStats.setInvocations(6);
        expectedProcessorStats.setProcessingNanos(7);
        expectedProcessorStatus.setProcessorStats(expectedProcessorStats);
    }
    if (addBulletins) {
        if (populateBulletins) {
            BulletinStatus bulletinStatus = new BulletinStatus();
            bulletinStatus.setMessage("Bulletin message");
            bulletinStatus.setTimestamp(new Date(1464019245000L));
            expectedProcessorStatus.setBulletinList(Collections.singletonList(bulletinStatus));
        } else {
            expectedProcessorStatus.setBulletinList(Collections.EMPTY_LIST);
        }
    }
    flowStatusReport.setProcessorStatusList(Collections.singletonList(expectedProcessorStatus));
}
Also used : ProcessorStatusBean(org.apache.nifi.minifi.commons.status.processor.ProcessorStatusBean) ValidationError(org.apache.nifi.minifi.commons.status.common.ValidationError) BulletinStatus(org.apache.nifi.minifi.commons.status.common.BulletinStatus) ProcessorHealth(org.apache.nifi.minifi.commons.status.processor.ProcessorHealth) LinkedList(java.util.LinkedList) Date(java.util.Date) ProcessorStats(org.apache.nifi.minifi.commons.status.processor.ProcessorStats) SystemProcessorStats(org.apache.nifi.minifi.commons.status.system.SystemProcessorStats)

Aggregations

ProcessorStatusBean (org.apache.nifi.minifi.commons.status.processor.ProcessorStatusBean)3 LinkedList (java.util.LinkedList)2 ProcessorHealth (org.apache.nifi.minifi.commons.status.processor.ProcessorHealth)2 ProcessorStats (org.apache.nifi.minifi.commons.status.processor.ProcessorStats)2 SystemProcessorStats (org.apache.nifi.minifi.commons.status.system.SystemProcessorStats)2 Date (java.util.Date)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 ValidationError (org.apache.nifi.minifi.commons.status.common.ValidationError)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 ReportingTaskStatus (org.apache.nifi.minifi.commons.status.reportingTask.ReportingTaskStatus)1 RemoteProcessGroupStatusBean (org.apache.nifi.minifi.commons.status.rpg.RemoteProcessGroupStatusBean)1 SystemDiagnosticsStatus (org.apache.nifi.minifi.commons.status.system.SystemDiagnosticsStatus)1 Bulletin (org.apache.nifi.reporting.Bulletin)1