Search in sources :

Example 1 with CheckerConfigurationType

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;
    }
}
Also used : HashMap(java.util.HashMap) ConfigView(org.jvnet.hk2.config.ConfigView) CheckerConfigurationType(fish.payara.nucleus.healthcheck.configuration.CheckerConfigurationType)

Aggregations

CheckerConfigurationType (fish.payara.nucleus.healthcheck.configuration.CheckerConfigurationType)1 HashMap (java.util.HashMap)1 ConfigView (org.jvnet.hk2.config.ConfigView)1