Class ClientZKSyncer
java.lang.Object
org.apache.hadoop.hbase.zookeeper.ZKListener
org.apache.hadoop.hbase.master.zksyncer.ClientZKSyncer
- Direct Known Subclasses:
MasterAddressSyncer
,MetaLocationSyncer
Tracks the target znode(s) on server ZK cluster and synchronize them to client ZK cluster if
changed
The target znode(s) is given through
getPathsToWatch()
method-
Nested Class Summary
Modifier and TypeClassDescriptionprivate final class
Thread to synchronize znode data to client ZK clusterprivate static final class
Used to store the newest data which we want to sync to client zk. -
Field Summary
Modifier and TypeFieldDescriptionprivate final ZKWatcher
private static final org.slf4j.Logger
private final ConcurrentMap<String,
ClientZKSyncer.ZKData> private final Server
Fields inherited from class org.apache.hadoop.hbase.zookeeper.ZKListener
watcher
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate void
private void
getDataAndWatch
(String path) Returns the zk path(s) to watchvoid
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 deletedprivate final void
protected final void
private void
removeQueue
(String path) private void
setDataForClientZkUntilSuccess
(String node, byte[] data) Set data for client ZK and retry until succeed.void
start()
Starts the syncerprivate void
startNewSyncThread
(String path) private void
upsertQueue
(String node, byte[] data) Update the value of the single element in queue if any, or else insert.protected abstract boolean
Validate whether a znode path is watched by usprivate void
watchAndCheckExists
(String node) Methods inherited from class org.apache.hadoop.hbase.zookeeper.ZKListener
getWatcher, nodeChildrenChanged
-
Field Details
-
LOG
-
server
-
clientZkWatcher
-
queues
-
-
Constructor Details
-
ClientZKSyncer
-
-
Method Details
-
startNewSyncThread
-
start
Starts the syncer- Throws:
org.apache.zookeeper.KeeperException
- if error occurs when trying to create base nodes on client ZK
-
watchAndCheckExists
-
upsertQueue
Update the value of the single element in queue if any, or else insert. We only need to synchronize the latest znode value to client ZK rather than synchronize each time- Parameters:
data
- the data to write to queue
-
setDataForClientZkUntilSuccess
Set data for client ZK and retry until succeed. Be very careful to prevent dead loop when modifying this method- Parameters:
node
- the znode to set on client ZKdata
- the data to set to client ZK- Throws:
InterruptedException
- if the thread is interrupted during process
-
deleteDataForClientZkUntilSuccess
- Throws:
InterruptedException
-
reconnectAfterExpiration
- Throws:
InterruptedException
-
getDataAndWatch
-
removeQueue
-
nodeCreated
Description copied from class:ZKListener
Called when a new node has been created.- Overrides:
nodeCreated
in classZKListener
- Parameters:
path
- full path of the new node
-
nodeDataChanged
Description copied from class:ZKListener
Called when an existing node has changed data.- Overrides:
nodeDataChanged
in classZKListener
- Parameters:
path
- full path of the updated node
-
nodeDeleted
Description copied from class:ZKListener
Called when a node has been deleted- Overrides:
nodeDeleted
in classZKListener
- Parameters:
path
- full path of the deleted node
-
validate
Validate whether a znode path is watched by us- Parameters:
path
- the path to validate- Returns:
- true if the znode is watched by us
-
getPathsToWatch
Returns the zk path(s) to watch -
refreshWatchingList
-