Package org.vertx.java.core.eventbus

Examples of org.vertx.java.core.eventbus.ReplyException


    final Object[] results = new Object[2];
    completionHandler.setHandler(new Handler<AsyncResult<Void>>() {
      @Override
      public void handle(AsyncResult<Void> ar) {
        if (ar.failed()) {
          ReplyException cause = (ReplyException) ar.cause();
          resp.fail(cause.failureCode(), cause.getMessage());
          return;
        }
        JsonObject toRtn = (JsonObject) results[0];
        if (toRtn == null) {
          toRtn = new JsonObject();
View Full Code Here


  private void doHead(String docType, String docId, final Message<JsonObject> resp) {
    storage.getVersion(docType, docId, new AsyncResultHandler<Long>() {
      @Override
      public void handle(AsyncResult<Long> ar) {
        if (ar.failed()) {
          ReplyException cause = (ReplyException) ar.cause();
          resp.fail(cause.failureCode(), cause.getMessage());
          return;
        }
        resp.reply(ar.result());
      }
    });
View Full Code Here

      final Message<JsonObject> resp) {
    processor.submit(docType, docId, opData, new AsyncResultHandler<JsonObject>() {
      @Override
      public void handle(AsyncResult<JsonObject> ar) {
        if (ar.failed()) {
          ReplyException cause = (ReplyException) ar.cause();
          resp.fail(cause.failureCode(), cause.getMessage());
          return;
        }
        JsonObject result = ar.result();
        result.removeField(Key.SNAPSHOT);
        resp.reply(result);
View Full Code Here

              long opVersion = opData.getLong(Key.VERSION);
              if (snapshotV == opVersion) {
                try {
                  snapshot.consume(createOperation(opData));
                } catch (Exception e) {
                  callback.handle(new DefaultFutureResult<JsonObject>(new ReplyException(
                      ReplyFailure.RECIPIENT_FAILURE, e.getMessage())));
                  return;
                }
                snapshotV++;
              }
              if (opV == opVersion) {
                transformedOps.add(opData);
                opV++;
              }
            }
            if (opV != snapshotV) {
              callback.handle(new DefaultFutureResult<JsonObject>(new ReplyException(
                  ReplyFailure.RECIPIENT_FAILURE, "Invalid opData version")));
              return;
            }
            CollaborativeOperation transformed = operation;
            if (applyAt != null && ops.size() > 0
                && applyAt <= ops.<JsonObject>get(ops.size() - 1).getLong(Key.VERSION)) {
              try {
                CollaborativeOperation applied =
                    transformer.compose(createOperations(ops, (int) (applyAt - ops
                        .<JsonObject>get(0).getLong(Key.VERSION)), ops.size()));
                transformed = operation.transform(applied, false);
              } catch (Exception e) {
                log.log(Level.WARNING, "Failed to transform operation", e);
                callback.handle(new DefaultFutureResult<JsonObject>(new ReplyException(
                    ReplyFailure.RECIPIENT_FAILURE, e.getMessage())));
                return;
              }
            }

            // Ok, now we can try to apply the op.
            try {
              snapshot.consume(transformed);
            } catch (Exception e) {
              log.log(Level.WARNING, "Failed to consume operation", e);
              callback.handle(new DefaultFutureResult<JsonObject>(new ReplyException(
                  ReplyFailure.RECIPIENT_FAILURE, e.getMessage())));
              return;
            }
            doSubmit(transformedOps, docType, docId, transformed, opV, snapshot, callback);
          }
View Full Code Here

    }
    storage.getOps(docType, docId, from, to, new AsyncResultHandler<JsonObject>() {
      @Override
      public void handle(AsyncResult<JsonObject> ar) {
        if (ar.failed()) {
          ReplyException cause = (ReplyException) ar.cause();
          resp.fail(cause.failureCode(), cause.getMessage());
          return;
        }
        resp.reply(ar.result().getArray(Key.OPS));
      }
    });
View Full Code Here

TOP

Related Classes of org.vertx.java.core.eventbus.ReplyException

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.