Package org.apache.zookeeper.AsyncCallback

Examples of org.apache.zookeeper.AsyncCallback.MultiCallback


    private List<OpResult> multi(ZooKeeper zk, Iterable<Op> ops)
    throws KeeperException, InterruptedException {
        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;
View Full Code Here


    private void multiHavingErrors(ZooKeeper zk, Iterable<Op> ops,
            List<Integer> expectedResultCodes, String expectedErr)
            throws KeeperException, InterruptedException {
        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;
View Full Code Here

    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;
View Full Code Here

                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;
View Full Code Here

    private List<OpResult> multi(ZooKeeper zk, Iterable<Op> ops)
    throws KeeperException, InterruptedException {
        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;
View Full Code Here

    private void multiHavingErrors(ZooKeeper zk, Iterable<Op> ops,
            List<Integer> expectedResultCodes, String expectedErr)
            throws KeeperException, InterruptedException {
        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;
View Full Code Here

    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;
View Full Code Here

                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;
View Full Code Here

                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;
View Full Code Here

                                    .substring(chrootPath.length())), rsp.getStat());
                      } else {
                          cb.processResult(rc, clientPath, p.ctx, null, null);
                      }                  
                  } else if (p.response instanceof MultiResponse) {
                    MultiCallback cb = (MultiCallback) p.cb;
                    MultiResponse rsp = (MultiResponse) p.response;
                    if (rc == 0) {
                      List<OpResult> results = rsp.getResultList();
                      int newRc = rc;
                      for (OpResult result : results) {
                        if (result instanceof ErrorResult
                            && KeeperException.Code.OK.intValue() != (newRc = ((ErrorResult) result)
                            .getErr())) {
                          break;
                        }
                      }
                      cb.processResult(newRc, clientPath, p.ctx, results);
                    } else {
                      cb.processResult(rc, clientPath, p.ctx, null);
                    }
                  }  else if (p.cb instanceof VoidCallback) {
                      VoidCallback cb = (VoidCallback) p.cb;
                      cb.processResult(rc, clientPath, p.ctx);
                  }
              }
          } catch (Throwable t) {
              LOG.error("Caught unexpected throwable", t);
          }
View Full Code Here

TOP

Related Classes of org.apache.zookeeper.AsyncCallback.MultiCallback

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.