@InterfaceAudience.Private public class RecoverableZooKeeper extends Object
| Constructor and Description |
|---|
RecoverableZooKeeper(String quorumServers,
int sessionTimeout,
Watcher watcher,
int maxRetries,
int retryIntervalMillis) |
RecoverableZooKeeper(String quorumServers,
int sessionTimeout,
Watcher watcher,
int maxRetries,
int retryIntervalMillis,
String identifier) |
| Modifier and Type | Method and Description |
|---|---|
protected ZooKeeper |
checkZk()
Try to create a Zookeeper connection.
|
void |
close() |
String |
create(String path,
byte[] data,
List<ACL> acl,
CreateMode createMode)
NONSEQUENTIAL create is idempotent operation.
|
void |
delete(String path,
int version)
delete is an idempotent operation.
|
Stat |
exists(String path,
boolean watch)
exists is an idempotent operation.
|
Stat |
exists(String path,
Watcher watcher)
exists is an idempotent operation.
|
List<ACL> |
getAcl(String path,
Stat stat)
getAcl is an idempotent operation.
|
List<String> |
getChildren(String path,
Watcher watcher)
getChildren is an idempotent operation.
|
byte[] |
getData(String path,
boolean watch,
Stat stat)
getData is an idemnpotent operation.
|
byte[] |
getData(String path,
Watcher watcher,
Stat stat)
getData is an idempotent operation.
|
String |
getIdentifier() |
long |
getSessionId() |
byte[] |
getSessionPasswd() |
States |
getState() |
ZooKeeper |
getZooKeeper() |
List<OpResult> |
multi(Iterable<Op> ops)
Run multiple operations in a transactional manner.
|
void |
reconnectAfterExpiration() |
byte[] |
removeMetaData(byte[] data) |
Stat |
setAcl(String path,
List<ACL> acls,
int version)
setAcl is an idempotent operation.
|
Stat |
setData(String path,
byte[] data,
int version)
setData is NOT an idempotent operation.
|
void |
sync(String path,
AsyncCallback.VoidCallback cb,
Object ctx) |
public RecoverableZooKeeper(String quorumServers, int sessionTimeout, Watcher watcher, int maxRetries, int retryIntervalMillis) throws IOException
IOExceptionpublic RecoverableZooKeeper(String quorumServers, int sessionTimeout, Watcher watcher, int maxRetries, int retryIntervalMillis, String identifier) throws IOException
IOExceptionprotected ZooKeeper checkZk()
throws KeeperException
KeeperExceptionpublic void reconnectAfterExpiration()
throws IOException,
KeeperException,
InterruptedException
IOExceptionKeeperExceptionInterruptedExceptionpublic void delete(String path, int version) throws InterruptedException, KeeperException
InterruptedExceptionKeeperExceptionpublic Stat exists(String path, Watcher watcher) throws KeeperException, InterruptedException
KeeperExceptionInterruptedExceptionpublic Stat exists(String path, boolean watch) throws KeeperException, InterruptedException
KeeperExceptionInterruptedExceptionpublic List<String> getChildren(String path, Watcher watcher) throws KeeperException, InterruptedException
KeeperExceptionInterruptedExceptionpublic byte[] getData(String path, Watcher watcher, Stat stat) throws KeeperException, InterruptedException
KeeperExceptionInterruptedExceptionpublic byte[] getData(String path, boolean watch, Stat stat) throws KeeperException, InterruptedException
KeeperExceptionInterruptedExceptionpublic Stat setData(String path, byte[] data, int version) throws KeeperException, InterruptedException
KeeperExceptionInterruptedExceptionpublic List<ACL> getAcl(String path, Stat stat) throws KeeperException, InterruptedException
KeeperExceptionInterruptedExceptionpublic Stat setAcl(String path, List<ACL> acls, int version) throws KeeperException, InterruptedException
KeeperExceptionInterruptedExceptionpublic String create(String path, byte[] data, List<ACL> acl, CreateMode createMode) throws KeeperException, InterruptedException
NONSEQUENTIAL create is idempotent operation. Retry before throwing exceptions. But this function will not throw the NodeExist exception back to the application.
But SEQUENTIAL is NOT idempotent operation. It is necessary to add identifier to the path to verify, whether the previous one is successful or not.
KeeperExceptionInterruptedExceptionpublic List<OpResult> multi(Iterable<Op> ops) throws KeeperException, InterruptedException
KeeperExceptionInterruptedExceptionpublic byte[] removeMetaData(byte[] data)
public long getSessionId()
public void close()
throws InterruptedException
InterruptedExceptionpublic States getState()
public ZooKeeper getZooKeeper()
public byte[] getSessionPasswd()
public void sync(String path, AsyncCallback.VoidCallback cb, Object ctx) throws KeeperException
KeeperExceptionpublic String getIdentifier()