当前位置: 首页>>代码示例>>Java>>正文


Java ErrorResult类代码示例

本文整理汇总了Java中org.apache.zookeeper.OpResult.ErrorResult的典型用法代码示例。如果您正苦于以下问题:Java ErrorResult类的具体用法?Java ErrorResult怎么用?Java ErrorResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ErrorResult类属于org.apache.zookeeper.OpResult包,在下文中一共展示了ErrorResult类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: TestGetResults

import org.apache.zookeeper.OpResult.ErrorResult; //导入依赖的package包/类
@Test
public void TestGetResults() throws Exception {
    /* Delete of a node folowed by an update of the (now) deleted node */
    try {
        zk.multi(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)
        ));
        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));

        for (OpResult r : e.getResults()) {
            LOG.info("RESULT==> " + r);
            if (r instanceof ErrorResult) {
                ErrorResult er = (ErrorResult) r;
                LOG.info("ERROR RESULT: " + er + " ERR=>" + KeeperException.Code.get(er.getErr()));
            }
        }
    }
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:25,代码来源:MultiTransactionTest.java

示例2: testOpResultEquals

import org.apache.zookeeper.OpResult.ErrorResult; //导入依赖的package包/类
/**
 * Exercise the equals methods of OpResult classes.
 */
@Test
public void testOpResultEquals() {
    opEquals(new CreateResult("/foo"),
            new CreateResult("/foo"),
            new CreateResult("nope"));

    opEquals(new CheckResult(),
            new CheckResult(),
            null);
    
    opEquals(new SetDataResult(new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
            new SetDataResult(new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
            new SetDataResult(new Stat(11, 12, 13, 14, 15, 16, 17, 18, 19, 110, 111)));
    
    opEquals(new ErrorResult(1),
            new ErrorResult(1),
            new ErrorResult(2));
    
    opEquals(new DeleteResult(),
            new DeleteResult(),
            null);

    opEquals(new ErrorResult(1),
            new ErrorResult(1),
            new ErrorResult(2));
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:30,代码来源:MultiTransactionTest.java

示例3: opEquals

import org.apache.zookeeper.OpResult.ErrorResult; //导入依赖的package包/类
private void opEquals(OpResult expected, OpResult value, OpResult near) {
    assertEquals(value, value);
    assertFalse(value.equals(new Object()));
    assertFalse(value.equals(near));
    assertFalse(value.equals(value instanceof CreateResult ?
            new ErrorResult(1) : new CreateResult("nope2")));
    assertTrue(value.equals(expected));
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:9,代码来源:MultiTransactionTest.java

示例4: testOpResultEquals

import org.apache.zookeeper.OpResult.ErrorResult; //导入依赖的package包/类
/**
 * Exercise the equals methods of OpResult classes.
 */
@Test
public void testOpResultEquals() {
    opEquals(new CreateResult("/foo"),
             new CreateResult("/foo"),
             new CreateResult("nope"));

    opEquals(new CreateResult("/foo"),
             new CreateResult("/foo"),
             new CreateResult("/foo", new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)));

    opEquals(new CreateResult("/foo", new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
             new CreateResult("/foo", new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
             new CreateResult("nope", new Stat(11, 12, 13, 14, 15, 16, 17, 18, 19, 110, 111)));

    opEquals(new CreateResult("/foo", new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
             new CreateResult("/foo", new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
             new CreateResult("/foo"));

    opEquals(new CheckResult(),
             new CheckResult(),
             null);

    opEquals(new SetDataResult(new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
             new SetDataResult(new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
             new SetDataResult(new Stat(11, 12, 13, 14, 15, 16, 17, 18, 19, 110, 111)));
    
    opEquals(new ErrorResult(1),
             new ErrorResult(1),
             new ErrorResult(2));
    
    opEquals(new DeleteResult(),
             new DeleteResult(),
             null);

    opEquals(new ErrorResult(1),
             new ErrorResult(1),
             new ErrorResult(2));
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:42,代码来源:MultiTransactionTest.java

示例5: TestGetResults

import org.apache.zookeeper.OpResult.ErrorResult; //导入依赖的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()));
        }
    }
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:54,代码来源:MultiTransactionTest.java

示例6: testGetResults

import org.apache.zookeeper.OpResult.ErrorResult; //导入依赖的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()));
        }
    }
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:54,代码来源:MultiTransactionTest.java

示例7: testSequentialNodeCreateInAsyncMulti

import org.apache.zookeeper.OpResult.ErrorResult; //导入依赖的package包/类
/**
 * ZOOKEEPER-1624: PendingChanges of create sequential node request didn't
 * get rollbacked correctly when multi-op failed. This cause
 * create sequential node request in subsequent multi-op to failed because
 * sequential node name generation is incorrect.
 *
 * The check is to make sure that each request in multi-op failed with
 * the correct reason.
 */
@Test
public void testSequentialNodeCreateInAsyncMulti() throws Exception {
    final int iteration = 4;
    final List<MultiResult> results = new ArrayList<MultiResult>();

    pendingOps.set(iteration);

    List<Op> ops = Arrays.asList(
            Op.create("/node-", new byte[0], Ids.OPEN_ACL_UNSAFE,
                      CreateMode.PERSISTENT_SEQUENTIAL),
            Op.create("/dup", new byte[0], Ids.OPEN_ACL_UNSAFE,
                      CreateMode.PERSISTENT));


    for (int i = 0; i < iteration; ++i) {
        zk.multi(ops, new MultiCallback() {
            @Override
            public void processResult(int rc, String path, Object ctx,
                    List<OpResult> opResults) {
                MultiResult result = new MultiResult();
                result.results = opResults;
                result.rc = rc;
                results.add(result);
                finishPendingOps();
            }
        }, null);
    }

    waitForPendingOps(CONNECTION_TIMEOUT);

    // Check that return code of all request are correct
    assertEquals(KeeperException.Code.OK.intValue(), results.get(0).rc);
    assertEquals(KeeperException.Code.NODEEXISTS.intValue(), results.get(1).rc);
    assertEquals(KeeperException.Code.NODEEXISTS.intValue(), results.get(2).rc);
    assertEquals(KeeperException.Code.NODEEXISTS.intValue(), results.get(3).rc);

    // Check that the first operation is successful in all request
    assertTrue(results.get(0).results.get(0) instanceof CreateResult);
    assertEquals(KeeperException.Code.OK.intValue(),
            ((ErrorResult) results.get(1).results.get(0)).getErr());
    assertEquals(KeeperException.Code.OK.intValue(),
            ((ErrorResult) results.get(2).results.get(0)).getErr());
    assertEquals(KeeperException.Code.OK.intValue(),
            ((ErrorResult) results.get(3).results.get(0)).getErr());

    // Check that the second operation failed after the first request
    assertEquals(KeeperException.Code.NODEEXISTS.intValue(),
            ((ErrorResult) results.get(1).results.get(1)).getErr());
    assertEquals(KeeperException.Code.NODEEXISTS.intValue(),
            ((ErrorResult) results.get(2).results.get(1)).getErr());
    assertEquals(KeeperException.Code.NODEEXISTS.intValue(),
            ((ErrorResult) results.get(3).results.get(1)).getErr());

}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:64,代码来源:MultiAsyncTransactionTest.java

示例8: testGetResults

import org.apache.zookeeper.OpResult.ErrorResult; //导入依赖的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()));
        }
    }
}
 
开发者ID:sereca,项目名称:SecureKeeper,代码行数:54,代码来源:MultiTransactionTest.java


注:本文中的org.apache.zookeeper.OpResult.ErrorResult类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。