|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.hadoop.hbase.zookeeper.RecoverableZooKeeper
@InterfaceAudience.Private public class RecoverableZooKeeper
A zookeeper that can handle 'recoverable' errors. To handle recoverable errors, developers need to realize that there are two classes of requests: idempotent and non-idempotent requests. Read requests and unconditional sets and deletes are examples of idempotent requests, they can be reissued with the same results. (Although, the delete may throw a NoNodeException on reissue its effect on the ZooKeeper state is the same.) Non-idempotent requests need special handling, application and library writers need to keep in mind that they may need to encode information in the data or name of znodes to detect retries. A simple example is a create that uses a sequence flag. If a process issues a create("/x-", ..., SEQUENCE) and gets a connection loss exception, that process will reissue another create("/x-", ..., SEQUENCE) and get back x-111. When the process does a getChildren("/"), it sees x-1,x-30,x-109,x-110,x-111, now it could be that x-109 was the result of the previous create, so the process actually owns both x-109 and x-111. An easy way around this is to use "x-process id-" when doing the create. If the process is using an id of 352, before reissuing the create it will do a getChildren("/") and see "x-222-1", "x-542-30", "x-352-109", x-333-110". The process will know that the original create succeeded an the znode it created is "x-352-109".
Constructor Summary | |
---|---|
RecoverableZooKeeper(String quorumServers,
int sessionTimeout,
org.apache.zookeeper.Watcher watcher,
int maxRetries,
int retryIntervalMillis)
|
|
RecoverableZooKeeper(String quorumServers,
int sessionTimeout,
org.apache.zookeeper.Watcher watcher,
int maxRetries,
int retryIntervalMillis,
String identifier)
|
Method Summary | |
---|---|
protected org.apache.zookeeper.ZooKeeper |
checkZk()
Try to create a Zookeeper connection. |
void |
close()
|
String |
create(String path,
byte[] data,
List<org.apache.zookeeper.data.ACL> acl,
org.apache.zookeeper.CreateMode createMode)
NONSEQUENTIAL create is idempotent operation. |
void |
delete(String path,
int version)
delete is an idempotent operation. |
org.apache.zookeeper.data.Stat |
exists(String path,
boolean watch)
exists is an idempotent operation. |
org.apache.zookeeper.data.Stat |
exists(String path,
org.apache.zookeeper.Watcher watcher)
exists is an idempotent operation. |
List<org.apache.zookeeper.data.ACL> |
getAcl(String path,
org.apache.zookeeper.data.Stat stat)
getAcl is an idempotent operation. |
List<String> |
getChildren(String path,
boolean watch)
getChildren is an idempotent operation. |
List<String> |
getChildren(String path,
org.apache.zookeeper.Watcher watcher)
getChildren is an idempotent operation. |
byte[] |
getData(String path,
boolean watch,
org.apache.zookeeper.data.Stat stat)
getData is an idemnpotent operation. |
byte[] |
getData(String path,
org.apache.zookeeper.Watcher watcher,
org.apache.zookeeper.data.Stat stat)
getData is an idempotent operation. |
String |
getIdentifier()
|
long |
getSessionId()
|
byte[] |
getSessionPasswd()
|
org.apache.zookeeper.ZooKeeper.States |
getState()
|
org.apache.zookeeper.ZooKeeper |
getZooKeeper()
|
List<org.apache.zookeeper.OpResult> |
multi(Iterable<org.apache.zookeeper.Op> ops)
Run multiple operations in a transactional manner. |
void |
reconnectAfterExpiration()
|
byte[] |
removeMetaData(byte[] data)
|
org.apache.zookeeper.data.Stat |
setAcl(String path,
List<org.apache.zookeeper.data.ACL> acls,
int version)
setAcl is an idempotent operation. |
org.apache.zookeeper.data.Stat |
setData(String path,
byte[] data,
int version)
setData is NOT an idempotent operation. |
void |
sync(String path,
org.apache.zookeeper.AsyncCallback.VoidCallback cb,
Object ctx)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RecoverableZooKeeper(String quorumServers, int sessionTimeout, org.apache.zookeeper.Watcher watcher, int maxRetries, int retryIntervalMillis) throws IOException
IOException
public RecoverableZooKeeper(String quorumServers, int sessionTimeout, org.apache.zookeeper.Watcher watcher, int maxRetries, int retryIntervalMillis, String identifier) throws IOException
IOException
Method Detail |
---|
protected org.apache.zookeeper.ZooKeeper checkZk() throws org.apache.zookeeper.KeeperException
org.apache.zookeeper.KeeperException
public void reconnectAfterExpiration() throws IOException, org.apache.zookeeper.KeeperException, InterruptedException
IOException
org.apache.zookeeper.KeeperException
InterruptedException
public void delete(String path, int version) throws InterruptedException, org.apache.zookeeper.KeeperException
InterruptedException
org.apache.zookeeper.KeeperException
public org.apache.zookeeper.data.Stat exists(String path, org.apache.zookeeper.Watcher watcher) throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperException
InterruptedException
public org.apache.zookeeper.data.Stat exists(String path, boolean watch) throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperException
InterruptedException
public List<String> getChildren(String path, org.apache.zookeeper.Watcher watcher) throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperException
InterruptedException
public List<String> getChildren(String path, boolean watch) throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperException
InterruptedException
public byte[] getData(String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.data.Stat stat) throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperException
InterruptedException
public byte[] getData(String path, boolean watch, org.apache.zookeeper.data.Stat stat) throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperException
InterruptedException
public org.apache.zookeeper.data.Stat setData(String path, byte[] data, int version) throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperException
InterruptedException
public List<org.apache.zookeeper.data.ACL> getAcl(String path, org.apache.zookeeper.data.Stat stat) throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperException
InterruptedException
public org.apache.zookeeper.data.Stat setAcl(String path, List<org.apache.zookeeper.data.ACL> acls, int version) throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperException
InterruptedException
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
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.
org.apache.zookeeper.KeeperException
InterruptedException
public List<org.apache.zookeeper.OpResult> multi(Iterable<org.apache.zookeeper.Op> ops) throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperException
InterruptedException
public byte[] removeMetaData(byte[] data)
public long getSessionId()
public void close() throws InterruptedException
InterruptedException
public org.apache.zookeeper.ZooKeeper.States getState()
public org.apache.zookeeper.ZooKeeper getZooKeeper()
public byte[] getSessionPasswd()
public void sync(String path, org.apache.zookeeper.AsyncCallback.VoidCallback cb, Object ctx) throws org.apache.zookeeper.KeeperException
org.apache.zookeeper.KeeperException
public String getIdentifier()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |