use of fish.payara.nucleus.healthcheck.configuration.CheckerConfigurationType in project Payara by payara.
the class GetHealthCheckConfiguration method addThresholdDiagnosticsCheckerExtraProps.
private void addThresholdDiagnosticsCheckerExtraProps(Properties thresholdDiagnosticsExtraProps, ThresholdDiagnosticsChecker thresholdDiagnosticsChecker) {
Map<String, Object> extraPropsMap = new HashMap<>(7);
extraPropsMap.put("checkerName", thresholdDiagnosticsChecker.getName());
extraPropsMap.put("enabled", thresholdDiagnosticsChecker.getEnabled());
extraPropsMap.put("time", thresholdDiagnosticsChecker.getTime());
extraPropsMap.put("unit", thresholdDiagnosticsChecker.getUnit());
if (thresholdDiagnosticsChecker.getProperty(THRESHOLD_CRITICAL) != null) {
extraPropsMap.put("thresholdCritical", thresholdDiagnosticsChecker.getProperty(THRESHOLD_CRITICAL).getValue());
}
if (thresholdDiagnosticsChecker.getProperty(THRESHOLD_WARNING) != null) {
extraPropsMap.put("thresholdWarning", thresholdDiagnosticsChecker.getProperty(THRESHOLD_WARNING).getValue());
}
if (thresholdDiagnosticsChecker.getProperty(THRESHOLD_GOOD) != null) {
extraPropsMap.put("thresholdGood", thresholdDiagnosticsChecker.getProperty(THRESHOLD_GOOD).getValue());
}
// Get the checker type
ConfigView view = ConfigSupport.getImpl(thresholdDiagnosticsChecker);
CheckerConfigurationType annotation = view.getProxyType().getAnnotation(CheckerConfigurationType.class);
// Add the extraPropsMap as a property with a name matching its checker type
switch(annotation.type()) {
case CONNECTION_POOL:
thresholdDiagnosticsExtraProps.put(connectionPoolPropertyName, extraPropsMap);
break;
case CPU_USAGE:
thresholdDiagnosticsExtraProps.put(cpuUsagePropertyName, extraPropsMap);
break;
case GARBAGE_COLLECTOR:
thresholdDiagnosticsExtraProps.put(garbageCollectorPropertyName, extraPropsMap);
break;
case HEAP_MEMORY_USAGE:
thresholdDiagnosticsExtraProps.put(heapMemoryUsagePropertyName, extraPropsMap);
break;
case MACHINE_MEMORY_USAGE:
thresholdDiagnosticsExtraProps.put(machineMemoryUsagePropertyName, extraPropsMap);
break;
case STUCK_THREAD:
thresholdDiagnosticsExtraProps.put(stuckThreadsPropertyName, extraPropsMap);
break;
}
}
Aggregations