public class MonitoringZookeeperConnection extends Object implements Closeable
| Modifier and Type | Class and Description |
|---|---|
static interface |
MonitoringZookeeperConnection.NodeChangeListener |
static class |
MonitoringZookeeperConnection.State
State of the
MonitoringZookeeperConnection class. |
| Constructor and Description |
|---|
MonitoringZookeeperConnection(String quorum) |
MonitoringZookeeperConnection(String[] quorum) |
MonitoringZookeeperConnection(String[] quorum,
String chroot,
MonitoringZookeeperConnection.NodeChangeListener changeListener)
Create a new
MonitoringZookeeperConnection. |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
deregisterObserver(ZooKeeperConnectionObserver observer) |
org.apache.zookeeper.ZooKeeper |
getActiveConnection() |
MonitoringZookeeperConnection.State |
getState()
Get the current state of the connection to the ZooKeeper quorum.
|
void |
listen(String node)
Start watching a node for changes.
|
void |
listen(String node,
boolean loadInitially)
Start watching a node for changes.
|
Optional<InputStream> |
load(String node)
Attempt to retrieve the contents of a ZooKeeper node.
|
ZooKeeperLock |
prepareLock(String znode) |
void |
registerObserver(ZooKeeperConnectionObserver observer) |
void |
set(String node,
String value,
boolean createIfMissing) |
void |
stopListening(String part) |
public MonitoringZookeeperConnection(String quorum)
public MonitoringZookeeperConnection(String[] quorum)
public MonitoringZookeeperConnection(String[] quorum, String chroot, MonitoringZookeeperConnection.NodeChangeListener changeListener)
MonitoringZookeeperConnection.quorum - ZooKeeper quorum addresses.chroot - Optional; limit the ZooKeeper connection to this prefix.changeListener - Callback interface called when a node changes.public Optional<InputStream> load(String node)
node - The name of the node. If this class was constructed with a chroot, then the node is
relative to that chroot.InputStream, or empty if the node was not found.public void registerObserver(ZooKeeperConnectionObserver observer)
public void deregisterObserver(ZooKeeperConnectionObserver observer)
public MonitoringZookeeperConnection.State getState()
public org.apache.zookeeper.ZooKeeper getActiveConnection()
public void listen(String node)
MonitoringZookeeperConnection.NodeChangeListener passed to this class
during construction will be called.node - The name of the node. If this class was constructed with a chroot, then the node is
relative to that chroot.public void listen(String node, boolean loadInitially)
MonitoringZookeeperConnection.NodeChangeListener passed to this class
during construction will be called.node - The name of the node. If this class was constructed with a chroot, then the node is
relative to that chroot.loadInitially - If true, the callback listener will be called with the current contents of the node. If
false, the callback won't be triggered until the node changes.public void stopListening(String part)
public ZooKeeperLock prepareLock(String znode)
public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionCopyright © 2015–2019 Lable. All rights reserved.