@InterfaceAudience.Private public abstract class ClientZKSyncer extends ZKListener
getNodesToWatch() method| Modifier and Type | Class and Description |
|---|---|
(package private) class |
ClientZKSyncer.ClientZkUpdater
Thread to synchronize znode data to client ZK cluster
|
| Modifier and Type | Field and Description |
|---|---|
private ZKWatcher |
clientZkWatcher |
private static org.slf4j.Logger |
LOG |
private Map<String,BlockingQueue<byte[]>> |
queues |
private Server |
server |
watcher| Constructor and Description |
|---|
ClientZKSyncer(ZKWatcher watcher,
ZKWatcher clientZkWatcher,
Server server) |
| Modifier and Type | Method and Description |
|---|---|
(package private) abstract Collection<String> |
getNodesToWatch() |
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
|
private void |
reconnectAfterExpiration() |
private void |
setDataForClientZkUntilSuccess(String node,
byte[] data)
Set data for client ZK and retry until succeed.
|
void |
start()
Starts the syncer
|
private void |
upsertQueue(String node,
byte[] data)
Update the value of the single element in queue if any, or else insert.
|
(package private) abstract boolean |
validate(String path)
Validate whether a znode path is watched by us
|
private void |
watchAndCheckExists(String node) |
getWatcher, nodeChildrenChangedprivate static final org.slf4j.Logger LOG
private final ZKWatcher clientZkWatcher
private final Map<String,BlockingQueue<byte[]>> queues
public ClientZKSyncer(ZKWatcher watcher, ZKWatcher clientZkWatcher, Server server)
public void start() throws org.apache.zookeeper.KeeperException
org.apache.zookeeper.KeeperException - if error occurs when trying to create base nodes on client ZKprivate void watchAndCheckExists(String node)
private void upsertQueue(String node, byte[] data)
data - the data to write to queueprivate final void setDataForClientZkUntilSuccess(String node, byte[] data) throws InterruptedException
node - the znode to set on client ZKdata - the data to set to client ZKInterruptedException - if the thread is interrupted during processprivate final void reconnectAfterExpiration() throws InterruptedException
InterruptedExceptionpublic void nodeCreated(String path)
ZKListenernodeCreated in class ZKListenerpath - full path of the new nodepublic void nodeDataChanged(String path)
ZKListenernodeDataChanged in class ZKListenerpath - full path of the updated nodepublic void nodeDeleted(String path)
ZKListenernodeDeleted in class ZKListenerpath - full path of the deleted nodeabstract boolean validate(String path)
path - the path to validateabstract Collection<String> getNodesToWatch()
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.