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