本文整理匯總了Java中org.apache.zookeeper.KeeperException.Code.get方法的典型用法代碼示例。如果您正苦於以下問題:Java Code.get方法的具體用法?Java Code.get怎麽用?Java Code.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.zookeeper.KeeperException.Code
的用法示例。
在下文中一共展示了Code.get方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: processResult
import org.apache.zookeeper.KeeperException.Code; //導入方法依賴的package包/類
public void processResult(int rc, String path, Object ctx,
List<ACL> acl, Stat stat)
{
this.acl = acl;
this.stat = stat;
super.processResult(Code.get(rc), path, ctx);
}
示例2: processResult
import org.apache.zookeeper.KeeperException.Code; //導入方法依賴的package包/類
public void processResult(int rc, String path, Object ctx, byte[] data,
Stat stat)
{
this.data = data;
this.stat = stat;
super.processResult(Code.get(rc), path, ctx);
}
示例3: processResult
import org.apache.zookeeper.KeeperException.Code; //導入方法依賴的package包/類
public void processResult(int rc, String path, Object ctx,
List<String> children)
{
this.children =
(children == null ? new ArrayList<String>() : children);
Collections.sort(this.children);
super.processResult(Code.get(rc), path, ctx);
}
示例4: processResult
import org.apache.zookeeper.KeeperException.Code; //導入方法依賴的package包/類
/**
* interface implementation of Zookeeper callback for create
*/
@Override
public synchronized void processResult(int rc, String path, Object ctx,
String name) {
if (isStaleClient(ctx)) return;
if (LOG.isDebugEnabled()) {
LOG.debug("CreateNode result: " + rc + " for path: " + path
+ " connectionState: " + zkConnectionState +
" for " + this);
}
Code code = Code.get(rc);
if (isSuccess(code)) {
// we successfully created the znode. we are the leader. start monitoring
if (becomeActive()) {
monitorActiveStatus();
} else {
reJoinElectionAfterFailureToBecomeActive();
}
return;
}
if (isNodeExists(code)) {
if (createRetryCount == 0) {
// znode exists and we did not retry the operation. so a different
// instance has created it. become standby and monitor lock.
becomeStandby();
}
// if we had retried then the znode could have been created by our first
// attempt to the server (that we lost) and this node exists response is
// for the second attempt. verify this case via ephemeral node owner. this
// will happen on the callback for monitoring the lock.
monitorActiveStatus();
return;
}
String errorMessage = "Received create error from Zookeeper. code:"
+ code.toString() + " for path " + path;
LOG.debug(errorMessage);
if (shouldRetry(code)) {
if (createRetryCount < maxRetryNum) {
LOG.debug("Retrying createNode createRetryCount: " + createRetryCount);
++createRetryCount;
createLockNodeAsync();
return;
}
errorMessage = errorMessage
+ ". Not retrying further znode create connection errors.";
} else if (isSessionExpired(code)) {
// This isn't fatal - the client Watcher will re-join the election
LOG.warn("Lock acquisition failed because session was lost");
return;
}
fatalError(errorMessage);
}