Chapter 12. The Health Check API
12.1. The Health Check API
The Health Check API allows users to monitor the health of the cluster, and the caches contained within. This information is particularly important when working in a cloud environment, as it provides a method of querying to report the status of the cluster or cache.
This API exposes the following information:
- The name of the cluster.
- The number of machines in the cluster.
The overall status of the cluster or cache, represented in one of three values:
- Healthy - The entity is healthy.
- Unhealthy - The entity is unhealthy. This value indicates that one or more caches are in a degraded state.
- Rebalancing - The entity is operational, but a rebalance is in progress. Cluster nodes should not be adjusted when this value is reported.
- The status of each cache.
- A tail of the server log.
For information on using the Health Check API through non-programmatic methods, refer to the JBoss Data Grid Administration and Configuration Guide
.
12.2. Accessing the Health Check API Programmatically
The Health Check API is only accessible programatically in Library mode, and may be accessed by calling the embeddedCacheManager.getHealth()
method.
This method returns an org.infinispan.health.Health
object, which has access to the following methods:
getClusterHealth()
- returns aClusterHealth
object with access to the following methods:-
getNumberOfNodes()
- returns an int representing the number of all nodes in the cluster -
getNodeNames()
- returns aList<String>
containing the names of all nodes in the cluster -
getClusterName()
- returns aString
containing the name of the cluster -
getHealthStatus()
- returns aHealthStatus
that contains the cluster’s health, being reported as HEALTHY, UNHEALTHY, or REBALANCING
-
getHostInfo()
- returns aHostInfo
object with access to the following methods:-
getNumberOfCpus()
- returns an int containing the number of CPUs installed in the host -
getTotalMemoryKb()
- returns a long containing the total memory in KB -
getFreeMemoryInKb()
- returns a long containing the free memory in KB
-
getCacheHealth()
- returns aList<CacheHealth>
. EachCacheHealth
object has access to the following methods:-
getCacheName()
- returns aString
containing the name of the cache -
getStatus()
- returns aHealthStatus
that contains the cache’s health, being reported as HEALTHY, UNHEALTHY, or REBALANCING
-