Package com.codahale.metrics.health
Class HealthCheckRegistry
java.lang.Object
com.codahale.metrics.health.HealthCheckRegistry
A registry for health checks.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ConcurrentMap
<String, HealthCheck> private static final org.slf4j.Logger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetNames()
Returns a set of the names of all registered health checks.void
register
(String name, HealthCheck healthCheck) Registers an applicationHealthCheck
.runHealthCheck
(String name) Runs the health check with the given name.Runs the registered health checks and returns a map of the results.runHealthChecks
(ExecutorService executor) Runs the registered health checks in parallel and returns a map of the results.void
unregister
(String name) Unregisters the applicationHealthCheck
with the given name.
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
healthChecks
-
-
Constructor Details
-
HealthCheckRegistry
public HealthCheckRegistry()Creates a newHealthCheckRegistry
.
-
-
Method Details
-
register
Registers an applicationHealthCheck
.- Parameters:
name
- the name of the health checkhealthCheck
- theHealthCheck
instance
-
unregister
Unregisters the applicationHealthCheck
with the given name.- Parameters:
name
- the name of theHealthCheck
instance
-
getNames
Returns a set of the names of all registered health checks.- Returns:
- the names of all registered health checks
-
runHealthCheck
Runs the health check with the given name.- Parameters:
name
- the health check's name- Returns:
- the result of the health check
- Throws:
NoSuchElementException
- if there is no health check with the given name
-
runHealthChecks
Runs the registered health checks and returns a map of the results.- Returns:
- a map of the health check results
-
runHealthChecks
Runs the registered health checks in parallel and returns a map of the results.- Returns:
- a map of the health check results
-