Search in sources :

Example 1 with GarbageCollection

use of org.apache.nifi.diagnostics.GarbageCollection in project nifi by apache.

the class DtoFactory method createSystemDiagnosticsDto.

/**
 * Creates a SystemDiagnosticsDTO for the specified SystemDiagnostics.
 *
 * @param sysDiagnostics diags
 * @return dto
 */
public SystemDiagnosticsDTO createSystemDiagnosticsDto(final SystemDiagnostics sysDiagnostics) {
    final SystemDiagnosticsDTO dto = new SystemDiagnosticsDTO();
    final SystemDiagnosticsSnapshotDTO snapshot = new SystemDiagnosticsSnapshotDTO();
    dto.setAggregateSnapshot(snapshot);
    snapshot.setStatsLastRefreshed(new Date(sysDiagnostics.getCreationTimestamp()));
    // processors
    snapshot.setAvailableProcessors(sysDiagnostics.getAvailableProcessors());
    snapshot.setProcessorLoadAverage(sysDiagnostics.getProcessorLoadAverage());
    // threads
    snapshot.setDaemonThreads(sysDiagnostics.getDaemonThreads());
    snapshot.setTotalThreads(sysDiagnostics.getTotalThreads());
    // heap
    snapshot.setMaxHeap(FormatUtils.formatDataSize(sysDiagnostics.getMaxHeap()));
    snapshot.setMaxHeapBytes(sysDiagnostics.getMaxHeap());
    snapshot.setTotalHeap(FormatUtils.formatDataSize(sysDiagnostics.getTotalHeap()));
    snapshot.setTotalHeapBytes(sysDiagnostics.getTotalHeap());
    snapshot.setUsedHeap(FormatUtils.formatDataSize(sysDiagnostics.getUsedHeap()));
    snapshot.setUsedHeapBytes(sysDiagnostics.getUsedHeap());
    snapshot.setFreeHeap(FormatUtils.formatDataSize(sysDiagnostics.getFreeHeap()));
    snapshot.setFreeHeapBytes(sysDiagnostics.getFreeHeap());
    if (sysDiagnostics.getHeapUtilization() != -1) {
        snapshot.setHeapUtilization(FormatUtils.formatUtilization(sysDiagnostics.getHeapUtilization()));
    }
    // non heap
    snapshot.setMaxNonHeap(FormatUtils.formatDataSize(sysDiagnostics.getMaxNonHeap()));
    snapshot.setMaxNonHeapBytes(sysDiagnostics.getMaxNonHeap());
    snapshot.setTotalNonHeap(FormatUtils.formatDataSize(sysDiagnostics.getTotalNonHeap()));
    snapshot.setTotalNonHeapBytes(sysDiagnostics.getTotalNonHeap());
    snapshot.setUsedNonHeap(FormatUtils.formatDataSize(sysDiagnostics.getUsedNonHeap()));
    snapshot.setUsedNonHeapBytes(sysDiagnostics.getUsedNonHeap());
    snapshot.setFreeNonHeap(FormatUtils.formatDataSize(sysDiagnostics.getFreeNonHeap()));
    snapshot.setFreeNonHeapBytes(sysDiagnostics.getFreeNonHeap());
    if (sysDiagnostics.getNonHeapUtilization() != -1) {
        snapshot.setNonHeapUtilization(FormatUtils.formatUtilization(sysDiagnostics.getNonHeapUtilization()));
    }
    // flow file disk usage
    final SystemDiagnosticsSnapshotDTO.StorageUsageDTO flowFileRepositoryStorageUsageDto = createStorageUsageDTO(null, sysDiagnostics.getFlowFileRepositoryStorageUsage());
    snapshot.setFlowFileRepositoryStorageUsage(flowFileRepositoryStorageUsageDto);
    // content disk usage
    final Set<SystemDiagnosticsSnapshotDTO.StorageUsageDTO> contentRepositoryStorageUsageDtos = new LinkedHashSet<>();
    snapshot.setContentRepositoryStorageUsage(contentRepositoryStorageUsageDtos);
    for (final Map.Entry<String, StorageUsage> entry : sysDiagnostics.getContentRepositoryStorageUsage().entrySet()) {
        contentRepositoryStorageUsageDtos.add(createStorageUsageDTO(entry.getKey(), entry.getValue()));
    }
    // provenance disk usage
    final Set<SystemDiagnosticsSnapshotDTO.StorageUsageDTO> provenanceRepositoryStorageUsageDtos = new LinkedHashSet<>();
    snapshot.setProvenanceRepositoryStorageUsage(provenanceRepositoryStorageUsageDtos);
    for (final Map.Entry<String, StorageUsage> entry : sysDiagnostics.getProvenanceRepositoryStorageUsage().entrySet()) {
        provenanceRepositoryStorageUsageDtos.add(createStorageUsageDTO(entry.getKey(), entry.getValue()));
    }
    // garbage collection
    final Set<SystemDiagnosticsSnapshotDTO.GarbageCollectionDTO> garbageCollectionDtos = new LinkedHashSet<>();
    snapshot.setGarbageCollection(garbageCollectionDtos);
    for (final Map.Entry<String, GarbageCollection> entry : sysDiagnostics.getGarbageCollection().entrySet()) {
        garbageCollectionDtos.add(createGarbageCollectionDTO(entry.getKey(), entry.getValue()));
    }
    // version info
    final SystemDiagnosticsSnapshotDTO.VersionInfoDTO versionInfoDto = createVersionInfoDTO();
    snapshot.setVersionInfo(versionInfoDto);
    // uptime
    snapshot.setUptime(FormatUtils.formatHoursMinutesSeconds(sysDiagnostics.getUptime(), TimeUnit.MILLISECONDS));
    return dto;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) GarbageCollection(org.apache.nifi.diagnostics.GarbageCollection) Date(java.util.Date) JVMSystemDiagnosticsSnapshotDTO(org.apache.nifi.web.api.dto.diagnostics.JVMSystemDiagnosticsSnapshotDTO) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) TreeMap(java.util.TreeMap) StateMap(org.apache.nifi.components.state.StateMap) HashMap(java.util.HashMap) StorageUsage(org.apache.nifi.diagnostics.StorageUsage)

