Package org.apache.hadoop.ha
Class HealthMonitor
java.lang.Object
org.apache.hadoop.ha.HealthMonitor
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 -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCallback(org.apache.hadoop.ha.HealthMonitor.Callback cb) voidaddServiceStateCallback(org.apache.hadoop.ha.HealthMonitor.ServiceStateCallback cb) protected HAServiceProtocolConnect to the service to be monitored.getProxy()voidshutdown()
-
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
- 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
Connect to the service to be monitored. Stubbed out for easier testing.- Returns:
- HAServiceProtocol.
- Throws:
IOException- raised on errors performing I/O.
-