Class AbstractZookeeperClient<TargetDataListener,TargetChildListener>

java.lang.Object
org.apache.dubbo.remoting.zookeeper.AbstractZookeeperClient<TargetDataListener,TargetChildListener>
All Implemented Interfaces:
ZookeeperClient

public abstract class AbstractZookeeperClient<TargetDataListener,TargetChildListener> extends Object implements ZookeeperClient
  • Constructor Details

    • AbstractZookeeperClient

      public AbstractZookeeperClient(URL url)
  • Method Details

    • getUrl

      public URL getUrl()
      Specified by:
      getUrl in interface ZookeeperClient
    • delete

      public void delete(String path)
      Description copied from interface: ZookeeperClient
      Delete ZNode.
      Specified by:
      delete in interface ZookeeperClient
      Parameters:
      path - path to ZNode
    • create

      public void create(String path, boolean ephemeral, boolean faultTolerant)
      Description copied from interface: ZookeeperClient
      Create ZNode in Zookeeper.
      Specified by:
      create in interface ZookeeperClient
      Parameters:
      path - path to ZNode
      ephemeral - specify create mode of ZNode creation. true - EPHEMERAL, false - PERSISTENT.
      faultTolerant - specify fault tolerance of ZNode creation. true - ignore exception and recreate if is ephemeral, false - throw exception.
    • addStateListener

      public void addStateListener(StateListener listener)
      Specified by:
      addStateListener in interface ZookeeperClient
    • removeStateListener

      public void removeStateListener(StateListener listener)
      Specified by:
      removeStateListener in interface ZookeeperClient
    • getSessionListeners

      public Set<StateListener> getSessionListeners()
    • addChildListener

      public List<String> addChildListener(String path, ChildListener listener)
      Specified by:
      addChildListener in interface ZookeeperClient
    • addDataListener

      public void addDataListener(String path, DataListener listener)
      Description copied from interface: ZookeeperClient
      Attach data listener to current Zookeeper client.
      Specified by:
      addDataListener in interface ZookeeperClient
      Parameters:
      path - directory. All children of path will be listened.
      listener - The data listener object.
    • addDataListener

      public void addDataListener(String path, DataListener listener, Executor executor)
      Description copied from interface: ZookeeperClient
      Attach data listener to current Zookeeper client. The listener will be executed using the given executor.
      Specified by:
      addDataListener in interface ZookeeperClient
      Parameters:
      path - directory. All children of path will be listened.
      listener - The data listener object.
      executor - the executor that will execute the listener.
    • removeDataListener

      public void removeDataListener(String path, DataListener listener)
      Description copied from interface: ZookeeperClient
      Detach data listener.
      Specified by:
      removeDataListener in interface ZookeeperClient
      Parameters:
      path - directory. All listener of children of the path will be detached.
      listener - The data listener object.
    • removeChildListener

      public void removeChildListener(String path, ChildListener listener)
      Specified by:
      removeChildListener in interface ZookeeperClient
    • close

      public void close()
      Description copied from interface: ZookeeperClient
      Close connection to Zookeeper server (cluster).
      Specified by:
      close in interface ZookeeperClient
    • createOrUpdate

      public void createOrUpdate(String path, String content, boolean ephemeral)
      Description copied from interface: ZookeeperClient
      Create or update ZNode in Zookeeper with content specified.
      Specified by:
      createOrUpdate in interface ZookeeperClient
      Parameters:
      path - path to ZNode
      content - the content of ZNode
      ephemeral - specify create mode of ZNode creation. true - EPHEMERAL, false - PERSISTENT.
    • createOrUpdate

      public void createOrUpdate(String path, String content, boolean ephemeral, Integer version)
      Description copied from interface: ZookeeperClient
      CAS version to Create or update ZNode in Zookeeper with content specified.
      Specified by:
      createOrUpdate in interface ZookeeperClient
      Parameters:
      path - path to ZNode
      content - the content of ZNode
      ephemeral - specify create mode of ZNode creation. true - EPHEMERAL, false - PERSISTENT.
      version - origin content version, if current version is not the specified version, throw exception
    • getContent

      public String getContent(String path)
      Description copied from interface: ZookeeperClient
      Obtain the content of a ZNode.
      Specified by:
      getContent in interface ZookeeperClient
      Parameters:
      path - path to ZNode
      Returns:
      content of ZNode
    • getConfigItem

      public ConfigItem getConfigItem(String path)
      Specified by:
      getConfigItem in interface ZookeeperClient
    • checkExists

      public abstract boolean checkExists(String path)
      Specified by:
      checkExists in interface ZookeeperClient