Example 2 with GarbageCollection

use of org.apache.nifi.diagnostics.GarbageCollection 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 GarbageCollection

use of org.apache.nifi.diagnostics.GarbageCollection in project nifi-minifi by apache.

the class StatusConfigReporterTest method addGarbageCollectionToSystemDiagnostics.

private void addGarbageCollectionToSystemDiagnostics(SystemDiagnostics systemDiagnostics) {
    Map<String, GarbageCollection> garbageCollectionMap = new HashMap<>();
    GarbageCollection garbageCollection1 = new GarbageCollection();
    garbageCollection1.setCollectionCount(1);
    garbageCollection1.setCollectionTime(10);
    garbageCollection1.setName("garbage 1");
    garbageCollectionMap.put(garbageCollection1.getName(), garbageCollection1);
    systemDiagnostics.setGarbageCollection(garbageCollectionMap);
}
Also used : HashMap(java.util.HashMap) GarbageCollection(org.apache.nifi.diagnostics.GarbageCollection)

Aggregations

GarbageCollection (org.apache.nifi.diagnostics.GarbageCollection)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 StorageUsage (org.apache.nifi.diagnostics.StorageUsage)2 Date (java.util.Date)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 LinkedList (java.util.LinkedList)1 TreeMap (java.util.TreeMap)1 StateMap (org.apache.nifi.components.state.StateMap)1 ContentRepositoryUsage (org.apache.nifi.minifi.commons.status.system.ContentRepositoryUsage)1 FlowfileRepositoryUsage (org.apache.nifi.minifi.commons.status.system.FlowfileRepositoryUsage)1 GarbageCollectionStatus (org.apache.nifi.minifi.commons.status.system.GarbageCollectionStatus)1 HeapStatus (org.apache.nifi.minifi.commons.status.system.HeapStatus)1 SystemDiagnosticsStatus (org.apache.nifi.minifi.commons.status.system.SystemDiagnosticsStatus)1 SystemProcessorStats (org.apache.nifi.minifi.commons.status.system.SystemProcessorStats)1 JVMSystemDiagnosticsSnapshotDTO (org.apache.nifi.web.api.dto.diagnostics.JVMSystemDiagnosticsSnapshotDTO)1