@InterfaceAudience.Private public class RecoverableZooKeeper extends java.lang.Object
| Constructor and Description |
|---|
RecoverableZooKeeper(java.lang.String quorumServers,
int sessionTimeout,
Watcher watcher,
int maxRetries,
int retryIntervalMillis) |
RecoverableZooKeeper(java.lang.String quorumServers,
int sessionTimeout,
Watcher watcher,
int maxRetries,
int retryIntervalMillis,
java.lang.String identifier) |
| Modifier and Type | Method and Description |
|---|---|
protected ZooKeeper |
checkZk()
Try to create a Zookeeper connection.
|
void |
close() |
java.lang.String |
create(java.lang.String path,
byte[] data,
java.util.List<ACL> acl,
CreateMode createMode)
NONSEQUENTIAL create is idempotent operation.
|
void |
delete(java.lang.String path,
int version)
delete is an idempotent operation.
|
Stat |
exists(java.lang.String path,
boolean watch)
exists is an idempotent operation.
|
Stat |
exists(java.lang.String path,
Watcher watcher)
exists is an idempotent operation.
|
java.util.List<ACL> |
getAcl(java.lang.String path,
Stat stat)
getAcl is an idempotent operation.
|
java.util.List<java.lang.String> |
getChildren(java.lang.String path,
Watcher watcher)
getChildren is an idempotent operation.
|
byte[] |
getData(java.lang.String path,
boolean watch,
Stat stat)
getData is an idemnpotent operation.
|
byte[] |
getData(java.lang.String path,
Watcher watcher,
Stat stat)
getData is an idempotent operation.
|
java.lang.String |
getIdentifier() |
long |
getSessionId() |
byte[] |
getSessionPasswd() |
States |
getState() |
ZooKeeper |
getZooKeeper() |
java.util.List<OpResult> |
multi(java.lang.Iterable<Op> ops)
Run multiple operations in a transactional manner.
|
void |
reconnectAfterExpiration() |
byte[] |
removeMetaData(byte[] data) |
Stat |
setAcl(java.lang.String path,
java.util.List<ACL> acls,
int version)
setAcl is an idempotent operation.
|
Stat |
setData(java.lang.String path,
byte[] data,
int version)
setData is NOT an idempotent operation.
|
void |
sync(java.lang.String path,
AsyncCallback.VoidCallback cb,
java.lang.Object ctx) |
public RecoverableZooKeeper(java.lang.String quorumServers,
int sessionTimeout,
Watcher watcher,
int maxRetries,
int retryIntervalMillis)
throws java.io.IOException
java.io.IOExceptionpublic RecoverableZooKeeper(java.lang.String quorumServers,
int sessionTimeout,
Watcher watcher,
int maxRetries,
int retryIntervalMillis,
java.lang.String identifier)
throws java.io.IOException
java.io.IOExceptionprotected ZooKeeper checkZk()
throws KeeperException
KeeperExceptionpublic void reconnectAfterExpiration()
throws java.io.IOException,
KeeperException,
java.lang.InterruptedException
java.io.IOExceptionKeeperExceptionjava.lang.InterruptedExceptionpublic void delete(java.lang.String path,
int version)
throws java.lang.InterruptedException,
KeeperException
java.lang.InterruptedExceptionKeeperExceptionpublic Stat exists(java.lang.String path,
Watcher watcher)
throws KeeperException,
java.lang.InterruptedException
KeeperExceptionjava.lang.InterruptedExceptionpublic Stat exists(java.lang.String path,
boolean watch)
throws KeeperException,
java.lang.InterruptedException
KeeperExceptionjava.lang.InterruptedExceptionpublic java.util.List<java.lang.String> getChildren(java.lang.String path,
Watcher watcher)
throws KeeperException,
java.lang.InterruptedException
KeeperExceptionjava.lang.InterruptedExceptionpublic byte[] getData(java.lang.String path,
Watcher watcher,
Stat stat)
throws KeeperException,
java.lang.InterruptedException
KeeperExceptionjava.lang.InterruptedExceptionpublic byte[] getData(java.lang.String path,
boolean watch,
Stat stat)
throws KeeperException,
java.lang.InterruptedException
KeeperExceptionjava.lang.InterruptedExceptionpublic Stat setData(java.lang.String path,
byte[] data,
int version)
throws KeeperException,
java.lang.InterruptedException
KeeperExceptionjava.lang.InterruptedExceptionpublic java.util.List<ACL> getAcl(java.lang.String path,
Stat stat)
throws KeeperException,
java.lang.InterruptedException
KeeperExceptionjava.lang.InterruptedExceptionpublic Stat setAcl(java.lang.String path,
java.util.List<ACL> acls,
int version)
throws KeeperException,
java.lang.InterruptedException
KeeperExceptionjava.lang.InterruptedExceptionpublic java.lang.String create(java.lang.String path,
byte[] data,
java.util.List<ACL> acl,
CreateMode createMode)
throws KeeperException,
java.lang.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.
KeeperExceptionjava.lang.InterruptedExceptionpublic java.util.List<OpResult> multi(java.lang.Iterable<Op> ops)
throws KeeperException,
java.lang.InterruptedException
KeeperExceptionjava.lang.InterruptedExceptionpublic byte[] removeMetaData(byte[] data)
public long getSessionId()
public void close()
throws java.lang.InterruptedException
java.lang.InterruptedExceptionpublic States getState()
public ZooKeeper getZooKeeper()
public byte[] getSessionPasswd()
public void sync(java.lang.String path,
AsyncCallback.VoidCallback cb,
java.lang.Object ctx)
throws KeeperException
KeeperExceptionpublic java.lang.String getIdentifier()