private List<OpResult> commit(Transaction txn)
throws KeeperException, InterruptedException {
if (useAsync) {
final MultiResult res = new MultiResult();
txn.commit(new MultiCallback() {
@Override
public void processResult(int rc, String path, Object ctx,
List<OpResult> opResults) {
synchronized (res) {
res.rc = rc;
res.results = opResults;
res.finished = true;
res.notifyAll();
}
}
}, null);
synchronized (res) {
while (!res.finished) {
res.wait();
}
}
if (KeeperException.Code.OK.intValue() != res.rc) {
KeeperException ke = KeeperException.create(KeeperException.Code.get(res.rc));
throw ke;
}
return res.results;
} else {
return txn.commit();
}
}
MultiTransactionTest.java 文件源码
java
阅读 36
收藏 0
点赞 0
评论 0
项目:https-github.com-apache-zookeeper
作者:
评论列表
文章目录