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 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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.opennms.core.health.api.HealthCheckService
HealthCheckService.ProgressListener
-
-
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 List<HealthCheck>
getHealthChecks()
io.vavr.control.Either<String,CompletionStage<Health>>
performAsyncHealthCheck(Context context, HealthCheckService.ProgressListener listener, List<String> tags)
Performs variousHealthCheck
s asynchronously and returns aCompletableFuture
which contains theHealth
representing eachHealthCheck
sResponse
.
-
-
-
Method Detail
-
getHealthChecks
protected List<HealthCheck> getHealthChecks() throws org.osgi.framework.InvalidSyntaxException
- Throws:
org.osgi.framework.InvalidSyntaxException
-
performAsyncHealthCheck
public io.vavr.control.Either<String,CompletionStage<Health>> performAsyncHealthCheck(Context context, HealthCheckService.ProgressListener listener, List<String> tags)
Description copied from interface:HealthCheckService
Performs variousHealthCheck
s asynchronously and returns aCompletableFuture
which contains theHealth
representing eachHealthCheck
sResponse
. It is up to the implementation 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 objectlistener
- gets informed about health check progress. May be null. In case theEither
contains an error no listener callbacks are called at all. If theEither
contains a all listener callbacks are guaranteed to be called before that completion stage completes.tags
- selects the single health checks that are included in the overall check; every health check that has any of the given tags is included.- Returns:
- Either an error message if no matching health checks could be determined or a
CompletableFuture
to retrieve theHealth
from.
-
-