HealthMonitor (Apache Hadoop Common 3.5.0 API)
Description: declaration: package: org.apache.hadoop.ha, class: HealthMonitor

Package org.apache.hadoop.ha

# Class HealthMonitor

java.lang.Object
org.apache.hadoop.ha.HealthMonitor

@Private public class HealthMonitor extends Object
This class is a daemon which runs in a loop, periodically heartbeating with an HA service. It is responsible for keeping track of that service's health and exposing callbacks to the failover controller when the health status changes. Classes which need callbacks should implement the `HealthMonitor.Callback` interface.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static enum`
  `HealthMonitor.State`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addCallback(org.apache.hadoop.ha.HealthMonitor.Callback cb)`
  `void`
  `addServiceStateCallback(org.apache.hadoop.ha.HealthMonitor.ServiceStateCallback cb)`
  `protected HAServiceProtocol`
  `createProxy()`
  Connect to the service to be monitored.
  `HAServiceProtocol`
  `getProxy()`
  `void`
  `shutdown()`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### addCallback

    public void addCallback(org.apache.hadoop.ha.HealthMonitor.Callback cb)

  - ### addServiceStateCallback

    public void addServiceStateCallback(org.apache.hadoop.ha.HealthMonitor.ServiceStateCallback cb)

  - ### shutdown

    public void shutdown()

  - ### getProxy

    public HAServiceProtocol getProxy()
    Returns:
      the current proxy object to the underlying service. Note that this may return null in the case that the service is not responding. Also note that, even if the last indicated state is healthy, the service may have gone down in the meantime.

  - ### createProxy

    protected HAServiceProtocol createProxy() throws IOException
    Connect to the service to be monitored. Stubbed out for easier testing.
    Returns:
      HAServiceProtocol.
    Throws:
      `IOException` - raised on errors performing I/O.