List of usage examples for io.vertx.core Future failedFuture
static <T> Future<T> failedFuture(String failureMessage)
From source file:com.emikra.vertx.orientdb.OrientDBServiceVertxEBProxy.java
License:Apache License
public void createClass(CreateClassParams params, Handler<AsyncResult<JsonObject>> handler) { if (closed) { handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return;//from w w w .jav a 2 s . c o m } JsonObject _json = new JsonObject(); _json.put("params", params == null ? null : params.toJson()); DeliveryOptions _deliveryOptions = new DeliveryOptions(); _deliveryOptions.addHeader("action", "createClass"); _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())); } }); }
From source file:com.emikra.vertx.orientdb.OrientDBServiceVertxEBProxy.java
License:Apache License
public void getDocument(JsonObject docQuery, Handler<AsyncResult<JsonObject>> handler) { if (closed) { handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return;/* w w w .j ava2s.co m*/ } JsonObject _json = new JsonObject(); _json.put("docQuery", docQuery); DeliveryOptions _deliveryOptions = new DeliveryOptions(); _deliveryOptions.addHeader("action", "getDocument"); _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())); } }); }
From source file:com.emikra.vertx.orientdb.OrientDBServiceVertxEBProxy.java
License:Apache License
public void getVertex(JsonObject vertexQuery, Handler<AsyncResult<JsonObject>> handler) { if (closed) { handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return;/*from w ww .j a v a 2 s. co m*/ } JsonObject _json = new JsonObject(); _json.put("vertexQuery", vertexQuery); DeliveryOptions _deliveryOptions = new DeliveryOptions(); _deliveryOptions.addHeader("action", "getVertex"); _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())); } }); }
From source file:com.emikra.vertx.orientdb.OrientDBServiceVertxEBProxy.java
License:Apache License
public void getEdge(JsonObject edgeQuery, Handler<AsyncResult<JsonObject>> handler) { if (closed) { handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return;/*from w w w . java2 s.co m*/ } JsonObject _json = new JsonObject(); _json.put("edgeQuery", edgeQuery); DeliveryOptions _deliveryOptions = new DeliveryOptions(); _deliveryOptions.addHeader("action", "getEdge"); _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())); } }); }
From source file:com.englishtown.vertx.elasticsearch.ElasticSearchAdminServiceVertxEBProxy.java
License:Apache License
public void putMapping(List<String> indices, String type, JsonObject source, MappingOptions options, Handler<AsyncResult<JsonObject>> resultHandler) { if (closed) { resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return;/*from www .j a v a 2s .co m*/ } JsonObject _json = new JsonObject(); _json.put("indices", new JsonArray(indices)); _json.put("type", type); _json.put("source", source); _json.put("options", options == null ? null : options.toJson()); DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); _deliveryOptions.addHeader("action", "putMapping"); _vertx.eventBus().<JsonObject>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:com.englishtown.vertx.elasticsearch.ElasticSearchServiceVertxEBProxy.java
License:Apache License
public void index(String index, String type, JsonObject source, IndexOptions options, Handler<AsyncResult<JsonObject>> resultHandler) { if (closed) { resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return;//www.j a v a 2 s .c o m } JsonObject _json = new JsonObject(); _json.put("index", index); _json.put("type", type); _json.put("source", source); _json.put("options", options == null ? null : options.toJson()); DeliveryOptions _deliveryOptions = new DeliveryOptions(); _deliveryOptions.addHeader("action", "index"); _vertx.eventBus().<JsonObject>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:com.englishtown.vertx.elasticsearch.ElasticSearchServiceVertxEBProxy.java
License:Apache License
public void update(String index, String type, String id, UpdateOptions options, Handler<AsyncResult<JsonObject>> resultHandler) { if (closed) { resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return;//from w w w . ja va 2 s.co m } JsonObject _json = new JsonObject(); _json.put("index", index); _json.put("type", type); _json.put("id", id); _json.put("options", options == null ? null : options.toJson()); DeliveryOptions _deliveryOptions = new DeliveryOptions(); _deliveryOptions.addHeader("action", "update"); _vertx.eventBus().<JsonObject>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:com.englishtown.vertx.elasticsearch.ElasticSearchServiceVertxEBProxy.java
License:Apache License
public void get(String index, String type, String id, GetOptions options, Handler<AsyncResult<JsonObject>> resultHandler) { if (closed) { resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return;/*from w w w . j ava 2s . co m*/ } JsonObject _json = new JsonObject(); _json.put("index", index); _json.put("type", type); _json.put("id", id); _json.put("options", options == null ? null : options.toJson()); DeliveryOptions _deliveryOptions = new DeliveryOptions(); _deliveryOptions.addHeader("action", "get"); _vertx.eventBus().<JsonObject>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:com.englishtown.vertx.elasticsearch.ElasticSearchServiceVertxEBProxy.java
License:Apache License
public void search(List<String> indices, SearchOptions options, Handler<AsyncResult<JsonObject>> resultHandler) { if (closed) { resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return;//from www .j a va 2 s.c o m } JsonObject _json = new JsonObject(); _json.put("indices", new JsonArray(indices)); _json.put("options", options == null ? null : options.toJson()); DeliveryOptions _deliveryOptions = new DeliveryOptions(); _deliveryOptions.addHeader("action", "search"); _vertx.eventBus().<JsonObject>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:com.englishtown.vertx.elasticsearch.ElasticSearchServiceVertxEBProxy.java
License:Apache License
public void searchScroll(String scrollId, SearchScrollOptions options, Handler<AsyncResult<JsonObject>> resultHandler) { if (closed) { resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return;//from w w w . j av a 2 s. c o m } JsonObject _json = new JsonObject(); _json.put("scrollId", scrollId); _json.put("options", options == null ? null : options.toJson()); DeliveryOptions _deliveryOptions = new DeliveryOptions(); _deliveryOptions.addHeader("action", "searchScroll"); _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> { if (res.failed()) { resultHandler.handle(Future.failedFuture(res.cause())); } else { resultHandler.handle(Future.succeededFuture(res.result().body())); } }); }