Class ZookeeperNodeListener

java.lang.Object
java.util.Observable
com.alibaba.druid.pool.ha.node.NodeListener
com.alibaba.druid.pool.ha.node.ZookeeperNodeListener

public class ZookeeperNodeListener extends NodeListener
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 Details

    • ZookeeperNodeListener

      public ZookeeperNodeListener()
  • Method Details

    • init

      public void init()
      Init a PathChildrenCache to watch the given path.
      Overrides:
      init in class NodeListener
      See Also:
    • destroy

      public void destroy()
      Close PathChildrenCache and CuratorFramework.
      Specified by:
      destroy in class NodeListener
    • refresh

      public List<NodeEvent> refresh()
      Build Properties from PathChildrenCache. Should be called after init().
      Specified by:
      refresh in class NodeListener
      See Also:
      • getPropertiesFromCache()
    • setClient

      public void setClient(org.apache.curator.framework.CuratorFramework client)
    • getClient

      public org.apache.curator.framework.CuratorFramework getClient()
    • getZkConnectString

      public String getZkConnectString()
    • setZkConnectString

      public void setZkConnectString(String zkConnectString)
    • getPath

      public String getPath()
    • setPath

      public void setPath(String path)
    • getUrlTemplate

      public String getUrlTemplate()
    • setUrlTemplate

      public void setUrlTemplate(String urlTemplate)