public class MonitoringZookeeperConnection extends Object implements Closeable
| Modifier and Type | Class and Description |
|---|---|
static interface |
MonitoringZookeeperConnection.NodeChangeListener |
| Constructor and Description |
|---|
MonitoringZookeeperConnection(String[] quorum,
String chroot,
MonitoringZookeeperConnection.NodeChangeListener changeListener)
Create a new
MonitoringZookeeperConnection. |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
org.lable.oss.dynamicconfig.zookeeper.MonitoringZookeeperConnection.State |
getState()
Get the current state of the connection to the ZooKeeper quorum.
|
void |
listen(String node)
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 |
set(String node,
String value,
boolean createIfMissing) |
void |
stopListening(String part) |
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 org.lable.oss.dynamicconfig.zookeeper.MonitoringZookeeperConnection.State getState()
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 stopListening(String part)
public ZookeeperLock prepareLock(String znode)
public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionCopyright © 2015–2018 Lable. All rights reserved.