Class PulsarZooKeeperClient

java.lang.Object
org.apache.zookeeper.ZooKeeper
org.apache.pulsar.metadata.impl.PulsarZooKeeperClient
All Implemented Interfaces:
AutoCloseable, org.apache.zookeeper.Watcher

public class PulsarZooKeeperClient extends org.apache.zookeeper.ZooKeeper implements org.apache.zookeeper.Watcher, AutoCloseable
Provide a zookeeper client to handle session expire.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    A builder to build retryable zookeeper client.

    Nested classes/interfaces inherited from class org.apache.zookeeper.ZooKeeper

    org.apache.zookeeper.ZooKeeper.States, org.apache.zookeeper.ZooKeeper.WatchRegistration

    Nested classes/interfaces inherited from interface org.apache.zookeeper.Watcher

    org.apache.zookeeper.Watcher.Event, org.apache.zookeeper.Watcher.WatcherType
  • Field Summary

    Fields inherited from class org.apache.zookeeper.ZooKeeper

    cnxn, hostProvider, SECURE_CLIENT, watchManager, ZOOKEEPER_CLIENT_CNXN_SOCKET
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    PulsarZooKeeperClient(String connectString, int sessionTimeoutMs, org.apache.bookkeeper.zookeeper.ZooKeeperWatcherBase watcherManager, org.apache.bookkeeper.zookeeper.RetryPolicy connectRetryPolicy, org.apache.bookkeeper.zookeeper.RetryPolicy operationRetryPolicy, org.apache.bookkeeper.stats.StatsLogger statsLogger, int retryExecThreadCount, double rate, boolean allowReadOnlyMode)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addAuthInfo(String scheme, byte[] auth)
     
    void
    addWatch(String basePath, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.AddWatchMode mode)
     
    void
    addWatch(String basePath, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.AddWatchMode mode, org.apache.zookeeper.AsyncCallback.VoidCallback cb, Object ctx)
     
    void
     
    create(String path, byte[] data, List<org.apache.zookeeper.data.ACL> acl, org.apache.zookeeper.CreateMode createMode)
     
    void
    create(String path, byte[] data, List<org.apache.zookeeper.data.ACL> acl, org.apache.zookeeper.CreateMode createMode, org.apache.zookeeper.AsyncCallback.StringCallback cb, Object context)
     
    protected org.apache.zookeeper.ZooKeeper
     
    void
    delete(String path, int version)
     
    void
    delete(String path, int version, org.apache.zookeeper.AsyncCallback.VoidCallback cb, Object context)
     
    org.apache.zookeeper.data.Stat
    exists(String path, boolean watch)
     
    void
    exists(String path, boolean watch, org.apache.zookeeper.AsyncCallback.StatCallback cb, Object context)
     
    org.apache.zookeeper.data.Stat
    exists(String path, org.apache.zookeeper.Watcher watcher)
     
    void
    exists(String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.AsyncCallback.StatCallback cb, Object context)
     
    List<org.apache.zookeeper.data.ACL>
    getACL(String path, org.apache.zookeeper.data.Stat stat)
     
    void
    getACL(String path, org.apache.zookeeper.data.Stat stat, org.apache.zookeeper.AsyncCallback.ACLCallback cb, Object context)
     
    getChildren(String path, boolean watch)
     
    void
    getChildren(String path, boolean watch, org.apache.zookeeper.AsyncCallback.Children2Callback cb, Object context)
     
    void
    getChildren(String path, boolean watch, org.apache.zookeeper.AsyncCallback.ChildrenCallback cb, Object context)
     
    getChildren(String path, boolean watch, org.apache.zookeeper.data.Stat stat)
     
    getChildren(String path, org.apache.zookeeper.Watcher watcher)
     
    void
    getChildren(String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.AsyncCallback.Children2Callback cb, Object context)
     
    void
    getChildren(String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.AsyncCallback.ChildrenCallback cb, Object context)
     
    getChildren(String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.data.Stat stat)
     
    void
    getData(String path, boolean watch, org.apache.zookeeper.AsyncCallback.DataCallback cb, Object context)
     
    byte[]
    getData(String path, boolean watch, org.apache.zookeeper.data.Stat stat)
     
    void
    getData(String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.AsyncCallback.DataCallback cb, Object context)
     
    byte[]
    getData(String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.data.Stat stat)
     
    long
     
    byte[]
     
    int
     
    org.apache.zookeeper.ZooKeeper.States
     
    List<org.apache.zookeeper.OpResult>
    multi(Iterable<org.apache.zookeeper.Op> ops)
     
    void
    multi(Iterable<org.apache.zookeeper.Op> ops, org.apache.zookeeper.AsyncCallback.MultiCallback cb, Object context)
     
     
    void
    process(org.apache.zookeeper.WatchedEvent event)
     
    void
    register(org.apache.zookeeper.Watcher watcher)
     
    org.apache.zookeeper.data.Stat
    setACL(String path, List<org.apache.zookeeper.data.ACL> acl, int version)
     
    void
    setACL(String path, List<org.apache.zookeeper.data.ACL> acl, int version, org.apache.zookeeper.AsyncCallback.StatCallback cb, Object context)
     
    org.apache.zookeeper.data.Stat
    setData(String path, byte[] data, int version)
     
    void
    setData(String path, byte[] data, int version, org.apache.zookeeper.AsyncCallback.StatCallback cb, Object context)
     
    void
    sync(String path, org.apache.zookeeper.AsyncCallback.VoidCallback cb, Object context)
     
     
    org.apache.zookeeper.Transaction
    Deprecated.
    void
     

    Methods inherited from class org.apache.zookeeper.ZooKeeper

    addWatch, addWatch, close, create, create, create, create, createConnection, defaultWatchManager, getAllChildrenNumber, getAllChildrenNumber, getChildWatches, getClientConfig, getConfig, getConfig, getConfig, getConfig, getDataWatches, getEphemerals, getEphemerals, getEphemerals, getEphemerals, getExistWatches, getPersistentRecursiveWatches, getPersistentWatches, getSaslClient, getTestable, multiInternal, multiInternal, removeAllWatches, removeAllWatches, removeWatches, removeWatches, testableLocalSocketAddress, testableRemoteSocketAddress, testableWaitForShutdown, updateServerList

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • PulsarZooKeeperClient

      protected PulsarZooKeeperClient(String connectString, int sessionTimeoutMs, org.apache.bookkeeper.zookeeper.ZooKeeperWatcherBase watcherManager, org.apache.bookkeeper.zookeeper.RetryPolicy connectRetryPolicy, org.apache.bookkeeper.zookeeper.RetryPolicy operationRetryPolicy, org.apache.bookkeeper.stats.StatsLogger statsLogger, int retryExecThreadCount, double rate, boolean allowReadOnlyMode) throws IOException
      Throws:
      IOException
  • Method Details

    • newBuilder

      public static PulsarZooKeeperClient.Builder newBuilder()
    • close

      public void close() throws InterruptedException
      Specified by:
      close in interface AutoCloseable
      Overrides:
      close in class org.apache.zookeeper.ZooKeeper
      Throws:
      InterruptedException
    • waitForConnection

      public void waitForConnection() throws org.apache.zookeeper.KeeperException, InterruptedException
      Throws:
      org.apache.zookeeper.KeeperException
      InterruptedException
    • createZooKeeper

      protected org.apache.zookeeper.ZooKeeper createZooKeeper() throws IOException
      Throws:
      IOException
    • process

      public void process(org.apache.zookeeper.WatchedEvent event)
      Specified by:
      process in interface org.apache.zookeeper.Watcher
    • getSessionId

      public long getSessionId()
      Overrides:
      getSessionId in class org.apache.zookeeper.ZooKeeper
    • getSessionPasswd

      public byte[] getSessionPasswd()
      Overrides:
      getSessionPasswd in class org.apache.zookeeper.ZooKeeper
    • getSessionTimeout

      public int getSessionTimeout()
      Overrides:
      getSessionTimeout in class org.apache.zookeeper.ZooKeeper
    • addAuthInfo

      public void addAuthInfo(String scheme, byte[] auth)
      Overrides:
      addAuthInfo in class org.apache.zookeeper.ZooKeeper
    • register

      public void register(org.apache.zookeeper.Watcher watcher)
      Overrides:
      register in class org.apache.zookeeper.ZooKeeper
    • multi

      public List<org.apache.zookeeper.OpResult> multi(Iterable<org.apache.zookeeper.Op> ops) throws InterruptedException, org.apache.zookeeper.KeeperException
      Overrides:
      multi in class org.apache.zookeeper.ZooKeeper
      Throws:
      InterruptedException
      org.apache.zookeeper.KeeperException
    • multi

      public void multi(Iterable<org.apache.zookeeper.Op> ops, org.apache.zookeeper.AsyncCallback.MultiCallback cb, Object context)
      Overrides:
      multi in class org.apache.zookeeper.ZooKeeper
    • transaction

      @Deprecated public org.apache.zookeeper.Transaction transaction()
      Deprecated.
      Overrides:
      transaction in class org.apache.zookeeper.ZooKeeper
    • getACL

      public List<org.apache.zookeeper.data.ACL> getACL(String path, org.apache.zookeeper.data.Stat stat) throws org.apache.zookeeper.KeeperException, InterruptedException
      Overrides:
      getACL in class org.apache.zookeeper.ZooKeeper
      Throws:
      org.apache.zookeeper.KeeperException
      InterruptedException
    • getACL

      public void getACL(String path, org.apache.zookeeper.data.Stat stat, org.apache.zookeeper.AsyncCallback.ACLCallback cb, Object context)
      Overrides:
      getACL in class org.apache.zookeeper.ZooKeeper
    • setACL

      public org.apache.zookeeper.data.Stat setACL(String path, List<org.apache.zookeeper.data.ACL> acl, int version) throws org.apache.zookeeper.KeeperException, InterruptedException
      Overrides:
      setACL in class org.apache.zookeeper.ZooKeeper
      Throws:
      org.apache.zookeeper.KeeperException
      InterruptedException
    • setACL

      public void setACL(String path, List<org.apache.zookeeper.data.ACL> acl, int version, org.apache.zookeeper.AsyncCallback.StatCallback cb, Object context)
      Overrides:
      setACL in class org.apache.zookeeper.ZooKeeper
    • sync

      public void sync(String path, org.apache.zookeeper.AsyncCallback.VoidCallback cb, Object context)
      Overrides:
      sync in class org.apache.zookeeper.ZooKeeper
    • getState

      public org.apache.zookeeper.ZooKeeper.States getState()
      Overrides:
      getState in class org.apache.zookeeper.ZooKeeper
    • toString

      public String toString()
      Overrides:
      toString in class org.apache.zookeeper.ZooKeeper
    • create

      public String create(String path, byte[] data, List<org.apache.zookeeper.data.ACL> acl, org.apache.zookeeper.CreateMode createMode) throws org.apache.zookeeper.KeeperException, InterruptedException
      Overrides:
      create in class org.apache.zookeeper.ZooKeeper
      Throws:
      org.apache.zookeeper.KeeperException
      InterruptedException
    • create

      public void create(String path, byte[] data, List<org.apache.zookeeper.data.ACL> acl, org.apache.zookeeper.CreateMode createMode, org.apache.zookeeper.AsyncCallback.StringCallback cb, Object context)
      Overrides:
      create in class org.apache.zookeeper.ZooKeeper
    • delete

      public void delete(String path, int version) throws org.apache.zookeeper.KeeperException, InterruptedException
      Overrides:
      delete in class org.apache.zookeeper.ZooKeeper
      Throws:
      org.apache.zookeeper.KeeperException
      InterruptedException
    • delete

      public void delete(String path, int version, org.apache.zookeeper.AsyncCallback.VoidCallback cb, Object context)
      Overrides:
      delete in class org.apache.zookeeper.ZooKeeper
    • exists

      public org.apache.zookeeper.data.Stat exists(String path, org.apache.zookeeper.Watcher watcher) throws org.apache.zookeeper.KeeperException, InterruptedException
      Overrides:
      exists in class org.apache.zookeeper.ZooKeeper
      Throws:
      org.apache.zookeeper.KeeperException
      InterruptedException
    • exists

      public org.apache.zookeeper.data.Stat exists(String path, boolean watch) throws org.apache.zookeeper.KeeperException, InterruptedException
      Overrides:
      exists in class org.apache.zookeeper.ZooKeeper
      Throws:
      org.apache.zookeeper.KeeperException
      InterruptedException
    • exists

      public void exists(String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.AsyncCallback.StatCallback cb, Object context)
      Overrides:
      exists in class org.apache.zookeeper.ZooKeeper
    • exists

      public void exists(String path, boolean watch, org.apache.zookeeper.AsyncCallback.StatCallback cb, Object context)
      Overrides:
      exists in class org.apache.zookeeper.ZooKeeper
    • getData

      public byte[] getData(String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.data.Stat stat) throws org.apache.zookeeper.KeeperException, InterruptedException
      Overrides:
      getData in class org.apache.zookeeper.ZooKeeper
      Throws:
      org.apache.zookeeper.KeeperException
      InterruptedException
    • getData

      public byte[] getData(String path, boolean watch, org.apache.zookeeper.data.Stat stat) throws org.apache.zookeeper.KeeperException, InterruptedException
      Overrides:
      getData in class org.apache.zookeeper.ZooKeeper
      Throws:
      org.apache.zookeeper.KeeperException
      InterruptedException
    • getData

      public void getData(String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.AsyncCallback.DataCallback cb, Object context)
      Overrides:
      getData in class org.apache.zookeeper.ZooKeeper
    • getData

      public void getData(String path, boolean watch, org.apache.zookeeper.AsyncCallback.DataCallback cb, Object context)
      Overrides:
      getData in class org.apache.zookeeper.ZooKeeper
    • setData

      public org.apache.zookeeper.data.Stat setData(String path, byte[] data, int version) throws org.apache.zookeeper.KeeperException, InterruptedException
      Overrides:
      setData in class org.apache.zookeeper.ZooKeeper
      Throws:
      org.apache.zookeeper.KeeperException
      InterruptedException
    • setData

      public void setData(String path, byte[] data, int version, org.apache.zookeeper.AsyncCallback.StatCallback cb, Object context)
      Overrides:
      setData in class org.apache.zookeeper.ZooKeeper
    • addWatch

      public void addWatch(String basePath, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.AddWatchMode mode) throws org.apache.zookeeper.KeeperException, InterruptedException
      Overrides:
      addWatch in class org.apache.zookeeper.ZooKeeper
      Throws:
      org.apache.zookeeper.KeeperException
      InterruptedException
    • addWatch

      public void addWatch(String basePath, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.AddWatchMode mode, org.apache.zookeeper.AsyncCallback.VoidCallback cb, Object ctx)
      Overrides:
      addWatch in class org.apache.zookeeper.ZooKeeper
    • getChildren

      public List<String> getChildren(String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.data.Stat stat) throws org.apache.zookeeper.KeeperException, InterruptedException
      Overrides:
      getChildren in class org.apache.zookeeper.ZooKeeper
      Throws:
      org.apache.zookeeper.KeeperException
      InterruptedException
    • getChildren

      public List<String> getChildren(String path, boolean watch, org.apache.zookeeper.data.Stat stat) throws org.apache.zookeeper.KeeperException, InterruptedException
      Overrides:
      getChildren in class org.apache.zookeeper.ZooKeeper
      Throws:
      org.apache.zookeeper.KeeperException
      InterruptedException
    • getChildren

      public void getChildren(String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.AsyncCallback.Children2Callback cb, Object context)
      Overrides:
      getChildren in class org.apache.zookeeper.ZooKeeper
    • getChildren

      public void getChildren(String path, boolean watch, org.apache.zookeeper.AsyncCallback.Children2Callback cb, Object context)
      Overrides:
      getChildren in class org.apache.zookeeper.ZooKeeper
    • getChildren

      public List<String> getChildren(String path, org.apache.zookeeper.Watcher watcher) throws org.apache.zookeeper.KeeperException, InterruptedException
      Overrides:
      getChildren in class org.apache.zookeeper.ZooKeeper
      Throws:
      org.apache.zookeeper.KeeperException
      InterruptedException
    • getChildren

      public List<String> getChildren(String path, boolean watch) throws org.apache.zookeeper.KeeperException, InterruptedException
      Overrides:
      getChildren in class org.apache.zookeeper.ZooKeeper
      Throws:
      org.apache.zookeeper.KeeperException
      InterruptedException
    • getChildren

      public void getChildren(String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.AsyncCallback.ChildrenCallback cb, Object context)
      Overrides:
      getChildren in class org.apache.zookeeper.ZooKeeper
    • getChildren

      public void getChildren(String path, boolean watch, org.apache.zookeeper.AsyncCallback.ChildrenCallback cb, Object context)
      Overrides:
      getChildren in class org.apache.zookeeper.ZooKeeper