Search in sources :

Example 1 with SystemProcessorStats

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

use of org.apache.nifi.minifi.commons.status.system.SystemProcessorStats 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)2 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 SystemDiagnosticsStatus (org.apache.nifi.minifi.commons.status.system.SystemDiagnosticsStatus)2 SystemProcessorStats (org.apache.nifi.minifi.commons.status.system.SystemProcessorStats)2 Map (java.util.Map)1 GarbageCollection (org.apache.nifi.diagnostics.GarbageCollection)1 StorageUsage (org.apache.nifi.diagnostics.StorageUsage)1