@InterfaceAudience.Private public abstract class ClientZKSyncer extends ZKListener
getNodesToWatch()
methodModifier 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, nodeChildrenChanged
private 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
InterruptedException
public void nodeCreated(String path)
ZKListener
nodeCreated
in class ZKListener
path
- full path of the new nodepublic void nodeDataChanged(String path)
ZKListener
nodeDataChanged
in class ZKListener
path
- full path of the updated nodepublic void nodeDeleted(String path)
ZKListener
nodeDeleted
in class ZKListener
path
- 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.