Package org.apache.zookeeper.retry
Class ZooKeeperRetry
java.lang.Object
org.apache.zookeeper.ZooKeeper
org.apache.zookeeper.retry.ZooKeeperRetry
- All Implemented Interfaces:
AutoCloseable
A Class which extends
ZooKeeper
and will automatically retry calls to
zookeeper if a KeeperException.ConnectionLossException
occurs.-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.zookeeper.ZooKeeper
ZooKeeper.States, ZooKeeper.WatchRegistration
-
Field Summary
Fields inherited from class org.apache.zookeeper.ZooKeeper
cnxn, hostProvider, SECURE_CLIENT, ZOOKEEPER_CLIENT_CNXN_SOCKET
-
Constructor Summary
ConstructorsConstructorDescriptionZooKeeperRetry
(String connectString, int sessionTimeout, Watcher watcher) ZooKeeperRetry
(String connectString, int sessionTimeout, Watcher watcher, long sessionId, byte[] sessionPasswd) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
create
(String path, byte[] data, List<org.apache.zookeeper.data.ACL> acl, CreateMode createMode) void
org.apache.zookeeper.data.Stat
org.apache.zookeeper.data.Stat
List
<org.apache.zookeeper.data.ACL> getChildren
(String path, boolean watch) getChildren
(String path, Watcher watcher) byte[]
byte[]
org.apache.zookeeper.data.Stat
org.apache.zookeeper.data.Stat
void
setRetryLimit
(int limit) boolean
Methods inherited from class org.apache.zookeeper.ZooKeeper
addAuthInfo, addWatch, addWatch, addWatch, addWatch, close, create, create, create, create, create, delete, exists, exists, getACL, getAllChildrenNumber, getAllChildrenNumber, getChildren, getChildren, getChildren, getChildren, getChildren, getChildren, getChildWatches, getClientConfig, getConfig, getConfig, getConfig, getConfig, getData, getData, getDataWatches, getEphemerals, getEphemerals, getEphemerals, getEphemerals, getExistWatches, getPersistentRecursiveWatches, getPersistentWatches, getSaslClient, getSessionId, getSessionPasswd, getSessionTimeout, getState, getTestable, multi, multi, multiInternal, multiInternal, register, removeAllWatches, removeAllWatches, removeWatches, removeWatches, setACL, setData, sync, testableLocalSocketAddress, testableRemoteSocketAddress, testableWaitForShutdown, toString, transaction, updateServerList, whoAmI
-
Constructor Details
-
ZooKeeperRetry
- Parameters:
connectString
-sessionTimeout
-watcher
-- Throws:
IOException
-
ZooKeeperRetry
public ZooKeeperRetry(String connectString, int sessionTimeout, Watcher watcher, long sessionId, byte[] sessionPasswd) throws IOException - Parameters:
connectString
-sessionTimeout
-watcher
-sessionId
-sessionPasswd
-- Throws:
IOException
-
-
Method Details
-
close
- Specified by:
close
in interfaceAutoCloseable
- Overrides:
close
in classZooKeeper
- Throws:
InterruptedException
-
create
public String create(String path, byte[] data, List<org.apache.zookeeper.data.ACL> acl, CreateMode createMode) throws KeeperException, InterruptedException - Overrides:
create
in classZooKeeper
- Throws:
KeeperException
InterruptedException
-
delete
- Overrides:
delete
in classZooKeeper
- Throws:
InterruptedException
KeeperException
-
exists
public org.apache.zookeeper.data.Stat exists(String path, boolean watch) throws KeeperException, InterruptedException - Overrides:
exists
in classZooKeeper
- Throws:
KeeperException
InterruptedException
-
exists
public org.apache.zookeeper.data.Stat exists(String path, Watcher watcher) throws KeeperException, InterruptedException - Overrides:
exists
in classZooKeeper
- Throws:
KeeperException
InterruptedException
-
getACL
public List<org.apache.zookeeper.data.ACL> getACL(String path, org.apache.zookeeper.data.Stat stat) throws KeeperException, InterruptedException - Overrides:
getACL
in classZooKeeper
- Throws:
KeeperException
InterruptedException
-
getChildren
public List<String> getChildren(String path, boolean watch) throws KeeperException, InterruptedException - Overrides:
getChildren
in classZooKeeper
- Throws:
KeeperException
InterruptedException
-
getChildren
public List<String> getChildren(String path, Watcher watcher) throws KeeperException, InterruptedException - Overrides:
getChildren
in classZooKeeper
- Throws:
KeeperException
InterruptedException
-
getData
public byte[] getData(String path, boolean watch, org.apache.zookeeper.data.Stat stat) throws KeeperException, InterruptedException - Overrides:
getData
in classZooKeeper
- Throws:
KeeperException
InterruptedException
-
getData
public byte[] getData(String path, Watcher watcher, org.apache.zookeeper.data.Stat stat) throws KeeperException, InterruptedException - Overrides:
getData
in classZooKeeper
- Throws:
KeeperException
InterruptedException
-
setACL
public org.apache.zookeeper.data.Stat setACL(String path, List<org.apache.zookeeper.data.ACL> acl, int aclVersion) throws KeeperException, InterruptedException - Overrides:
setACL
in classZooKeeper
- Throws:
KeeperException
InterruptedException
-
setData
public org.apache.zookeeper.data.Stat setData(String path, byte[] data, int version) throws KeeperException, InterruptedException - Overrides:
setData
in classZooKeeper
- Throws:
KeeperException
InterruptedException
-
setRetryLimit
public void setRetryLimit(int limit) - Parameters:
limit
-
-
testConnection
public boolean testConnection()- Returns:
- true if successfully connected to zookeeper
-