Search in sources :

Example 1 with SystemDiagnosticsStatus

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

use of org.apache.nifi.minifi.commons.status.system.SystemDiagnosticsStatus in project nifi-minifi by apache.

the class StatusRequestParser method parseSystemDiagnosticsRequest.

static SystemDiagnosticsStatus parseSystemDiagnosticsRequest(SystemDiagnostics inputSystemDiagnostics, String statusTypes) throws StatusRequestException {
    if (inputSystemDiagnostics == null) {
        throw new StatusRequestException("Unable to get system diagnostics");
    }
    SystemDiagnosticsStatus systemDiagnosticsStatus = new SystemDiagnosticsStatus();
    String[] statusSplits = statusTypes.split(",");
    for (String statusType : statusSplits) {
        switch(statusType.toLowerCase().trim()) {
            case "heap":
                HeapStatus heapStatus = new HeapStatus();
                heapStatus.setTotalHeap(inputSystemDiagnostics.getTotalHeap());
                heapStatus.setMaxHeap(inputSystemDiagnostics.getMaxHeap());
                heapStatus.setFreeHeap(inputSystemDiagnostics.getFreeHeap());
                heapStatus.setUsedHeap(inputSystemDiagnostics.getUsedHeap());
                heapStatus.setHeapUtilization(inputSystemDiagnostics.getHeapUtilization());
                heapStatus.setTotalNonHeap(inputSystemDiagnostics.getTotalNonHeap());
                heapStatus.setMaxNonHeap(inputSystemDiagnostics.getMaxNonHeap());
                heapStatus.setFreeNonHeap(inputSystemDiagnostics.getFreeNonHeap());
                heapStatus.setUsedNonHeap(inputSystemDiagnostics.getUsedNonHeap());
                heapStatus.setNonHeapUtilization(inputSystemDiagnostics.getNonHeapUtilization());
                systemDiagnosticsStatus.setHeapStatus(heapStatus);
                break;
            case "processorstats":
                SystemProcessorStats systemProcessorStats = new SystemProcessorStats();
                systemProcessorStats.setAvailableProcessors(inputSystemDiagnostics.getAvailableProcessors());
                systemProcessorStats.setLoadAverage(inputSystemDiagnostics.getProcessorLoadAverage());
                systemDiagnosticsStatus.setProcessorStatus(systemProcessorStats);
                break;
            case "contentrepositoryusage":
                List<ContentRepositoryUsage> contentRepositoryUsageList = new LinkedList<>();
                Map<String, StorageUsage> contentRepoStorage = inputSystemDiagnostics.getContentRepositoryStorageUsage();
                for (Map.Entry<String, StorageUsage> stringStorageUsageEntry : contentRepoStorage.entrySet()) {
                    ContentRepositoryUsage contentRepositoryUsage = new ContentRepositoryUsage();
                    StorageUsage storageUsage = stringStorageUsageEntry.getValue();
                    contentRepositoryUsage.setName(storageUsage.getIdentifier());
                    contentRepositoryUsage.setFreeSpace(storageUsage.getFreeSpace());
                    contentRepositoryUsage.setTotalSpace(storageUsage.getTotalSpace());
                    contentRepositoryUsage.setDiskUtilization(storageUsage.getDiskUtilization());
                    contentRepositoryUsage.setUsedSpace(storageUsage.getUsedSpace());
                    contentRepositoryUsageList.add(contentRepositoryUsage);
                }
                systemDiagnosticsStatus.setContentRepositoryUsageList(contentRepositoryUsageList);
                break;
            case "flowfilerepositoryusage":
                FlowfileRepositoryUsage flowfileRepositoryUsage = new FlowfileRepositoryUsage();
                StorageUsage flowFileRepoStorage = inputSystemDiagnostics.getFlowFileRepositoryStorageUsage();
                flowfileRepositoryUsage.setFreeSpace(flowFileRepoStorage.getFreeSpace());
                flowfileRepositoryUsage.setTotalSpace(flowFileRepoStorage.getTotalSpace());
                flowfileRepositoryUsage.setDiskUtilization(flowFileRepoStorage.getDiskUtilization());
                flowfileRepositoryUsage.setUsedSpace(flowFileRepoStorage.getUsedSpace());
                systemDiagnosticsStatus.setFlowfileRepositoryUsage(flowfileRepositoryUsage);
                break;
            case "garbagecollection":
                List<GarbageCollectionStatus> garbageCollectionStatusList = new LinkedList<>();
                Map<String, GarbageCollection> garbageCollectionMap = inputSystemDiagnostics.getGarbageCollection();
                for (Map.Entry<String, GarbageCollection> stringGarbageCollectionEntry : garbageCollectionMap.entrySet()) {
                    GarbageCollectionStatus garbageCollectionStatus = new GarbageCollectionStatus();
                    GarbageCollection garbageCollection = stringGarbageCollectionEntry.getValue();
                    garbageCollectionStatus.setName(garbageCollection.getName());
                    garbageCollectionStatus.setCollectionCount(garbageCollection.getCollectionCount());
                    garbageCollectionStatus.setCollectionTime(garbageCollection.getCollectionTime());
                    garbageCollectionStatusList.add(garbageCollectionStatus);
                }
                systemDiagnosticsStatus.setGarbageCollectionStatusList(garbageCollectionStatusList);
                break;
        }
    }
    return systemDiagnosticsStatus;
}
Also used : SystemProcessorStats(org.apache.nifi.minifi.commons.status.system.SystemProcessorStats) ContentRepositoryUsage(org.apache.nifi.minifi.commons.status.system.ContentRepositoryUsage) GarbageCollectionStatus(org.apache.nifi.minifi.commons.status.system.GarbageCollectionStatus) GarbageCollection(org.apache.nifi.diagnostics.GarbageCollection) LinkedList(java.util.LinkedList) FlowfileRepositoryUsage(org.apache.nifi.minifi.commons.status.system.FlowfileRepositoryUsage) SystemDiagnosticsStatus(org.apache.nifi.minifi.commons.status.system.SystemDiagnosticsStatus) HeapStatus(org.apache.nifi.minifi.commons.status.system.HeapStatus) StorageUsage(org.apache.nifi.diagnostics.StorageUsage) Map(java.util.Map)

