本文整理汇总了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);
}