Package org.vertx.java.core.eventbus

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


    // the other side has registered a handler and responded at least once.
    eventBus.sendWithTimeout(inAddress, new JsonObject().putString("action", "connect"), 1000, new Handler<AsyncResult<Message<Boolean>>>() {
      @Override
      public void handle(AsyncResult<Message<Boolean>> result) {
        if (result.failed()) {
          ReplyException failure = (ReplyException) result.cause();
          if (failure.failureType().equals(ReplyFailure.RECIPIENT_FAILURE)) {
            log.warn(String.format("%s - Failed to connect to %s", DefaultOutputConnection.this, context.target()), result.cause());
            new DefaultFutureResult<Void>(failure).setHandler(doneHandler);
          } else if (failure.failureType().equals(ReplyFailure.TIMEOUT)) {
            log.warn(String.format("%s - Connection to %s failed, retrying", DefaultOutputConnection.this, context.target()));
            connect(doneHandler);
          } else {
            log.debug(String.format("%s - Connection to %s failed, retrying", DefaultOutputConnection.this, context.target()));
            vertx.setTimer(500, new Handler<Long>() {
View Full Code Here


  private void disconnect(final Handler<AsyncResult<Void>> doneHandler) {
    eventBus.sendWithTimeout(inAddress, new JsonObject().putString("action", "disconnect"), 5000, new Handler<AsyncResult<Message<Boolean>>>() {
      @Override
      public void handle(AsyncResult<Message<Boolean>> result) {
        if (result.failed()) {
          ReplyException failure = (ReplyException) result.cause();
          if (failure.failureType().equals(ReplyFailure.RECIPIENT_FAILURE)) {
            log.warn(String.format("%s - Failed to disconnect from %s", DefaultOutputConnection.this, context.target()), result.cause());
            new DefaultFutureResult<Void>(failure).setHandler(doneHandler);
          } else if (failure.failureType().equals(ReplyFailure.NO_HANDLERS)) {
            log.info(String.format("%s - Disconnected from %s", DefaultOutputConnection.this, context.target()));
            new DefaultFutureResult<Void>((Void) null).setHandler(doneHandler);
          } else {
            log.debug(String.format("%s - Disconnection from %s failed, retrying", DefaultOutputConnection.this, context.target()));
            disconnect(doneHandler);
View Full Code Here

    redis.get(getVersionKey(docType, docId), new Handler<Message<JsonObject>>() {
      @Override
      public void handle(Message<JsonObject> reply) {
        JsonObject body = reply.body();
        if (!"ok".equals(body.getString("status"))) {
          callback.handle(new DefaultFutureResult<Long>(new ReplyException(
              ReplyFailure.RECIPIENT_FAILURE, body.getString("message"))));
          return;
        }
        String docVersion = body.getString("value");
        if (docVersion != null) {
View Full Code Here

      @Override
      public void handle(Message<JsonObject> reply) {
        JsonObject body = reply.body();
        if (!"ok".equals(body.getString("status"))) {
          if (opt_callback != null) {
            opt_callback.handle(new DefaultFutureResult<Void>(new ReplyException(
                ReplyFailure.RECIPIENT_FAILURE, body.getString("message"))));
          }
          return;
        }
        if (body.getInteger("value") == 0) {
View Full Code Here

        new Handler<Message<JsonObject>>() {
          @Override
          public void handle(Message<JsonObject> reply) {
            JsonObject body = reply.body();
            if (!"ok".equals(body.getString("status"))) {
              futureResult.setFailure(new ReplyException(ReplyFailure.RECIPIENT_FAILURE, body
                  .getString("message")));
              return;
            }
            JsonArray value = body.getArray("value");
            JsonObject result;
View Full Code Here

            if (opt_callback == null) {
              return;
            }
            JsonObject body = reply.body();
            if (!"ok".equals(body.getString("status"))) {
              opt_callback.handle(new DefaultFutureResult<Void>(new ReplyException(
                  ReplyFailure.RECIPIENT_FAILURE, body.getString("message"))));
              return;
            }
            opt_callback.handle(new DefaultFutureResult<Void>((Void) null));
          }
View Full Code Here

          @Override
          public void handle(Message<JsonObject> reply) {
            DefaultFutureResult<Void> result = new DefaultFutureResult<Void>().setHandler(callback);
            JsonObject body = reply.body();
            if (!"ok".equals(body.getString("status"))) {
              result.setFailure(new ReplyException(ReplyFailure.RECIPIENT_FAILURE, body
                  .getString("status")
                  + ": " + body.getString("message")));
              return;
            }
            if (body.getString("value") != null) {
              result.setFailure(new ReplyException(ReplyFailure.RECIPIENT_FAILURE, body
                  .getString("value")));
              return;
            }
            result.setResult(null);
          }
View Full Code Here

          opVersion = opData.getLong(Key.VERSION);
          try {
            snapshot.consume(transformer.createOperation(new JreJsonObject(opData.toMap())));
          } 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;
          }
        }
        JsonObject root = new JsonObject(((JreJsonObject) snapshot.toJson()).toNative());
View Full Code Here

    List<JsonObject> opLog = getOpLog(docType, docId);
    // This should never actually happen unless there's bugs in delta storage. (Or you try to
    // use this memory implementation with multiple frontend servers)
    if (opData.getLong(Key.VERSION) > opLog.size()) {
      callback.handle(new DefaultFutureResult<Void>(
          new ReplyException(ReplyFailure.RECIPIENT_FAILURE,
              "Internal consistancy error - mutation storage missing parent version")));
      return;
    } else if (opData.getLong(Key.VERSION) == opLog.size()) {
      opLog.add(opData);
    }
View Full Code Here

    long opVersion = opData.getNumber(Key.VERSION).longValue();
    Long docVersion = getSnapshotVersion(docType, docId);
    if (docVersion != null && opVersion < docVersion) {
      callback.handle(new DefaultFutureResult<Void>(
          new ReplyException(ReplyFailure.RECIPIENT_FAILURE, "Transform needed")));
      return;
    }

    versions.put(docType + "/" + docId, opVersion + 1);
    writeOp(docType, docId, opData, new AsyncResultHandler<Void>() {
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.