Interface ZookeeperClient

All Known Implementing Classes:
AbstractZookeeperClient

public interface ZookeeperClient
Common abstraction of Zookeeper client.
  • Method Details

    • create

      void create(String path, boolean ephemeral, boolean faultTolerant)
      Create ZNode in Zookeeper.
      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.
    • delete

      void delete(String path)
      Delete ZNode.
      Parameters:
      path - path to ZNode
    • getChildren

      List<String> getChildren(String path)
    • addChildListener

      List<String> addChildListener(String path, ChildListener listener)
    • addDataListener

      void addDataListener(String path, DataListener listener)
      Attach data listener to current Zookeeper client.
      Parameters:
      path - directory. All children of path will be listened.
      listener - The data listener object.
    • addDataListener

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

      void removeDataListener(String path, DataListener listener)
      Detach data listener.
      Parameters:
      path - directory. All listener of children of the path will be detached.
      listener - The data listener object.
    • removeChildListener

      void removeChildListener(String path, ChildListener listener)
    • addStateListener

      void addStateListener(StateListener listener)
    • removeStateListener

      void removeStateListener(StateListener listener)
    • isConnected

      boolean isConnected()
      Check the Zookeeper client whether connected to server or not.
      Returns:
      true if connected
    • close

      void close()
      Close connection to Zookeeper server (cluster).
    • getUrl

      URL getUrl()
    • createOrUpdate

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

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

      String getContent(String path)
      Obtain the content of a ZNode.
      Parameters:
      path - path to ZNode
      Returns:
      content of ZNode
    • getConfigItem

      ConfigItem getConfigItem(String path)
    • checkExists

      boolean checkExists(String path)