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
Nested ClassesModifier and TypeClassDescriptionprivate final classThread to synchronize znode data to client ZK clusterprivate static final classUsed to store the newest data which we want to sync to client zk. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ZKWatcherprivate static final org.slf4j.Loggerprivate final ConcurrentMap<String,ClientZKSyncer.ZKData> private final ServerFields inherited from class org.apache.hadoop.hbase.zookeeper.ZKListener
watcher -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidprivate voidgetDataAndWatch(String path) Returns the zk path(s) to watchvoidnodeCreated(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 deletedprivate final voidprotected final voidprivate voidremoveQueue(String path) private voidsetDataForClientZkUntilSuccess(String node, byte[] data) Set data for client ZK and retry until succeed.voidstart()Starts the syncerprivate voidstartNewSyncThread(String path) private voidupsertQueue(String node, byte[] data) Update the value of the single element in queue if any, or else insert.protected abstract booleanValidate whether a znode path is watched by usprivate voidwatchAndCheckExists(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:ZKListenerCalled when a new node has been created.- Overrides:
nodeCreatedin classZKListener- Parameters:
path- full path of the new 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
-
nodeDeleted
Description copied from class:ZKListenerCalled when a node has been deleted- Overrides:
nodeDeletedin 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
-