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