本文整理汇总了Java中org.apache.zookeeper.KeeperException.getResults方法的典型用法代码示例。如果您正苦于以下问题:Java KeeperException.getResults方法的具体用法?Java KeeperException.getResults怎么用?Java KeeperException.getResults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.zookeeper.KeeperException
的用法示例。
在下文中一共展示了KeeperException.getResults方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TestGetResults
import org.apache.zookeeper.KeeperException; //导入方法依赖的package包/类
@Test
public void TestGetResults() throws Exception {
/* Delete of a node folowed by an update of the (now) deleted node */
Iterable<Op> ops = Arrays.asList(
Op.create("/multi", new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT),
Op.delete("/multi", 0),
Op.setData("/multi", "Y".getBytes(), 0),
Op.create("/foo", new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT)
);
List<OpResult> results = null;
if (useAsync) {
final MultiResult res = new MultiResult();
zk.multi(ops, 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();
}
}
Assert.assertFalse("/multi should have been deleted so setData should have failed",
KeeperException.Code.OK.intValue() == res.rc);
Assert.assertNull(zk.exists("/multi", null));
results = res.results;
} else {
try {
zk.multi(ops);
Assert.fail("/multi should have been deleted so setData should have failed");
} catch (KeeperException e) {
// '/multi' should never have been created as entire op should fail
Assert.assertNull(zk.exists("/multi", null));
results = e.getResults();
}
}
Assert.assertNotNull(results);
for (OpResult r : results) {
LOG.info("RESULT==> " + r);
if (r instanceof ErrorResult) {
ErrorResult er = (ErrorResult) r;
LOG.info("ERROR RESULT: " + er + " ERR=>" + KeeperException.Code.get(er.getErr()));
}
}
}
示例2: testGetResults
import org.apache.zookeeper.KeeperException; //导入方法依赖的package包/类
@Test
public void testGetResults() throws Exception {
/* Delete of a node folowed by an update of the (now) deleted node */
Iterable<Op> ops = Arrays.asList(
Op.create("/multi", new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT),
Op.delete("/multi", 0),
Op.setData("/multi", "Y".getBytes(), 0),
Op.create("/foo", new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT)
);
List<OpResult> results = null;
if (useAsync) {
final MultiResult res = new MultiResult();
zk.multi(ops, 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();
}
}
Assert.assertFalse("/multi should have been deleted so setData should have failed",
KeeperException.Code.OK.intValue() == res.rc);
Assert.assertNull(zk.exists("/multi", null));
results = res.results;
} else {
try {
zk.multi(ops);
Assert.fail("/multi should have been deleted so setData should have failed");
} catch (KeeperException e) {
// '/multi' should never have been created as entire op should fail
Assert.assertNull(zk.exists("/multi", null));
results = e.getResults();
}
}
Assert.assertNotNull(results);
for (OpResult r : results) {
LOG.info("RESULT==> {}", r);
if (r instanceof ErrorResult) {
ErrorResult er = (ErrorResult) r;
LOG.info("ERROR RESULT: {} ERR=>{}", er, KeeperException.Code.get(er.getErr()));
}
}
}