Search in sources :

Example 1 with READINESS

use of fish.payara.microprofile.healthcheck.HealthCheckType.READINESS in project Payara by payara.

the class HealthCheckService method getCollectiveHealthChecks.

private Map<String, Set<HealthCheck>> getCollectiveHealthChecks(HealthCheckType type) {
    final Map<String, Set<HealthCheck>> healthChecks;
    if (type == READINESS) {
        healthChecks = readiness;
    } else if (type == LIVENESS) {
        healthChecks = liveness;
    } else if (type == STARTUP) {
        healthChecks = startup;
    } else {
        // Make sure we do a deep-copy first, otherwise the first map the foreach consumer gets used on will be a
        // shallow copy: the two maps will essentially be the same map (changes to one affecting the other)
        healthChecks = readiness.entrySet().stream().collect(Collectors.toMap(entry -> entry.getKey(), entry -> new HashSet(entry.getValue())));
        BiConsumer<? super String, ? super Set<HealthCheck>> mergeHealthCheckMap = (key, value) -> healthChecks.merge(key, value, (oldValue, newValue) -> {
            oldValue.addAll(newValue);
            return oldValue;
        });
        liveness.forEach(mergeHealthCheckMap);
        startup.forEach(mergeHealthCheckMap);
    }
    return healthChecks;
}
Also used : JsonWriterFactory(javax.json.JsonWriterFactory) Events(org.glassfish.api.event.Events) MonitoringWatchCollector(fish.payara.monitoring.collect.MonitoringWatchCollector) Map(java.util.Map) WebApplication(com.sun.enterprise.web.WebApplication) LIVENESS(fish.payara.microprofile.healthcheck.HealthCheckType.LIVENESS) HealthCheck(org.eclipse.microprofile.health.HealthCheck) PayaraHealthCheckServiceEvents(fish.payara.nucleus.healthcheck.events.PayaraHealthCheckServiceEvents) MonitoringDataCollector(fish.payara.monitoring.collect.MonitoringDataCollector) Collections.emptyList(java.util.Collections.emptyList) UnprocessedChangeEvents(org.jvnet.hk2.config.UnprocessedChangeEvents) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) WARNING(java.util.logging.Level.WARNING) Set(java.util.Set) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) Collectors.joining(java.util.stream.Collectors.joining) MonitoringDataSource(fish.payara.monitoring.collect.MonitoringDataSource) List(java.util.List) StartupRunLevel(org.glassfish.api.StartupRunLevel) Service(org.jvnet.hk2.annotations.Service) Entry(java.util.Map.Entry) PostConstruct(javax.annotation.PostConstruct) MicroprofileHealthCheckConfiguration(fish.payara.microprofile.healthcheck.config.MicroprofileHealthCheckConfiguration) Optional(java.util.Optional) UnprocessedChangeEvent(org.jvnet.hk2.config.UnprocessedChangeEvent) JsonObjectBuilder(javax.json.JsonObjectBuilder) Deployment(org.glassfish.internal.deployment.Deployment) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) READINESS(fish.payara.microprofile.healthcheck.HealthCheckType.READINESS) JsonGenerator(javax.json.stream.JsonGenerator) InvocationManager(org.glassfish.api.invocation.InvocationManager) JsonArrayBuilder(javax.json.JsonArrayBuilder) Globals(org.glassfish.internal.api.Globals) MonitoringData(fish.payara.monitoring.collect.MonitoringData) HashMap(java.util.HashMap) AtomicReference(java.util.concurrent.atomic.AtomicReference) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Inject(javax.inject.Inject) InvocationException(org.glassfish.api.invocation.InvocationException) HealthCheckResponse(org.eclipse.microprofile.health.HealthCheckResponse) BiConsumer(java.util.function.BiConsumer) Json(javax.json.Json) Collections.singletonMap(java.util.Collections.singletonMap) EventListener(org.glassfish.api.event.EventListener) PropertyChangeEvent(java.beans.PropertyChangeEvent) WebComponentInvocation(com.sun.enterprise.web.WebComponentInvocation) RunLevel(org.glassfish.hk2.runlevel.RunLevel) StringWriter(java.io.StringWriter) HttpServletResponse(javax.servlet.http.HttpServletResponse) WebContainer(com.sun.enterprise.web.WebContainer) IOException(java.io.IOException) Checker(fish.payara.nucleus.healthcheck.configuration.Checker) STARTUP(fish.payara.microprofile.healthcheck.HealthCheckType.STARTUP) Status(org.eclipse.microprofile.health.HealthCheckResponse.Status) MonitoringWatchSource(fish.payara.monitoring.collect.MonitoringWatchSource) JsonWriter(javax.json.JsonWriter) ApplicationInfo(org.glassfish.internal.data.ApplicationInfo) ApplicationRegistry(org.glassfish.internal.data.ApplicationRegistry) ConfigListener(org.jvnet.hk2.config.ConfigListener) PayaraHealthCheck(fish.payara.microprofile.healthcheck.checks.PayaraHealthCheck) Set(java.util.Set) HashSet(java.util.HashSet) HealthCheck(org.eclipse.microprofile.health.HealthCheck) PayaraHealthCheck(fish.payara.microprofile.healthcheck.checks.PayaraHealthCheck) HashSet(java.util.HashSet)

Aggregations

WebApplication (com.sun.enterprise.web.WebApplication)1 WebComponentInvocation (com.sun.enterprise.web.WebComponentInvocation)1 WebContainer (com.sun.enterprise.web.WebContainer)1 LIVENESS (fish.payara.microprofile.healthcheck.HealthCheckType.LIVENESS)1 READINESS (fish.payara.microprofile.healthcheck.HealthCheckType.READINESS)1 STARTUP (fish.payara.microprofile.healthcheck.HealthCheckType.STARTUP)1 PayaraHealthCheck (fish.payara.microprofile.healthcheck.checks.PayaraHealthCheck)1 MicroprofileHealthCheckConfiguration (fish.payara.microprofile.healthcheck.config.MicroprofileHealthCheckConfiguration)1 MonitoringData (fish.payara.monitoring.collect.MonitoringData)1 MonitoringDataCollector (fish.payara.monitoring.collect.MonitoringDataCollector)1 MonitoringDataSource (fish.payara.monitoring.collect.MonitoringDataSource)1 MonitoringWatchCollector (fish.payara.monitoring.collect.MonitoringWatchCollector)1 MonitoringWatchSource (fish.payara.monitoring.collect.MonitoringWatchSource)1 Checker (fish.payara.nucleus.healthcheck.configuration.Checker)1 PayaraHealthCheckServiceEvents (fish.payara.nucleus.healthcheck.events.PayaraHealthCheckServiceEvents)1 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1