Package org.opennms.core.health.impl
Class DefaultHealthCheckService
- java.lang.Object
-
- org.opennms.core.health.impl.DefaultHealthCheckService
-
- All Implemented Interfaces:
HealthCheckService
public class DefaultHealthCheckService extends java.lang.Object implements HealthCheckService
The "Default" implementation of theHealthCheckService
. It loads all availableHealthCheckService
s from the OSGi service registry. If no checks are available, the overall health is "Unhealthy".- Author:
- mvrueden
-
-
Constructor Summary
Constructors Constructor Description DefaultHealthCheckService(org.osgi.framework.BundleContext bundleContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.List<HealthCheck>
getHealthChecks()
java.util.concurrent.CompletableFuture<Health>
performAsyncHealthCheck(Context context, java.util.function.Consumer<HealthCheck> onStartConsumer, java.util.function.Consumer<Response> onFinishConsumer)
Performs variousHealthCheck
s asynchronously and returns aCompletableFuture
which contains theHealth
representing eachHealthCheck
sResponse
.
-
-
-
Method Detail
-
getHealthChecks
protected java.util.List<HealthCheck> getHealthChecks() throws org.osgi.framework.InvalidSyntaxException
- Throws:
org.osgi.framework.InvalidSyntaxException
-
performAsyncHealthCheck
public java.util.concurrent.CompletableFuture<Health> performAsyncHealthCheck(Context context, java.util.function.Consumer<HealthCheck> onStartConsumer, java.util.function.Consumer<Response> onFinishConsumer)
Description copied from interface:HealthCheckService
Performs variousHealthCheck
s asynchronously and returns aCompletableFuture
which contains theHealth
representing eachHealthCheck
sResponse
. It is up to the implementator to respect timeouts and handle exceptions accordingly, when these situations arise when callingHealthCheck.perform(Context)
. Callback methods can be provided to print information before and after aHealthCheck
is invoked. When providing aonFinishConsumer
please note, that this is invoked even if theHealthCheck.perform(Context)
execution failed or timed out and therefore may not represent the value when callingHealthCheck.perform(Context)
directly.- Specified by:
performAsyncHealthCheck
in interfaceHealthCheckService
- Parameters:
context
- The context objectonStartConsumer
- Callback method which is invoked before theHealthCheck.perform(Context)
method is invoked. May be null.onFinishConsumer
- Callback method which is invoked after theHealthCheck.perform(Context)
method is invoked. May be null.- Returns:
- The
CompletableFuture
to retrieve theHealth
from.
-
-