Class ZKNodeTracker
java.lang.Object
org.apache.hadoop.hbase.zookeeper.ZKListener
org.apache.hadoop.hbase.zookeeper.ZKNodeTracker
- Direct Known Subclasses:
ClusterStatusTracker,MasterAddressTracker
Tracks the availability and value of a single ZooKeeper node.
Utilizes the ZKListener 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
FieldsModifier and TypeFieldDescriptionprotected final AbortableUsed to abort if a fatal error occursprivate byte[]Data of the node being trackedprotected static final org.slf4j.Loggerprotected final StringPath of node being trackedprivate booleanFields inherited from class org.apache.hadoop.hbase.zookeeper.ZKListener
watcher -
Constructor Summary
ConstructorsConstructorDescriptionZKNodeTracker(ZKWatcher watcher, String node, Abortable abortable) Constructs a new ZK node tracker. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]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.booleanChecks if the baseznode set as per the property 'zookeeper.znode.parent' exists.byte[]getData(boolean refresh) Gets the data of the node.getNode()voidnodeCreated(String path) Called when a new node has been created.voidnodeDataChanged(String path) Called when an existing node has changed data.voidnodeDeleted(String path) Called when a node has been deletedprotected voidCalled after start is called.voidstart()Starts the tracking of the node in ZooKeeper.voidstop()toString()Methods inherited from class org.apache.hadoop.hbase.zookeeper.ZKListener
getWatcher, nodeChildrenChanged
-
Field Details
-
LOG
-
node
Path of node being tracked -
data
Data of the node being tracked -
abortable
Used to abort if a fatal error occurs -
stopped
-
-
Constructor Details
-
Method Details
-
start
Starts the tracking of the node in ZooKeeper. UseblockUntilAvailable()to block until the node is available orgetData(boolean)to get the data of the node if it is available. -
postStart
Called after start is called. Sub classes could implement this method to load more data on zk. -
stop
-
blockUntilAvailable
Gets the data of the node, blocking until the node is available.- Returns:
- data of the node
- Throws:
InterruptedException- if the waiting thread is interrupted
-
blockUntilAvailable
Gets the data of the node, blocking until the node is available or the specified timeout has elapsed.- Parameters:
timeout- maximum time to wait for the node data to be available, n milliseconds. Pass 0 for no timeout.- Returns:
- data of the node
- Throws:
InterruptedException- if the waiting thread is interrupted
-
getData
Gets the data of the node.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.
- Parameters:
refresh- whether to refresh the data by calling ZK directly.- Returns:
- data of the node, null if unavailable
-
getNode
-
nodeCreated
Description copied from class:ZKListenerCalled when a new node has been created.- Overrides:
nodeCreatedin classZKListener- Parameters:
path- full path of the new node
-
nodeDeleted
Description copied from class:ZKListenerCalled when a node has been deleted- Overrides:
nodeDeletedin classZKListener- Parameters:
path- full path of the deleted node
-
nodeDataChanged
Description copied from class:ZKListenerCalled when an existing node has changed data.- Overrides:
nodeDataChangedin classZKListener- Parameters:
path- full path of the updated node
-
checkIfBaseNodeAvailable
Checks if the baseznode set as per the property 'zookeeper.znode.parent' exists.- Returns:
- true if baseznode exists. false if doesnot exists.
-
toString
-