Package org.apache.bookkeeper.zookeeper
Class ZooKeeperClient
java.lang.Object
org.apache.zookeeper.ZooKeeper
org.apache.bookkeeper.zookeeper.ZooKeeperClient
- All Implemented Interfaces:
AutoCloseable,org.apache.zookeeper.Watcher
public class ZooKeeperClient
extends org.apache.zookeeper.ZooKeeper
implements org.apache.zookeeper.Watcher, AutoCloseable
Provide a zookeeper client to handle session expire.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA builder to build retryable zookeeper client.(package private) static classA runnable that retries zookeeper operations.Nested classes/interfaces inherited from class org.apache.zookeeper.ZooKeeper
org.apache.zookeeper.ZooKeeper.States, org.apache.zookeeper.ZooKeeper.WatchRegistrationNested 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, ZOOKEEPER_CLIENT_CNXN_SOCKET -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedZooKeeperClient(String connectString, int sessionTimeoutMs, ZooKeeperWatcherBase watcherManager, RetryPolicy connectRetryPolicy, RetryPolicy operationRetryPolicy, StatsLogger statsLogger, int retryExecThreadCount, double rate, boolean allowReadOnlyMode) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAuthInfo(String scheme, byte[] auth) voidclose()create(String path, byte[] data, List<org.apache.zookeeper.data.ACL> acl, org.apache.zookeeper.CreateMode createMode) voidcreate(String path, byte[] data, List<org.apache.zookeeper.data.ACL> acl, org.apache.zookeeper.CreateMode createMode, org.apache.zookeeper.AsyncCallback.StringCallback cb, Object context) (package private) static ZooKeeperClientcreateConnectedZooKeeperClient(String connectString, int sessionTimeoutMs, Set<org.apache.zookeeper.Watcher> childWatchers, RetryPolicy operationRetryPolicy) protected org.apache.zookeeper.ZooKeepervoidvoiddelete(String path, int version, org.apache.zookeeper.AsyncCallback.VoidCallback cb, Object context) org.apache.zookeeper.data.Statvoidexists(String path, boolean watch, org.apache.zookeeper.AsyncCallback.StatCallback cb, Object context) org.apache.zookeeper.data.Statvoidexists(String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.AsyncCallback.StatCallback cb, Object context) List<org.apache.zookeeper.data.ACL>voidgetACL(String path, org.apache.zookeeper.data.Stat stat, org.apache.zookeeper.AsyncCallback.ACLCallback cb, Object context) getChildren(String path, boolean watch) voidgetChildren(String path, boolean watch, org.apache.zookeeper.AsyncCallback.Children2Callback cb, Object context) voidgetChildren(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) voidgetChildren(String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.AsyncCallback.Children2Callback cb, Object context) voidgetChildren(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) voidgetData(String path, boolean watch, org.apache.zookeeper.AsyncCallback.DataCallback cb, Object context) byte[]voidgetData(String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.AsyncCallback.DataCallback cb, Object context) byte[]longbyte[]intorg.apache.zookeeper.ZooKeeper.StatesgetState()List<org.apache.zookeeper.OpResult>voidmulti(Iterable<org.apache.zookeeper.Op> ops, org.apache.zookeeper.AsyncCallback.MultiCallback cb, Object context) static ZooKeeperClient.Buildervoidprocess(org.apache.zookeeper.WatchedEvent event) voidregister(org.apache.zookeeper.Watcher watcher) org.apache.zookeeper.data.StatvoidsetACL(String path, List<org.apache.zookeeper.data.ACL> acl, int version, org.apache.zookeeper.AsyncCallback.StatCallback cb, Object context) org.apache.zookeeper.data.StatvoidsetData(String path, byte[] data, int version, org.apache.zookeeper.AsyncCallback.StatCallback cb, Object context) voidtoString()org.apache.zookeeper.TransactionDeprecated.voidMethods inherited from class org.apache.zookeeper.ZooKeeper
addWatch, addWatch, addWatch, addWatch, close, create, create, create, create, getAllChildrenNumber, getAllChildrenNumber, getChildWatches, getClientConfig, getConfig, getConfig, getConfig, getConfig, getDataWatches, getEphemerals, getEphemerals, getEphemerals, getEphemerals, getExistWatches, getPersistentRecursiveWatches, getPersistentWatches, getSaslClient, getTestable, multiInternal, multiInternal, removeAllWatches, removeAllWatches, removeWatches, removeWatches, sync, testableLocalSocketAddress, testableRemoteSocketAddress, testableWaitForShutdown, updateServerList, whoAmI
-
Constructor Details
-
ZooKeeperClient
protected ZooKeeperClient(String connectString, int sessionTimeoutMs, ZooKeeperWatcherBase watcherManager, RetryPolicy connectRetryPolicy, RetryPolicy operationRetryPolicy, StatsLogger statsLogger, int retryExecThreadCount, double rate, boolean allowReadOnlyMode) throws IOException - Throws:
IOException
-
-
Method Details
-
createConnectedZooKeeperClient
static ZooKeeperClient createConnectedZooKeeperClient(String connectString, int sessionTimeoutMs, Set<org.apache.zookeeper.Watcher> childWatchers, RetryPolicy operationRetryPolicy) throws org.apache.zookeeper.KeeperException, InterruptedException, IOException - Throws:
org.apache.zookeeper.KeeperExceptionInterruptedExceptionIOException
-
newBuilder
-
close
- Specified by:
closein interfaceAutoCloseable- Overrides:
closein classorg.apache.zookeeper.ZooKeeper- Throws:
InterruptedException
-
waitForConnection
- Throws:
org.apache.zookeeper.KeeperExceptionInterruptedException
-
createZooKeeper
- Throws:
IOException
-
process
public void process(org.apache.zookeeper.WatchedEvent event) - Specified by:
processin interfaceorg.apache.zookeeper.Watcher
-
getSessionId
public long getSessionId()- Overrides:
getSessionIdin classorg.apache.zookeeper.ZooKeeper
-
getSessionPasswd
public byte[] getSessionPasswd()- Overrides:
getSessionPasswdin classorg.apache.zookeeper.ZooKeeper
-
getSessionTimeout
public int getSessionTimeout()- Overrides:
getSessionTimeoutin classorg.apache.zookeeper.ZooKeeper
-
addAuthInfo
- Overrides:
addAuthInfoin classorg.apache.zookeeper.ZooKeeper
-
register
public void register(org.apache.zookeeper.Watcher watcher) - Overrides:
registerin classorg.apache.zookeeper.ZooKeeper
-
multi
public List<org.apache.zookeeper.OpResult> multi(Iterable<org.apache.zookeeper.Op> ops) throws InterruptedException, org.apache.zookeeper.KeeperException - Overrides:
multiin classorg.apache.zookeeper.ZooKeeper- Throws:
InterruptedExceptionorg.apache.zookeeper.KeeperException
-
multi
public void multi(Iterable<org.apache.zookeeper.Op> ops, org.apache.zookeeper.AsyncCallback.MultiCallback cb, Object context) - Overrides:
multiin classorg.apache.zookeeper.ZooKeeper
-
transaction
Deprecated.- Overrides:
transactionin classorg.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:
getACLin classorg.apache.zookeeper.ZooKeeper- Throws:
org.apache.zookeeper.KeeperExceptionInterruptedException
-
getACL
public void getACL(String path, org.apache.zookeeper.data.Stat stat, org.apache.zookeeper.AsyncCallback.ACLCallback cb, Object context) - Overrides:
getACLin classorg.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:
setACLin classorg.apache.zookeeper.ZooKeeper- Throws:
org.apache.zookeeper.KeeperExceptionInterruptedException
-
setACL
public void setACL(String path, List<org.apache.zookeeper.data.ACL> acl, int version, org.apache.zookeeper.AsyncCallback.StatCallback cb, Object context) - Overrides:
setACLin classorg.apache.zookeeper.ZooKeeper
-
sync
- Overrides:
syncin classorg.apache.zookeeper.ZooKeeper
-
getState
public org.apache.zookeeper.ZooKeeper.States getState()- Overrides:
getStatein classorg.apache.zookeeper.ZooKeeper
-
toString
- Overrides:
toStringin classorg.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:
createin classorg.apache.zookeeper.ZooKeeper- Throws:
org.apache.zookeeper.KeeperExceptionInterruptedException
-
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:
createin classorg.apache.zookeeper.ZooKeeper
-
delete
public void delete(String path, int version) throws org.apache.zookeeper.KeeperException, InterruptedException - Overrides:
deletein classorg.apache.zookeeper.ZooKeeper- Throws:
org.apache.zookeeper.KeeperExceptionInterruptedException
-
delete
public void delete(String path, int version, org.apache.zookeeper.AsyncCallback.VoidCallback cb, Object context) - Overrides:
deletein classorg.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:
existsin classorg.apache.zookeeper.ZooKeeper- Throws:
org.apache.zookeeper.KeeperExceptionInterruptedException
-
exists
public org.apache.zookeeper.data.Stat exists(String path, boolean watch) throws org.apache.zookeeper.KeeperException, InterruptedException - Overrides:
existsin classorg.apache.zookeeper.ZooKeeper- Throws:
org.apache.zookeeper.KeeperExceptionInterruptedException
-
exists
public void exists(String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.AsyncCallback.StatCallback cb, Object context) - Overrides:
existsin classorg.apache.zookeeper.ZooKeeper
-
exists
public void exists(String path, boolean watch, org.apache.zookeeper.AsyncCallback.StatCallback cb, Object context) - Overrides:
existsin classorg.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:
getDatain classorg.apache.zookeeper.ZooKeeper- Throws:
org.apache.zookeeper.KeeperExceptionInterruptedException
-
getData
public byte[] getData(String path, boolean watch, org.apache.zookeeper.data.Stat stat) throws org.apache.zookeeper.KeeperException, InterruptedException - Overrides:
getDatain classorg.apache.zookeeper.ZooKeeper- Throws:
org.apache.zookeeper.KeeperExceptionInterruptedException
-
getData
public void getData(String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.AsyncCallback.DataCallback cb, Object context) - Overrides:
getDatain classorg.apache.zookeeper.ZooKeeper
-
getData
public void getData(String path, boolean watch, org.apache.zookeeper.AsyncCallback.DataCallback cb, Object context) - Overrides:
getDatain classorg.apache.zookeeper.ZooKeeper
-
setData
public org.apache.zookeeper.data.Stat setData(String path, byte[] data, int version) throws org.apache.zookeeper.KeeperException, InterruptedException - Overrides:
setDatain classorg.apache.zookeeper.ZooKeeper- Throws:
org.apache.zookeeper.KeeperExceptionInterruptedException
-
setData
public void setData(String path, byte[] data, int version, org.apache.zookeeper.AsyncCallback.StatCallback cb, Object context) - Overrides:
setDatain classorg.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:
getChildrenin classorg.apache.zookeeper.ZooKeeper- Throws:
org.apache.zookeeper.KeeperExceptionInterruptedException
-
getChildren
public List<String> getChildren(String path, boolean watch, org.apache.zookeeper.data.Stat stat) throws org.apache.zookeeper.KeeperException, InterruptedException - Overrides:
getChildrenin classorg.apache.zookeeper.ZooKeeper- Throws:
org.apache.zookeeper.KeeperExceptionInterruptedException
-
getChildren
public void getChildren(String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.AsyncCallback.Children2Callback cb, Object context) - Overrides:
getChildrenin classorg.apache.zookeeper.ZooKeeper
-
getChildren
public void getChildren(String path, boolean watch, org.apache.zookeeper.AsyncCallback.Children2Callback cb, Object context) - Overrides:
getChildrenin classorg.apache.zookeeper.ZooKeeper
-
getChildren
public List<String> getChildren(String path, org.apache.zookeeper.Watcher watcher) throws org.apache.zookeeper.KeeperException, InterruptedException - Overrides:
getChildrenin classorg.apache.zookeeper.ZooKeeper- Throws:
org.apache.zookeeper.KeeperExceptionInterruptedException
-
getChildren
public List<String> getChildren(String path, boolean watch) throws org.apache.zookeeper.KeeperException, InterruptedException - Overrides:
getChildrenin classorg.apache.zookeeper.ZooKeeper- Throws:
org.apache.zookeeper.KeeperExceptionInterruptedException
-
getChildren
public void getChildren(String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.AsyncCallback.ChildrenCallback cb, Object context) - Overrides:
getChildrenin classorg.apache.zookeeper.ZooKeeper
-
getChildren
public void getChildren(String path, boolean watch, org.apache.zookeeper.AsyncCallback.ChildrenCallback cb, Object context) - Overrides:
getChildrenin classorg.apache.zookeeper.ZooKeeper
-