Interface HealthCheck
-
@ConsumerType public interface HealthCheck
The Health Check SPI provides a means to check a certain system aspect programmatically. Health checks return a result
Result
, for most cases it is most convenient to useFormattingResultLog
that automatically derives the correctResult.Status
from the log messages.Clients must not look up health checks directly but rather use the
HealthCheckExecutor
service and execute checks based on tags (or name).If the
MBEAN_NAME
service registration property is set, the health check is registered as an mbean and can be invoked by getting the MBean from the JMX registry.Use the
hc.async.*
properties for the case a health check is known to be long-running (longer than the timeout as configured in the executor). For regularly triggering one or more health checks, rather configure aHealthCheckMonitor
.
-
-
Field Summary
Fields Modifier and Type Field Description static String
ASYNC_CRON_EXPRESSION
Optional service property: If this property is set the health check will be executed asynchronously using the cron expression provided.static String
ASYNC_INTERVAL_IN_SEC
Optional service property: If this property is set the health check will be executed asynchronously every n seconds.static String
KEEP_NON_OK_RESULTS_STICKY_FOR_SEC
Optional service property: If given, non-ok results from past executions will be taken into account as well for the given seconds (use Long.MAX_VALUE for indefinitely).static String
MBEAN_NAME
Optional service property: the name of the MBean for registering the health check as an MBean.static String
NAME
Optional service property: the name of a health check.static String
RESULT_CACHE_TTL_IN_MS
Optional service property: TTL for health checkResult
.static String
TAGS
Optional service property: tags for categorizing the health check services.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Result
execute()
Execute this health check.
-
-
-
Field Detail
-
NAME
static final String NAME
Optional service property: the name of a health check. This name should be unique, however there might be more than one health check service with the same value for this property. The value of this property must be of type String.- See Also:
- Constant Field Values
-
TAGS
static final String TAGS
Optional service property: tags for categorizing the health check services. The value of this property must be of type String or String array.- See Also:
- Constant Field Values
-
MBEAN_NAME
static final String MBEAN_NAME
Optional service property: the name of the MBean for registering the health check as an MBean. If this property is missing the health check is not registered as a JMX MBean. If there is more than one service with the same value for this property, the one with the highest service ranking is registered only. The value of this property must be of type String.- See Also:
- Constant Field Values
-
ASYNC_CRON_EXPRESSION
static final String ASYNC_CRON_EXPRESSION
Optional service property: If this property is set the health check will be executed asynchronously using the cron expression provided. Use this for long running health checks to avoid execution every time the tag/name is queried. Prefer configuring a HealthCheckMonitor if you only want to regularly execute a HC.- See Also:
- Constant Field Values
-
ASYNC_INTERVAL_IN_SEC
static final String ASYNC_INTERVAL_IN_SEC
Optional service property: If this property is set the health check will be executed asynchronously every n seconds. Use this for long running health checks to avoid execution every time the tag/name is queried. Prefer configuring a HealthCheckMonitor if you only want to regularly execute a HC.- See Also:
- Constant Field Values
-
RESULT_CACHE_TTL_IN_MS
static final String RESULT_CACHE_TTL_IN_MS
Optional service property: TTL for health checkResult
. The value of this property must be of typeLong
and is specified in ms.- See Also:
- Constant Field Values
-
KEEP_NON_OK_RESULTS_STICKY_FOR_SEC
static final String KEEP_NON_OK_RESULTS_STICKY_FOR_SEC
Optional service property: If given, non-ok results from past executions will be taken into account as well for the given seconds (use Long.MAX_VALUE for indefinitely). Useful for unhealthy system states that disappear but might leave the system at an inconsistent state (e.g. an event queue overflow where somebody needs to intervene manually) or for checks that should only go back to OK with a delay (can be useful for load balancers).- See Also:
- Constant Field Values
-
-