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;
}
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;
}
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);
}
Aggregations