Example 3 with SystemDiagnosticsStatus

use of org.apache.nifi.minifi.commons.status.system.SystemDiagnosticsStatus in project nifi-minifi by apache.

the class StatusReportPopulator method addSystemDiagnosticStatus.

public static void addSystemDiagnosticStatus(FlowStatusReport flowStatusReport, boolean addHeap, boolean addProcessorStats, boolean addFlowFileRepoUsage, boolean addContentRepoUsage, boolean addGarbageCollectionStatus) {
    SystemDiagnosticsStatus expectedSystemDiagnosticStatus = new SystemDiagnosticsStatus();
    if (addHeap) {
        HeapStatus heapStatus = new HeapStatus();
        heapStatus.setMaxHeap(5);
        heapStatus.setTotalHeap(3);
        heapStatus.setUsedHeap(2);
        heapStatus.setFreeHeap(1);
        heapStatus.setHeapUtilization(40);
        heapStatus.setMaxNonHeap(9);
        heapStatus.setTotalNonHeap(8);
        heapStatus.setUsedNonHeap(6);
        heapStatus.setFreeNonHeap(2);
        heapStatus.setNonHeapUtilization(67);
        expectedSystemDiagnosticStatus.setHeapStatus(heapStatus);
    }
    if (addProcessorStats) {
        SystemProcessorStats systemProcessorStats = new SystemProcessorStats();
        systemProcessorStats.setLoadAverage(80.9);
        systemProcessorStats.setAvailableProcessors(5);
        expectedSystemDiagnosticStatus.setProcessorStatus(systemProcessorStats);
    }
    if (addFlowFileRepoUsage) {
        FlowfileRepositoryUsage flowfileRepositoryUsage = new FlowfileRepositoryUsage();
        flowfileRepositoryUsage.setFreeSpace(30);
        flowfileRepositoryUsage.setTotalSpace(100);
        flowfileRepositoryUsage.setUsedSpace(70);
        flowfileRepositoryUsage.setDiskUtilization(70);
        expectedSystemDiagnosticStatus.setFlowfileRepositoryUsage(flowfileRepositoryUsage);
    }
    if (addContentRepoUsage) {
        List<ContentRepositoryUsage> contentRepositoryUsageList = new LinkedList<>();
        ContentRepositoryUsage contentRepositoryUsage = new ContentRepositoryUsage();
        contentRepositoryUsage.setFreeSpace(30);
        contentRepositoryUsage.setTotalSpace(100);
        contentRepositoryUsage.setName("Content repo1");
        contentRepositoryUsage.setUsedSpace(70);
        contentRepositoryUsage.setDiskUtilization(70);
        contentRepositoryUsageList.add(contentRepositoryUsage);
        expectedSystemDiagnosticStatus.setContentRepositoryUsageList(contentRepositoryUsageList);
    }
    if (addGarbageCollectionStatus) {
        List<GarbageCollectionStatus> garbageCollectionStatusList = new LinkedList<>();
        GarbageCollectionStatus garbageCollectionStatus1 = new GarbageCollectionStatus();
        garbageCollectionStatus1.setCollectionCount(1);
        garbageCollectionStatus1.setCollectionTime(10);
        garbageCollectionStatus1.setName("garbage 1");
        garbageCollectionStatusList.add(garbageCollectionStatus1);
        expectedSystemDiagnosticStatus.setGarbageCollectionStatusList(garbageCollectionStatusList);
    }
    flowStatusReport.setSystemDiagnosticsStatus(expectedSystemDiagnosticStatus);
}
Also used : FlowfileRepositoryUsage(org.apache.nifi.minifi.commons.status.system.FlowfileRepositoryUsage) SystemProcessorStats(org.apache.nifi.minifi.commons.status.system.SystemProcessorStats) ContentRepositoryUsage(org.apache.nifi.minifi.commons.status.system.ContentRepositoryUsage) SystemDiagnosticsStatus(org.apache.nifi.minifi.commons.status.system.SystemDiagnosticsStatus) HeapStatus(org.apache.nifi.minifi.commons.status.system.HeapStatus) GarbageCollectionStatus(org.apache.nifi.minifi.commons.status.system.GarbageCollectionStatus) LinkedList(java.util.LinkedList)

Aggregations

LinkedList (java.util.LinkedList)3 SystemDiagnosticsStatus (org.apache.nifi.minifi.commons.status.system.SystemDiagnosticsStatus)3 ContentRepositoryUsage (org.apache.nifi.minifi.commons.status.system.ContentRepositoryUsage)2 FlowfileRepositoryUsage (org.apache.nifi.minifi.commons.status.system.FlowfileRepositoryUsage)2 GarbageCollectionStatus (org.apache.nifi.minifi.commons.status.system.GarbageCollectionStatus)2 HeapStatus (org.apache.nifi.minifi.commons.status.system.HeapStatus)2 SystemProcessorStats (org.apache.nifi.minifi.commons.status.system.SystemProcessorStats)2 Map (java.util.Map)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 GarbageCollection (org.apache.nifi.diagnostics.GarbageCollection)1 StorageUsage (org.apache.nifi.diagnostics.StorageUsage)1 FlowStatusReport (org.apache.nifi.minifi.commons.status.FlowStatusReport)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