|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.hadoop.hbase.zookeeper.ZooKeeperListener
org.apache.hadoop.hbase.zookeeper.ZooKeeperNodeTracker
org.apache.hadoop.hbase.zookeeper.MasterAddressTracker
@InterfaceAudience.Private public class MasterAddressTracker
Manages the location of the current active Master for the RegionServer.
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()
or via
getMasterAddress(ZooKeeperWatcher)
if you do not have a running
instance of this Tracker in your context.
This class also includes utility for interacting with the master znode, for writing and reading the znode content.
Field Summary |
---|
Fields inherited from class org.apache.hadoop.hbase.zookeeper.ZooKeeperNodeTracker |
---|
abortable, node |
Fields inherited from class org.apache.hadoop.hbase.zookeeper.ZooKeeperListener |
---|
watcher |
Constructor Summary | |
---|---|
MasterAddressTracker(ZooKeeperWatcher watcher,
Abortable abortable)
Construct a master address listener with the specified zookeeper reference. |
Method Summary | |
---|---|
static boolean |
deleteIfEquals(ZooKeeperWatcher zkw,
String content)
delete the master znode if its content is same as the parameter |
ServerName |
getMasterAddress()
Get the address of the current master if one is available. |
ServerName |
getMasterAddress(boolean refresh)
Get the address of the current master if one is available. |
static ServerName |
getMasterAddress(ZooKeeperWatcher zkw)
Get master address. |
boolean |
hasMaster()
Check if there is a master available. |
static boolean |
setMasterAddress(ZooKeeperWatcher zkw,
String znode,
ServerName master)
Set master address into the master znode or into the backup
subdirectory of backup masters; switch off the passed in znode
path. |
Methods inherited from class org.apache.hadoop.hbase.zookeeper.ZooKeeperNodeTracker |
---|
blockUntilAvailable, blockUntilAvailable, checkIfBaseNodeAvailable, getData, getNode, nodeCreated, nodeDataChanged, nodeDeleted, start, stop |
Methods inherited from class org.apache.hadoop.hbase.zookeeper.ZooKeeperListener |
---|
nodeChildrenChanged |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
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 errorMethod Detail |
---|
public ServerName getMasterAddress()
public ServerName getMasterAddress(boolean refresh)
refresh
- whether to refresh the data by calling ZK directly.
public static ServerName getMasterAddress(ZooKeeperWatcher zkw) throws org.apache.zookeeper.KeeperException, IOException
getMasterAddress()
if you do not have an
instance of this tracker in your context.
zkw
- ZooKeeperWatcher to use
org.apache.zookeeper.KeeperException
IOException
public static boolean setMasterAddress(ZooKeeperWatcher zkw, String znode, ServerName master) throws org.apache.zookeeper.KeeperException
master
znode or into the backup
subdirectory of backup masters; switch off the passed in znode
path.
zkw
- The ZooKeeperWatcher to use.znode
- Where to create the znode; could be at the top level or it
could be under backup mastersmaster
- ServerName of the current master
org.apache.zookeeper.KeeperException
public boolean hasMaster()
public static boolean deleteIfEquals(ZooKeeperWatcher zkw, String content)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |