Package com.alibaba.druid.pool.ha.node
Class ZookeeperNodeListener
java.lang.Object
java.util.Observable
com.alibaba.druid.pool.ha.node.NodeListener
com.alibaba.druid.pool.ha.node.ZookeeperNodeListener
A NodeListener that watches a Zookeeper Path.
e.g.
Path to watch:
+ ha-druid-datasources |---- NodeA |---- NodeB
The Data of NodeA (in Java properties format):
foo.host=xxx.xxx.xxx.xxx foo.port=3308 foo.username=foo foo.password=foo_password bar.host=xxx.xxx.xxx.xxx bar.port=3309 bar.username=bar bar.password=bar_password bar.database=bar_database
- Author:
- DigitalSonic
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy()
Close PathChildrenCache and CuratorFramework.org.apache.curator.framework.CuratorFramework
getPath()
void
init()
Init a PathChildrenCache to watch the given path.refresh()
Build Properties from PathChildrenCache.void
setClient
(org.apache.curator.framework.CuratorFramework client) void
void
setUrlTemplate
(String urlTemplate) void
setZkConnectString
(String zkConnectString) Methods inherited from class com.alibaba.druid.pool.ha.node.NodeListener
getLastUpdateTime, getObserver, getPrefix, getProperties, setLastUpdateTime, setObserver, setPrefix, setProperties, update, update
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
-
Constructor Details
-
ZookeeperNodeListener
public ZookeeperNodeListener()
-
-
Method Details
-
init
public void init()Init a PathChildrenCache to watch the given path.- Overrides:
init
in classNodeListener
- See Also:
-
destroy
public void destroy()Close PathChildrenCache and CuratorFramework.- Specified by:
destroy
in classNodeListener
-
refresh
Build Properties from PathChildrenCache. Should be called after init().- Specified by:
refresh
in classNodeListener
- See Also:
-
getPropertiesFromCache()
-
setClient
public void setClient(org.apache.curator.framework.CuratorFramework client) -
getClient
public org.apache.curator.framework.CuratorFramework getClient() -
getZkConnectString
-
setZkConnectString
-
getPath
-
setPath
-
getUrlTemplate
-
setUrlTemplate
-