/** * Rx version of {@link #add(String, ChunkMeta, String, IndexMeta, Handler)} * @param chunk the chunk to add * @param chunkMeta the chunk's metadata * @param path the path where the chunk should be stored (may be null) * @param indexMeta metadata affecting the way the chunk will be indexed * @return a Completable that completes when the operation has finished */ public Completable rxAdd(String chunk, ChunkMeta chunkMeta, String path, IndexMeta indexMeta) { return Single.create(new SingleOnSubscribeAdapter<Void>(f -> add(chunk, chunkMeta, path, indexMeta, f))).toCompletable(); }
/** * Rx version of {@link #appendTags(String, String, List, Handler)} * @param search the search query * @param path the path where to search for the values (may be null) * @param tags the list of tags to append * @return a Completable that completes when the operation has finished */ public Completable rxAppendTags(String search, String path, List<String> tags) { return Single.create(new SingleOnSubscribeAdapter<Void>(f -> appendTags(search, path, tags, f))).toCompletable(); }
/** * Rx version of {@link #delete(String, String, Handler)} * @param search the search query * @param path the path where to search for the chunks (may be null) * @return a Completable that completes when the operation has finished * @deprecated Call {@link #rxDelete(String, String, DeleteMeta)} * instead with a unique {@code correlationId} in the {@link DeleteMeta} * object so the deletion process can be tracked correctly. This method * will be removed in GeoRocket 2.0.0. */ @Deprecated public Completable rxDelete(String search, String path) { return Single.create(new SingleOnSubscribeAdapter<Void>(f -> delete(search, path, f))).toCompletable(); }
@Override public Router createRouter(Vertx vertx) { this.vertx = vertx; store = new RxStore(StoreFactory.createStore(vertx)); storagePath = vertx.getOrCreateContext().config() .getString(ConfigConstants.STORAGE_FILE_PATH); Router router = Router.router(vertx); router.get("/*").handler(this::onGet); router.put("/*").handler(this::onPut); router.post("/*").handler(this::onPost); router.delete("/*").handler(this::onDelete); return router; }
/** * Remove properties * @param search the search query * @param path the path * @param properties the properties to remove * @param response the http response */ private void removeProperties(String search, String path, String properties, HttpServerResponse response) { List<String> list = Arrays.asList(properties.split(",")); store.removeProperties(search, path, list, ar -> { if (ar.succeeded()) { response .setStatusCode(204) .end(); } else { fail(response, ar.cause()); } }); }
/** * Remove tags * @param search the search query * @param path the path * @param tags the tags to remove * @param response the http response */ private void removeTags(String search, String path, String tags, HttpServerResponse response) { if (tags != null) { List<String> list = Arrays.asList(tags.split(",")); store.removeTags(search, path, list, ar -> { if (ar.succeeded()) { response .setStatusCode(204) .end(); } else { fail(response, ar.cause()); } }); } }
/** * Rx version of {@link #get(String, String, Handler)} * @param search the search query * @param path the path where to search for the chunks (may be null) * @return a Single that emits a cursor that can be used to iterate * over all matched chunks */ public Single<StoreCursor> rxGet(String search, String path) { ObservableFuture<StoreCursor> o = RxHelper.observableFuture(); get(search, path, o.toHandler()); return o.toSingle(); }
/** * Rx version of {@link #getOne(String, Handler)} * @param path the absolute path to the chunk * @return a Single that will emit a read stream that can be used to * get the chunk's contents */ public Single<ChunkReadStream> rxGetOne(String path) { ObservableFuture<ChunkReadStream> o = RxHelper.observableFuture(); getOne(path, o.toHandler()); return o.toSingle(); }
/** * Rx version of {@link #getPropertyValues(String, String, String, Handler)} * @param search the search query * @param path the path where to search for the values (may be null) * @param property the name of the property * @return emits when the values have been retrieved from the store */ public Single<AsyncCursor<String>> rxGetPropertyValues(String search, String path, String property) { ObservableFuture<AsyncCursor<String>> o = RxHelper.observableFuture(); getPropertyValues(search, path, property, o.toHandler()); return o.toSingle(); }
/** * Rx version of {@link #getAttributeValues(String, String, String, Handler)} * @param search the search query * @param path the path where to search for the values (may be null) * @param attribute the name of the attribute * @return emits when the values have been retrieved from the store */ public Single<AsyncCursor<String>> rxGetAttributeValues(String search, String path, String attribute) { ObservableFuture<AsyncCursor<String>> o = RxHelper.observableFuture(); getAttributeValues(search, path, attribute, o.toHandler()); return o.toSingle(); }
@Override public void start() { log.info("Launching importer ..."); store = new RxStore(StoreFactory.createStore(getVertx())); String storagePath = config().getString(ConfigConstants.STORAGE_FILE_PATH); incoming = storagePath + "/incoming"; vertx.eventBus().<JsonObject>localConsumer(AddressConstants.IMPORTER_IMPORT) .toObservable() .onBackpressureBuffer() // unlimited buffer .flatMapCompletable(msg -> { // call onImport() but ignore errors. onImport() will handle errors for us. return onImport(msg).onErrorComplete(); }, false, MAX_PARALLEL_IMPORTS) .subscribe(v -> { // ignore }, err -> { // This is bad. It will unsubscribe the consumer from the eventbus! // Should never happen anyhow. If it does, something else has // completely gone wrong. log.fatal("Could not import file", err); }); vertx.eventBus().localConsumer(AddressConstants.IMPORTER_PAUSE, this::onPause); }
/** * Rx version of {@link #removeProperties(String, String, List, Handler)} * @param search the search query * @param path the path where to search for the values (may be null) * @param properties the list of properties to remove * @return a Completable that completes when the operation has finished */ public Completable rxRemoveProperties(String search, String path, List<String> properties) { return Single.create(new SingleOnSubscribeAdapter<Void>(f -> removeProperties(search, path, properties, f))).toCompletable(); }
/** * Rx version of {@link #removeTags(String, String, List, Handler)} * @param search the search query * @param path the path where to search for the values (may be null) * @param tags the list of tags to remove * @return a Completable that completes when the operation has finished */ public Completable rxRemoveTags(String search, String path, List<String> tags) { return Single.create(new SingleOnSubscribeAdapter<Void>(f -> removeTags(search, path, tags, f))).toCompletable(); } }
.cast(MetaIndexerFactory.class)); store = new RxStore(StoreFactory.createStore(getVertx()));
/** * Rx version of {@link #delete(String, String, DeleteMeta, Handler)} * @param search the search query * @param path the path where to search for the chunks (may be null) * @param deleteMeta a metadata object containing additional information * about the deletion process * @return a Completable that completes when the operation has finished */ public Completable rxDelete(String search, String path, DeleteMeta deleteMeta) { return Single.create(new SingleOnSubscribeAdapter<Void>(f -> delete(search, path, deleteMeta, f))).toCompletable(); }