|
||||||||||
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
@InterfaceAudience.Public @InterfaceStability.Evolving public abstract class ZooKeeperNodeTracker
Tracks the availability and value of a single ZooKeeper node.
Utilizes the ZooKeeperListener
interface to get the necessary
ZooKeeper events related to the node.
This is the base class used by trackers in both the Master and RegionServers.
Field Summary | |
---|---|
protected Abortable |
abortable
Used to abort if a fatal error occurs |
protected String |
node
Path of node being tracked |
Fields inherited from class org.apache.hadoop.hbase.zookeeper.ZooKeeperListener |
---|
watcher |
Constructor Summary | |
---|---|
ZooKeeperNodeTracker(ZooKeeperWatcher watcher,
String node,
Abortable abortable)
Constructs a new ZK node tracker. |
Method Summary | |
---|---|
byte[] |
blockUntilAvailable()
Gets the data of the node, blocking until the node is available. |
byte[] |
blockUntilAvailable(long timeout,
boolean refresh)
Gets the data of the node, blocking until the node is available or the specified timeout has elapsed. |
boolean |
checkIfBaseNodeAvailable()
Checks if the baseznode set as per the property 'zookeeper.znode.parent' exists. |
byte[] |
getData(boolean refresh)
Gets the data of the node. |
String |
getNode()
|
void |
nodeCreated(String path)
Called when a new node has been created. |
void |
nodeDataChanged(String path)
Called when an existing node has changed data. |
void |
nodeDeleted(String path)
Called when a node has been deleted |
void |
start()
Starts the tracking of the node in ZooKeeper. |
void |
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 |
Field Detail |
---|
protected final String node
protected final Abortable abortable
Constructor Detail |
---|
public ZooKeeperNodeTracker(ZooKeeperWatcher watcher, String node, Abortable abortable)
After construction, use start()
to kick off tracking.
watcher
- node
- abortable
- Method Detail |
---|
public void start()
Use blockUntilAvailable()
to block until the node is available
or getData(boolean)
to get the data of the node if it is available.
public void stop()
public byte[] blockUntilAvailable() throws InterruptedException
InterruptedException
- if the waiting thread is interruptedpublic byte[] blockUntilAvailable(long timeout, boolean refresh) throws InterruptedException
timeout
- maximum time to wait for the node data to be available,
n milliseconds. Pass 0 for no timeout.
InterruptedException
- if the waiting thread is interruptedpublic byte[] getData(boolean refresh)
If the node is currently available, the most up-to-date known version of the data is returned. If the node is not currently available, null is returned.
refresh
- whether to refresh the data by calling ZK directly.
public String getNode()
public void nodeCreated(String path)
ZooKeeperListener
nodeCreated
in class ZooKeeperListener
path
- full path of the new nodepublic void nodeDeleted(String path)
ZooKeeperListener
nodeDeleted
in class ZooKeeperListener
path
- full path of the deleted nodepublic void nodeDataChanged(String path)
ZooKeeperListener
nodeDataChanged
in class ZooKeeperListener
path
- full path of the updated nodepublic boolean checkIfBaseNodeAvailable()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |