List of usage examples for io.vertx.core Future failedFuture
static <T> Future<T> failedFuture(String failureMessage)
From source file:io.rebind.vertx.orientdb.OrientDBServiceVertxEBProxy.java
License:Apache License
public OrientDBService getRelatedVertices(String sourceId, String label, Handler<AsyncResult<List<Record>>> handler) { if (closed) { handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return this; }//w ww . j ava 2 s .co m JsonObject _json = new JsonObject(); _json.put("sourceId", sourceId); _json.put("label", label); DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); _deliveryOptions.addHeader("action", "getRelatedVertices"); _vertx.eventBus().<JsonArray>send(_address, _json, _deliveryOptions, res -> { if (res.failed()) { handler.handle(Future.failedFuture(res.cause())); } else { handler.handle(Future.succeededFuture(res.result().body().stream().map( o -> o instanceof Map ? new Record(new JsonObject((Map) o)) : new Record((JsonObject) o)) .collect(Collectors.toList()))); } }); return this; }
From source file:io.rebind.vertx.orientdb.OrientDBServiceVertxEBProxy.java
License:Apache License
public OrientDBService addEdge(String sourceId, String destinationId, String label, JsonObject properties, Handler<AsyncResult<Record>> handler) { if (closed) { handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return this; }/*from www .j a v a2 s. c o m*/ JsonObject _json = new JsonObject(); _json.put("sourceId", sourceId); _json.put("destinationId", destinationId); _json.put("label", label); _json.put("properties", properties); DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); _deliveryOptions.addHeader("action", "addEdge"); _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> { if (res.failed()) { handler.handle(Future.failedFuture(res.cause())); } else { handler.handle(Future .succeededFuture(res.result().body() == null ? null : new Record(res.result().body()))); } }); return this; }
From source file:io.rebind.vertx.orientdb.OrientDBServiceVertxEBProxy.java
License:Apache License
public OrientDBService removeEdge(String id, Handler<AsyncResult<Record>> handler) { if (closed) { handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return this; }//from www . j a va 2s . c o m JsonObject _json = new JsonObject(); _json.put("id", id); DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); _deliveryOptions.addHeader("action", "removeEdge"); _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> { if (res.failed()) { handler.handle(Future.failedFuture(res.cause())); } else { handler.handle(Future .succeededFuture(res.result().body() == null ? null : new Record(res.result().body()))); } }); return this; }
From source file:io.rebind.vertx.orientdb.OrientDBServiceVertxEBProxy.java
License:Apache License
public OrientDBService removeEdges(String sourceId, String destinationId, String label, Handler<AsyncResult<List<Record>>> handler) { if (closed) { handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return this; }//from ww w . ja v a 2 s . co m JsonObject _json = new JsonObject(); _json.put("sourceId", sourceId); _json.put("destinationId", destinationId); _json.put("label", label); DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); _deliveryOptions.addHeader("action", "removeEdges"); _vertx.eventBus().<JsonArray>send(_address, _json, _deliveryOptions, res -> { if (res.failed()) { handler.handle(Future.failedFuture(res.cause())); } else { handler.handle(Future.succeededFuture(res.result().body().stream().map( o -> o instanceof Map ? new Record(new JsonObject((Map) o)) : new Record((JsonObject) o)) .collect(Collectors.toList()))); } }); return this; }
From source file:io.rebind.vertx.orientdb.OrientDBServiceVertxEBProxy.java
License:Apache License
public OrientDBService getEdges(String sourceId, String destinationId, String label, Handler<AsyncResult<List<Record>>> handler) { if (closed) { handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return this; }/*from ww w .jav a 2 s .c o m*/ JsonObject _json = new JsonObject(); _json.put("sourceId", sourceId); _json.put("destinationId", destinationId); _json.put("label", label); DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); _deliveryOptions.addHeader("action", "getEdges"); _vertx.eventBus().<JsonArray>send(_address, _json, _deliveryOptions, res -> { if (res.failed()) { handler.handle(Future.failedFuture(res.cause())); } else { handler.handle(Future.succeededFuture(res.result().body().stream().map( o -> o instanceof Map ? new Record(new JsonObject((Map) o)) : new Record((JsonObject) o)) .collect(Collectors.toList()))); } }); return this; }
From source file:io.rebind.vertx.orientdb.OrientDBServiceVertxEBProxy.java
License:Apache License
public OrientDBService getEdge(JsonObject edgeQuery, Handler<AsyncResult<List<Record>>> handler) { if (closed) { handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return this; }//from w w w .java2s.co m JsonObject _json = new JsonObject(); _json.put("edgeQuery", edgeQuery); DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); _deliveryOptions.addHeader("action", "getEdge"); _vertx.eventBus().<JsonArray>send(_address, _json, _deliveryOptions, res -> { if (res.failed()) { handler.handle(Future.failedFuture(res.cause())); } else { handler.handle(Future.succeededFuture(res.result().body().stream().map( o -> o instanceof Map ? new Record(new JsonObject((Map) o)) : new Record((JsonObject) o)) .collect(Collectors.toList()))); } }); return this; }
From source file:io.servicecomb.foundation.vertx.AsyncResultCallback.java
License:Apache License
default void fail(Throwable e) { handle(Future.failedFuture(e)); }
From source file:name.bpdp.vertx.changeme.ChangemeServiceVertxEBProxy.java
License:Apache License
public void method1(String method1Arg, Handler<AsyncResult<String>> resultHandler) { if (closed) { resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return;//from w ww.j a v a 2 s. c om } JsonObject _json = new JsonObject(); _json.put("method1Arg", method1Arg); DeliveryOptions _deliveryOptions = new DeliveryOptions(); _deliveryOptions.addHeader("action", "method1"); _vertx.eventBus().<String>send(_address, _json, _deliveryOptions, res -> { if (res.failed()) { resultHandler.handle(Future.failedFuture(res.cause())); } else { resultHandler.handle(Future.succeededFuture(res.result().body())); } }); }
From source file:net.kuujo.vertigo.deployment.impl.LocalDeploymentManager.java
License:Apache License
@Override public DeploymentManager getNetworkReference(String id, Handler<AsyncResult<NetworkReference>> doneHandler) { return getNetwork(id, result -> { if (result.succeeded()) { try { NetworkReferenceImpl ref = new NetworkReferenceImpl(vertx, result.result()); doneHandler.handle(Future.succeededFuture(ref)); } catch (Throwable throwable) { doneHandler.handle(Future.failedFuture(throwable)); }/* w w w.j ava 2s .c o m*/ } else { doneHandler.handle(Future.failedFuture(result.cause())); } }); }
From source file:net.kuujo.vertigo.util.CountingCompletionHandler.java
License:Apache License
/** * Indicates that a call failed. This will immediately fail the handler. * * @param t The cause of the failure./*from ww w . j av a 2 s. c o m*/ */ public void fail(Throwable t) { if (!failed) { if (doneHandler != null) { doneHandler.handle(Future.failedFuture(t)); } else { cause = t; } failed = true; } }