Search in sources :

Example 6 with ErrorResult

use of org.apache.zookeeper.OpResult.ErrorResult in project zookeeper by apache.

the class MultiTransactionTest method opEquals.

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));
}
Also used : CreateResult(org.apache.zookeeper.OpResult.CreateResult) ErrorResult(org.apache.zookeeper.OpResult.ErrorResult)

Example 7 with ErrorResult

use of org.apache.zookeeper.OpResult.ErrorResult in project zookeeper by apache.

the class ZooKeeper method validatePath.

private List<OpResult> validatePath(Iterable<Op> ops) {
    List<OpResult> results = new ArrayList<OpResult>();
    boolean error = false;
    for (Op op : ops) {
        try {
            op.validate();
        } catch (IllegalArgumentException iae) {
            LOG.error("IllegalArgumentException: " + iae.getMessage());
            ErrorResult err = new ErrorResult(KeeperException.Code.BADARGUMENTS.intValue());
            results.add(err);
            error = true;
            continue;
        } catch (KeeperException ke) {
            LOG.error("KeeperException: " + ke.getMessage());
            ErrorResult err = new ErrorResult(ke.code().intValue());
            results.add(err);
            error = true;
            continue;
        }
        ErrorResult err = new ErrorResult(KeeperException.Code.RUNTIMEINCONSISTENCY.intValue());
        results.add(err);
    }
    if (false == error) {
        results.clear();
    }
    return results;
}
Also used : ArrayList(java.util.ArrayList) ErrorResult(org.apache.zookeeper.OpResult.ErrorResult)

Aggregations

ErrorResult (org.apache.zookeeper.OpResult.ErrorResult)7 KeeperException (org.apache.zookeeper.KeeperException)3 OpResult (org.apache.zookeeper.OpResult)3 CreateResult (org.apache.zookeeper.OpResult.CreateResult)3 MultiCallback (org.apache.zookeeper.AsyncCallback.MultiCallback)2 CheckResult (org.apache.zookeeper.OpResult.CheckResult)2 DeleteResult (org.apache.zookeeper.OpResult.DeleteResult)2 SetDataResult (org.apache.zookeeper.OpResult.SetDataResult)2 Stat (org.apache.zookeeper.data.Stat)2 ReplyHeader (org.apache.zookeeper.proto.ReplyHeader)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 ByteBuffer (java.nio.ByteBuffer)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Record (org.apache.jute.Record)1 Code (org.apache.zookeeper.KeeperException.Code)1 SessionMovedException (org.apache.zookeeper.KeeperException.SessionMovedException)1 MultiResponse (org.apache.zookeeper.MultiResponse)1 Op (org.apache.zookeeper.Op)1