public class ZooKeeperConfigurationSource extends java.lang.Object implements WatchedConfigurationSource, java.io.Closeable
WatchedConfigurationSource
for ZooKeeper using Curator.
This implementation requires the path to the ZK root parent node that contains
the hierarchy of configuration properties.
An example is /Constructor and Description |
---|
ZooKeeperConfigurationSource(CuratorFramework client,
java.lang.String configRootPath)
Creates the pathChildrenCache using the CuratorFramework client and ZK root path node for the config
|
Modifier and Type | Method and Description |
---|---|
void |
addUpdateListener(WatchedUpdateListener l)
Add
WatchedUpdateListener listener |
void |
close() |
protected void |
fireEvent(WatchedUpdateResult result) |
java.util.Map<java.lang.String,java.lang.Object> |
getCurrentData()
Get a snapshot of the latest configuration data.
Note: The correctness of this data is only as good as the underlying config source's view of the data. |
void |
removeUpdateListener(WatchedUpdateListener l)
Remove
WatchedUpdateListener listener |
void |
start()
Adds a listener to the pathChildrenCache, initializes the cache, then starts the cache-management background thread
|
public ZooKeeperConfigurationSource(CuratorFramework client, java.lang.String configRootPath)
Curator
- clientpath
- to ZK root parent node for the rest of the configuration properties (ie. /public void start() throws java.lang.Exception
java.lang.Exception
public java.util.Map<java.lang.String,java.lang.Object> getCurrentData() throws java.lang.Exception
WatchedConfigurationSource
getCurrentData
in interface WatchedConfigurationSource
java.lang.Exception
public void addUpdateListener(WatchedUpdateListener l)
WatchedConfigurationSource
WatchedUpdateListener
listeneraddUpdateListener
in interface WatchedConfigurationSource
public void removeUpdateListener(WatchedUpdateListener l)
WatchedConfigurationSource
WatchedUpdateListener
listenerremoveUpdateListener
in interface WatchedConfigurationSource
protected void fireEvent(WatchedUpdateResult result)
public void close()
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable