public class MasterAddressTracker extends ZooKeeperNodeTracker
Listens for ZooKeeper events related to the master address. The node
/master
will contain the address of the current master.
This listener is interested in
NodeDeleted
and NodeCreated
events on
/master
.
Utilizes ZooKeeperNodeTracker
for zk interactions.
You can get the current master via getMasterAddress()
abortable, node
watcher
Constructor and Description |
---|
MasterAddressTracker(ZooKeeperWatcher watcher,
Abortable abortable)
Construct a master address listener with the specified
zookeeper reference. |
Modifier and Type | Method and Description |
---|---|
ServerName |
getMasterAddress()
Get the address of the current master if one is available.
|
boolean |
hasMaster()
Check if there is a master available.
|
blockUntilAvailable, blockUntilAvailable, checkIfBaseNodeAvailable, getData, getNode, nodeCreated, nodeDataChanged, nodeDeleted, start, stop
nodeChildrenChanged
public MasterAddressTracker(ZooKeeperWatcher watcher, Abortable abortable)
zookeeper
reference.
This constructor does not trigger any actions, you must call methods
explicitly. Normally you will just want to execute ZooKeeperNodeTracker.start()
to
begin tracking of the master address.
watcher
- zk reference and watcherabortable
- abortable in case of fatal errorpublic ServerName getMasterAddress()
public boolean hasMaster()
Copyright © 2014 The Apache Software Foundation. All Rights Reserved.