/** * Notify a new record has been published, the record's registration can be used to uniquely * identify the record * @param record the record */ public void onPublish(Record record) { delegate.onPublish(record); }
/** * Notify an existing record has been updated, the record's registration can be used to uniquely * identify the record * @param record the record */ public void onUpdate(Record record) { delegate.onUpdate(record); }
/** * Close the exporter * @param closeHandler the handle to be notified when exporter is closed, may be <code>null</code> */ public void close(Handler<Void> closeHandler) { delegate.close(closeHandler); }
public static void init(io.vertx.servicediscovery.spi.ServiceExporter j_receiver, io.vertx.core.Vertx vertx, io.vertx.servicediscovery.spi.ServicePublisher publisher, java.util.Map<String, Object> configuration, io.vertx.core.Future<java.lang.Void> future) { j_receiver.init(vertx, publisher, configuration != null ? io.vertx.core.impl.ConversionHelper.toJsonObject(configuration) : null, future); } public static void onPublish(io.vertx.servicediscovery.spi.ServiceExporter j_receiver, java.util.Map<String, Object> record) {
/** * Notify an existing record has been removed * @param id the record registration id */ public void onUnpublish(String id) { delegate.onUnpublish(id); }
@Override public ServiceDiscovery registerServiceExporter(ServiceExporter exporter, JsonObject configuration, Handler<AsyncResult<Void>> completionHandler) { JsonObject conf; if (configuration == null) { conf = new JsonObject(); } else { conf = configuration; } Future<Void> completed = Future.future(); completed.setHandler( ar -> { if (ar.failed()) { LOGGER.error("Cannot start the service importer " + exporter, ar.cause()); if (completionHandler != null) { completionHandler.handle(Future.failedFuture(ar.cause())); } } else { exporters.add(exporter); LOGGER.info("Service exporter " + exporter + " started"); if (completionHandler != null) { completionHandler.handle(Future.succeededFuture(null)); } } } ); exporter.init(vertx, this, conf, completed); return this; }
/** * Notify an existing record has been removed * @param id the record registration id */ public void onUnpublish(String id) { delegate.onUnpublish(id); }
@Override public ServiceDiscovery registerServiceExporter(ServiceExporter exporter, JsonObject configuration, Handler<AsyncResult<Void>> completionHandler) { JsonObject conf; if (configuration == null) { conf = new JsonObject(); } else { conf = configuration; } Future<Void> completed = Future.future(); completed.setHandler( ar -> { if (ar.failed()) { LOGGER.error("Cannot start the service importer " + exporter, ar.cause()); if (completionHandler != null) { completionHandler.handle(Future.failedFuture(ar.cause())); } } else { exporters.add(exporter); LOGGER.info("Service exporter " + exporter + " started"); if (completionHandler != null) { completionHandler.handle(Future.succeededFuture(null)); } } } ); exporter.init(vertx, this, conf, completed); return this; }
/** * Notify an existing record has been updated, the record's registration can be used to uniquely * identify the record * @param record the record */ public void onUpdate(Record record) { delegate.onUpdate(record); }
/** * Notify a new record has been published, the record's registration can be used to uniquely * identify the record * @param record the record */ public void onPublish(Record record) { delegate.onPublish(record); }
/** * Close the exporter * @param closeHandler the handle to be notified when exporter is closed, may be <code>null</code> */ public void close(Handler<Void> closeHandler) { delegate.close(closeHandler); }
@Override public void unpublish(String id, Handler<AsyncResult<Void>> resultHandler) { backend.remove(id, record -> { if (record.failed()) { resultHandler.handle(Future.failedFuture(record.cause())); return; } for (ServiceExporter exporter : exporters) { exporter.onUnpublish(id); } Record announcedRecord = new Record(record.result()); announcedRecord .setRegistration(null) .setStatus(Status.DOWN); vertx.eventBus().publish(announce, announcedRecord.toJson()); resultHandler.handle(Future.succeededFuture()); }); }
/** * Starts the exporter. * @param vertx the vertx instance * @param publisher the service discovery instance * @param configuration the bridge configuration if any * @param future a future on which the bridge must report the completion of the starting */ public void init(io.vertx.rxjava.core.Vertx vertx, io.vertx.rxjava.servicediscovery.spi.ServicePublisher publisher, JsonObject configuration, io.vertx.rxjava.core.Future<Void> future) { delegate.init(vertx.getDelegate(), publisher.getDelegate(), configuration, future.getDelegate()); }
public static void onUpdate(io.vertx.servicediscovery.spi.ServiceExporter j_receiver, java.util.Map<String, Object> record) { j_receiver.onUpdate(record != null ? new io.vertx.servicediscovery.Record(io.vertx.core.impl.ConversionHelper.toJsonObject(record)) : null); } }
public static void onPublish(io.vertx.servicediscovery.spi.ServiceExporter j_receiver, java.util.Map<String, Object> record) { j_receiver.onPublish(record != null ? new io.vertx.servicediscovery.Record(io.vertx.core.impl.ConversionHelper.toJsonObject(record)) : null); } public static void onUpdate(io.vertx.servicediscovery.spi.ServiceExporter j_receiver, java.util.Map<String, Object> record) {
@Override public void close() { LOGGER.info("Stopping service discovery"); List<Future> futures = new ArrayList<>(); for (ServiceImporter importer : importers) { Future<Void> future = Future.future(); importer.close(v -> future.complete()); futures.add(future); } for (ServiceExporter exporter : exporters) { Future<Void> future = Future.future(); exporter.close(future::complete); futures.add(future); } bindings.forEach(ServiceReference::release); bindings.clear(); CompositeFuture.all(futures).setHandler(ar -> { if (ar.succeeded()) { LOGGER.info("Discovery bridges stopped"); } else { LOGGER.warn("Some discovery bridges did not stopped smoothly", ar.cause()); } }); }
@Override public void unpublish(String id, Handler<AsyncResult<Void>> resultHandler) { backend.remove(id, record -> { if (record.failed()) { resultHandler.handle(Future.failedFuture(record.cause())); return; } for (ServiceExporter exporter : exporters) { exporter.onUnpublish(id); } Record announcedRecord = new Record(record.result()); announcedRecord .setRegistration(null) .setStatus(Status.DOWN); vertx.eventBus().publish(announce, announcedRecord.toJson()); resultHandler.handle(Future.succeededFuture()); }); }
/** * Starts the exporter. * @param vertx the vertx instance * @param publisher the service discovery instance * @param configuration the bridge configuration if any * @param future a future on which the bridge must report the completion of the starting */ public void init(io.vertx.rxjava.core.Vertx vertx, io.vertx.rxjava.servicediscovery.spi.ServicePublisher publisher, JsonObject configuration, io.vertx.rxjava.core.Future<Void> future) { delegate.init(vertx.getDelegate(), publisher.getDelegate(), configuration, future.getDelegate()); }
@Override public void update(Record record, Handler<AsyncResult<Record>> resultHandler) { backend.update(record, ar -> { if (ar.failed()) { resultHandler.handle(Future.failedFuture(ar.cause())); } else { resultHandler.handle(Future.succeededFuture(record)); } }); for (ServiceExporter exporter : exporters) { exporter.onUpdate(record); } Record announcedRecord = new Record(record); vertx.eventBus().publish(announce, announcedRecord.toJson()); }
@Override public void publish(Record record, Handler<AsyncResult<Record>> resultHandler) { Status status = record.getStatus() == null || record.getStatus() == Status.UNKNOWN ? Status.UP : record.getStatus(); backend.store(record.setStatus(status), ar -> { if (ar.failed()) { resultHandler.handle(Future.failedFuture(ar.cause())); return; } for (ServiceExporter exporter : exporters) { exporter.onPublish(new Record(ar.result())); } Record announcedRecord = new Record(ar.result()); announcedRecord .setRegistration(null) .setStatus(status); vertx.eventBus().publish(announce, announcedRecord.toJson()); resultHandler.handle(Future.succeededFuture(ar.result())); }); }