Package org.apache.bookkeeper.zookeeper
Class ZooKeeperClient
- java.lang.Object
-
- org.apache.zookeeper.ZooKeeper
-
- org.apache.bookkeeper.zookeeper.ZooKeeperClient
-
- All Implemented Interfaces:
java.lang.AutoCloseable
,org.apache.zookeeper.Watcher
public class ZooKeeperClient extends org.apache.zookeeper.ZooKeeper implements org.apache.zookeeper.Watcher, java.lang.AutoCloseable
Provide a zookeeper client to handle session expire.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ZooKeeperClient.Builder
A builder to build retryable zookeeper client.(package private) static class
ZooKeeperClient.ZkRetryRunnable
A runnable that retries zookeeper operations.
-
Constructor Summary
Constructors Modifier Constructor Description protected
ZooKeeperClient(java.lang.String connectString, int sessionTimeoutMs, ZooKeeperWatcherBase watcherManager, RetryPolicy connectRetryPolicy, RetryPolicy operationRetryPolicy, StatsLogger statsLogger, int retryExecThreadCount, double rate, boolean allowReadOnlyMode)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addAuthInfo(java.lang.String scheme, byte[] auth)
void
close()
java.lang.String
create(java.lang.String path, byte[] data, java.util.List<org.apache.zookeeper.data.ACL> acl, org.apache.zookeeper.CreateMode createMode)
void
create(java.lang.String path, byte[] data, java.util.List<org.apache.zookeeper.data.ACL> acl, org.apache.zookeeper.CreateMode createMode, org.apache.zookeeper.AsyncCallback.StringCallback cb, java.lang.Object context)
(package private) static ZooKeeperClient
createConnectedZooKeeperClient(java.lang.String connectString, int sessionTimeoutMs, java.util.Set<org.apache.zookeeper.Watcher> childWatchers, RetryPolicy operationRetryPolicy)
protected org.apache.zookeeper.ZooKeeper
createZooKeeper()
void
delete(java.lang.String path, int version)
void
delete(java.lang.String path, int version, org.apache.zookeeper.AsyncCallback.VoidCallback cb, java.lang.Object context)
org.apache.zookeeper.data.Stat
exists(java.lang.String path, boolean watch)
void
exists(java.lang.String path, boolean watch, org.apache.zookeeper.AsyncCallback.StatCallback cb, java.lang.Object context)
org.apache.zookeeper.data.Stat
exists(java.lang.String path, org.apache.zookeeper.Watcher watcher)
void
exists(java.lang.String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.AsyncCallback.StatCallback cb, java.lang.Object context)
java.util.List<org.apache.zookeeper.data.ACL>
getACL(java.lang.String path, org.apache.zookeeper.data.Stat stat)
void
getACL(java.lang.String path, org.apache.zookeeper.data.Stat stat, org.apache.zookeeper.AsyncCallback.ACLCallback cb, java.lang.Object context)
java.util.List<java.lang.String>
getChildren(java.lang.String path, boolean watch)
void
getChildren(java.lang.String path, boolean watch, org.apache.zookeeper.AsyncCallback.Children2Callback cb, java.lang.Object context)
void
getChildren(java.lang.String path, boolean watch, org.apache.zookeeper.AsyncCallback.ChildrenCallback cb, java.lang.Object context)
java.util.List<java.lang.String>
getChildren(java.lang.String path, boolean watch, org.apache.zookeeper.data.Stat stat)
java.util.List<java.lang.String>
getChildren(java.lang.String path, org.apache.zookeeper.Watcher watcher)
void
getChildren(java.lang.String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.AsyncCallback.Children2Callback cb, java.lang.Object context)
void
getChildren(java.lang.String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.AsyncCallback.ChildrenCallback cb, java.lang.Object context)
java.util.List<java.lang.String>
getChildren(java.lang.String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.data.Stat stat)
void
getData(java.lang.String path, boolean watch, org.apache.zookeeper.AsyncCallback.DataCallback cb, java.lang.Object context)
byte[]
getData(java.lang.String path, boolean watch, org.apache.zookeeper.data.Stat stat)
void
getData(java.lang.String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.AsyncCallback.DataCallback cb, java.lang.Object context)
byte[]
getData(java.lang.String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.data.Stat stat)
long
getSessionId()
byte[]
getSessionPasswd()
int
getSessionTimeout()
org.apache.zookeeper.ZooKeeper.States
getState()
java.util.List<org.apache.zookeeper.OpResult>
multi(java.lang.Iterable<org.apache.zookeeper.Op> ops)
void
multi(java.lang.Iterable<org.apache.zookeeper.Op> ops, org.apache.zookeeper.AsyncCallback.MultiCallback cb, java.lang.Object context)
static ZooKeeperClient.Builder
newBuilder()
void
process(org.apache.zookeeper.WatchedEvent event)
void
register(org.apache.zookeeper.Watcher watcher)
org.apache.zookeeper.data.Stat
setACL(java.lang.String path, java.util.List<org.apache.zookeeper.data.ACL> acl, int version)
void
setACL(java.lang.String path, java.util.List<org.apache.zookeeper.data.ACL> acl, int version, org.apache.zookeeper.AsyncCallback.StatCallback cb, java.lang.Object context)
org.apache.zookeeper.data.Stat
setData(java.lang.String path, byte[] data, int version)
void
setData(java.lang.String path, byte[] data, int version, org.apache.zookeeper.AsyncCallback.StatCallback cb, java.lang.Object context)
void
sync(java.lang.String path, org.apache.zookeeper.AsyncCallback.VoidCallback cb, java.lang.Object context)
java.lang.String
toString()
org.apache.zookeeper.Transaction
transaction()
Deprecated.void
waitForConnection()
-
Methods 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 Detail
-
ZooKeeperClient
protected ZooKeeperClient(java.lang.String connectString, int sessionTimeoutMs, ZooKeeperWatcherBase watcherManager, RetryPolicy connectRetryPolicy, RetryPolicy operationRetryPolicy, StatsLogger statsLogger, int retryExecThreadCount, double rate, boolean allowReadOnlyMode) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
createConnectedZooKeeperClient
static ZooKeeperClient createConnectedZooKeeperClient(java.lang.String connectString, int sessionTimeoutMs, java.util.Set<org.apache.zookeeper.Watcher> childWatchers, RetryPolicy operationRetryPolicy) throws org.apache.zookeeper.KeeperException, java.lang.InterruptedException, java.io.IOException
- Throws:
org.apache.zookeeper.KeeperException
java.lang.InterruptedException
java.io.IOException
-
newBuilder
public static ZooKeeperClient.Builder newBuilder()
-
close
public void close() throws java.lang.InterruptedException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Overrides:
close
in classorg.apache.zookeeper.ZooKeeper
- Throws:
java.lang.InterruptedException
-
waitForConnection
public void waitForConnection() throws org.apache.zookeeper.KeeperException, java.lang.InterruptedException
- Throws:
org.apache.zookeeper.KeeperException
java.lang.InterruptedException
-
createZooKeeper
protected org.apache.zookeeper.ZooKeeper createZooKeeper() throws java.io.IOException
- Throws:
java.io.IOException
-
process
public void process(org.apache.zookeeper.WatchedEvent event)
- Specified by:
process
in interfaceorg.apache.zookeeper.Watcher
-
getSessionId
public long getSessionId()
- Overrides:
getSessionId
in classorg.apache.zookeeper.ZooKeeper
-
getSessionPasswd
public byte[] getSessionPasswd()
- Overrides:
getSessionPasswd
in classorg.apache.zookeeper.ZooKeeper
-
getSessionTimeout
public int getSessionTimeout()
- Overrides:
getSessionTimeout
in classorg.apache.zookeeper.ZooKeeper
-
addAuthInfo
public void addAuthInfo(java.lang.String scheme, byte[] auth)
- Overrides:
addAuthInfo
in classorg.apache.zookeeper.ZooKeeper
-
register
public void register(org.apache.zookeeper.Watcher watcher)
- Overrides:
register
in classorg.apache.zookeeper.ZooKeeper
-
multi
public java.util.List<org.apache.zookeeper.OpResult> multi(java.lang.Iterable<org.apache.zookeeper.Op> ops) throws java.lang.InterruptedException, org.apache.zookeeper.KeeperException
- Overrides:
multi
in classorg.apache.zookeeper.ZooKeeper
- Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException
-
multi
public void multi(java.lang.Iterable<org.apache.zookeeper.Op> ops, org.apache.zookeeper.AsyncCallback.MultiCallback cb, java.lang.Object context)
- Overrides:
multi
in classorg.apache.zookeeper.ZooKeeper
-
transaction
@Deprecated public org.apache.zookeeper.Transaction transaction()
Deprecated.- Overrides:
transaction
in classorg.apache.zookeeper.ZooKeeper
-
getACL
public java.util.List<org.apache.zookeeper.data.ACL> getACL(java.lang.String path, org.apache.zookeeper.data.Stat stat) throws org.apache.zookeeper.KeeperException, java.lang.InterruptedException
- Overrides:
getACL
in classorg.apache.zookeeper.ZooKeeper
- Throws:
org.apache.zookeeper.KeeperException
java.lang.InterruptedException
-
getACL
public void getACL(java.lang.String path, org.apache.zookeeper.data.Stat stat, org.apache.zookeeper.AsyncCallback.ACLCallback cb, java.lang.Object context)
- Overrides:
getACL
in classorg.apache.zookeeper.ZooKeeper
-
setACL
public org.apache.zookeeper.data.Stat setACL(java.lang.String path, java.util.List<org.apache.zookeeper.data.ACL> acl, int version) throws org.apache.zookeeper.KeeperException, java.lang.InterruptedException
- Overrides:
setACL
in classorg.apache.zookeeper.ZooKeeper
- Throws:
org.apache.zookeeper.KeeperException
java.lang.InterruptedException
-
setACL
public void setACL(java.lang.String path, java.util.List<org.apache.zookeeper.data.ACL> acl, int version, org.apache.zookeeper.AsyncCallback.StatCallback cb, java.lang.Object context)
- Overrides:
setACL
in classorg.apache.zookeeper.ZooKeeper
-
sync
public void sync(java.lang.String path, org.apache.zookeeper.AsyncCallback.VoidCallback cb, java.lang.Object context)
- Overrides:
sync
in classorg.apache.zookeeper.ZooKeeper
-
getState
public org.apache.zookeeper.ZooKeeper.States getState()
- Overrides:
getState
in classorg.apache.zookeeper.ZooKeeper
-
toString
public java.lang.String toString()
- Overrides:
toString
in classorg.apache.zookeeper.ZooKeeper
-
create
public java.lang.String create(java.lang.String path, byte[] data, java.util.List<org.apache.zookeeper.data.ACL> acl, org.apache.zookeeper.CreateMode createMode) throws org.apache.zookeeper.KeeperException, java.lang.InterruptedException
- Overrides:
create
in classorg.apache.zookeeper.ZooKeeper
- Throws:
org.apache.zookeeper.KeeperException
java.lang.InterruptedException
-
create
public void create(java.lang.String path, byte[] data, java.util.List<org.apache.zookeeper.data.ACL> acl, org.apache.zookeeper.CreateMode createMode, org.apache.zookeeper.AsyncCallback.StringCallback cb, java.lang.Object context)
- Overrides:
create
in classorg.apache.zookeeper.ZooKeeper
-
delete
public void delete(java.lang.String path, int version) throws org.apache.zookeeper.KeeperException, java.lang.InterruptedException
- Overrides:
delete
in classorg.apache.zookeeper.ZooKeeper
- Throws:
org.apache.zookeeper.KeeperException
java.lang.InterruptedException
-
delete
public void delete(java.lang.String path, int version, org.apache.zookeeper.AsyncCallback.VoidCallback cb, java.lang.Object context)
- Overrides:
delete
in classorg.apache.zookeeper.ZooKeeper
-
exists
public org.apache.zookeeper.data.Stat exists(java.lang.String path, org.apache.zookeeper.Watcher watcher) throws org.apache.zookeeper.KeeperException, java.lang.InterruptedException
- Overrides:
exists
in classorg.apache.zookeeper.ZooKeeper
- Throws:
org.apache.zookeeper.KeeperException
java.lang.InterruptedException
-
exists
public org.apache.zookeeper.data.Stat exists(java.lang.String path, boolean watch) throws org.apache.zookeeper.KeeperException, java.lang.InterruptedException
- Overrides:
exists
in classorg.apache.zookeeper.ZooKeeper
- Throws:
org.apache.zookeeper.KeeperException
java.lang.InterruptedException
-
exists
public void exists(java.lang.String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.AsyncCallback.StatCallback cb, java.lang.Object context)
- Overrides:
exists
in classorg.apache.zookeeper.ZooKeeper
-
exists
public void exists(java.lang.String path, boolean watch, org.apache.zookeeper.AsyncCallback.StatCallback cb, java.lang.Object context)
- Overrides:
exists
in classorg.apache.zookeeper.ZooKeeper
-
getData
public byte[] getData(java.lang.String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.data.Stat stat) throws org.apache.zookeeper.KeeperException, java.lang.InterruptedException
- Overrides:
getData
in classorg.apache.zookeeper.ZooKeeper
- Throws:
org.apache.zookeeper.KeeperException
java.lang.InterruptedException
-
getData
public byte[] getData(java.lang.String path, boolean watch, org.apache.zookeeper.data.Stat stat) throws org.apache.zookeeper.KeeperException, java.lang.InterruptedException
- Overrides:
getData
in classorg.apache.zookeeper.ZooKeeper
- Throws:
org.apache.zookeeper.KeeperException
java.lang.InterruptedException
-
getData
public void getData(java.lang.String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.AsyncCallback.DataCallback cb, java.lang.Object context)
- Overrides:
getData
in classorg.apache.zookeeper.ZooKeeper
-
getData
public void getData(java.lang.String path, boolean watch, org.apache.zookeeper.AsyncCallback.DataCallback cb, java.lang.Object context)
- Overrides:
getData
in classorg.apache.zookeeper.ZooKeeper
-
setData
public org.apache.zookeeper.data.Stat setData(java.lang.String path, byte[] data, int version) throws org.apache.zookeeper.KeeperException, java.lang.InterruptedException
- Overrides:
setData
in classorg.apache.zookeeper.ZooKeeper
- Throws:
org.apache.zookeeper.KeeperException
java.lang.InterruptedException
-
setData
public void setData(java.lang.String path, byte[] data, int version, org.apache.zookeeper.AsyncCallback.StatCallback cb, java.lang.Object context)
- Overrides:
setData
in classorg.apache.zookeeper.ZooKeeper
-
getChildren
public java.util.List<java.lang.String> getChildren(java.lang.String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.data.Stat stat) throws org.apache.zookeeper.KeeperException, java.lang.InterruptedException
- Overrides:
getChildren
in classorg.apache.zookeeper.ZooKeeper
- Throws:
org.apache.zookeeper.KeeperException
java.lang.InterruptedException
-
getChildren
public java.util.List<java.lang.String> getChildren(java.lang.String path, boolean watch, org.apache.zookeeper.data.Stat stat) throws org.apache.zookeeper.KeeperException, java.lang.InterruptedException
- Overrides:
getChildren
in classorg.apache.zookeeper.ZooKeeper
- Throws:
org.apache.zookeeper.KeeperException
java.lang.InterruptedException
-
getChildren
public void getChildren(java.lang.String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.AsyncCallback.Children2Callback cb, java.lang.Object context)
- Overrides:
getChildren
in classorg.apache.zookeeper.ZooKeeper
-
getChildren
public void getChildren(java.lang.String path, boolean watch, org.apache.zookeeper.AsyncCallback.Children2Callback cb, java.lang.Object context)
- Overrides:
getChildren
in classorg.apache.zookeeper.ZooKeeper
-
getChildren
public java.util.List<java.lang.String> getChildren(java.lang.String path, org.apache.zookeeper.Watcher watcher) throws org.apache.zookeeper.KeeperException, java.lang.InterruptedException
- Overrides:
getChildren
in classorg.apache.zookeeper.ZooKeeper
- Throws:
org.apache.zookeeper.KeeperException
java.lang.InterruptedException
-
getChildren
public java.util.List<java.lang.String> getChildren(java.lang.String path, boolean watch) throws org.apache.zookeeper.KeeperException, java.lang.InterruptedException
- Overrides:
getChildren
in classorg.apache.zookeeper.ZooKeeper
- Throws:
org.apache.zookeeper.KeeperException
java.lang.InterruptedException
-
getChildren
public void getChildren(java.lang.String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.AsyncCallback.ChildrenCallback cb, java.lang.Object context)
- Overrides:
getChildren
in classorg.apache.zookeeper.ZooKeeper
-
getChildren
public void getChildren(java.lang.String path, boolean watch, org.apache.zookeeper.AsyncCallback.ChildrenCallback cb, java.lang.Object context)
- Overrides:
getChildren
in classorg.apache.zookeeper.ZooKeeper
-
-