@Override public ServiceDiscovery registerServiceImporter(ServiceImporter importer, JsonObject configuration, Handler<AsyncResult<Void>> completionHandler) { return unmanagedDiscoveryInstance.registerServiceImporter(importer, configuration, completionHandler); }
/** * {@inheritDoc} */ @Override public ServiceDiscovery registerServiceImporter(ServiceImporter importer, JsonObject configuration) { return unmanagedDiscoveryInstance.registerServiceImporter(importer, configuration); }
/** * Registers a discovery service importer. Importers let you integrate other discovery technologies in this service * discovery. * @param importer the service importer * @param configuration the optional configuration * @return the current {@link io.vertx.rxjava.servicediscovery.ServiceDiscovery} */ public io.vertx.rxjava.servicediscovery.ServiceDiscovery registerServiceImporter(io.vertx.rxjava.servicediscovery.spi.ServiceImporter importer, JsonObject configuration) { io.vertx.rxjava.servicediscovery.ServiceDiscovery ret = io.vertx.rxjava.servicediscovery.ServiceDiscovery.newInstance(delegate.registerServiceImporter(importer.getDelegate(), configuration)); return ret; }
/** * Registers a discovery service importer. Importers let you integrate other discovery technologies in this service * discovery. * @param importer the service importer * @param configuration the optional configuration * @return the current {@link io.vertx.rxjava.servicediscovery.ServiceDiscovery} */ public io.vertx.rxjava.servicediscovery.ServiceDiscovery registerServiceImporter(io.vertx.rxjava.servicediscovery.spi.ServiceImporter importer, JsonObject configuration) { io.vertx.rxjava.servicediscovery.ServiceDiscovery ret = io.vertx.rxjava.servicediscovery.ServiceDiscovery.newInstance(delegate.registerServiceImporter(importer.getDelegate(), configuration)); return ret; }
/** * Registers a discovery service importer. Importers let you integrate other discovery technologies in this service * discovery. * @param importer the service importer * @param configuration the optional configuration * @param completionHandler handler call when the importer has finished its initialization and initial imports * @return the current {@link io.vertx.rxjava.servicediscovery.ServiceDiscovery} */ public io.vertx.rxjava.servicediscovery.ServiceDiscovery registerServiceImporter(io.vertx.rxjava.servicediscovery.spi.ServiceImporter importer, JsonObject configuration, Handler<AsyncResult<Void>> completionHandler) { io.vertx.rxjava.servicediscovery.ServiceDiscovery ret = io.vertx.rxjava.servicediscovery.ServiceDiscovery.newInstance(delegate.registerServiceImporter(importer.getDelegate(), configuration, completionHandler)); return ret; }
public static io.vertx.servicediscovery.ServiceDiscovery registerServiceImporter(io.vertx.servicediscovery.ServiceDiscovery j_receiver, io.vertx.servicediscovery.spi.ServiceImporter importer, java.util.Map<String, Object> configuration) { return io.vertx.core.impl.ConversionHelper.fromObject(j_receiver.registerServiceImporter(importer, configuration != null ? io.vertx.core.impl.ConversionHelper.toJsonObject(configuration) : null)); } public static io.vertx.servicediscovery.ServiceDiscovery registerServiceImporter(io.vertx.servicediscovery.ServiceDiscovery j_receiver, io.vertx.servicediscovery.spi.ServiceImporter importer, java.util.Map<String, Object> configuration, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> completionHandler) {
public static io.vertx.servicediscovery.ServiceDiscovery registerServiceImporter(io.vertx.servicediscovery.ServiceDiscovery j_receiver, io.vertx.servicediscovery.spi.ServiceImporter importer, java.util.Map<String, Object> configuration, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> completionHandler) { return io.vertx.core.impl.ConversionHelper.fromObject(j_receiver.registerServiceImporter(importer, configuration != null ? io.vertx.core.impl.ConversionHelper.toJsonObject(configuration) : null, completionHandler != null ? new io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>() { public void handle(io.vertx.core.AsyncResult<java.lang.Void> ar) { completionHandler.handle(ar.map(event -> io.vertx.core.impl.ConversionHelper.fromObject(event))); } } : null)); } public static io.vertx.servicediscovery.ServiceDiscovery registerServiceExporter(io.vertx.servicediscovery.ServiceDiscovery j_receiver, io.vertx.servicediscovery.spi.ServiceExporter exporter, java.util.Map<String, Object> configuration) {
/** * Registers a discovery service importer. Importers let you integrate other discovery technologies in this service * discovery. * @param importer the service importer * @param configuration the optional configuration * @param completionHandler handler call when the importer has finished its initialization and initial imports * @return the current {@link io.vertx.rxjava.servicediscovery.ServiceDiscovery} */ public io.vertx.rxjava.servicediscovery.ServiceDiscovery registerServiceImporter(io.vertx.rxjava.servicediscovery.spi.ServiceImporter importer, JsonObject configuration, Handler<AsyncResult<Void>> completionHandler) { io.vertx.rxjava.servicediscovery.ServiceDiscovery ret = io.vertx.rxjava.servicediscovery.ServiceDiscovery.newInstance(delegate.registerServiceImporter(importer.getDelegate(), configuration, completionHandler)); return ret; }
@Test public void testHttpImport() { services.add(buildService("172.17.0.2", "web", "web", new String[]{"rails", "http-endpoint"}, 80, "passing")); discovery = ServiceDiscovery.create(vertx) .registerServiceImporter(new ConsulServiceImporter(), new JsonObject().put("host", "localhost").put("port", 5601)); await().until(() -> getAllRecordsBlocking().size() > 0); List<Record> list = getAllRecordsBlocking(); assertThat(list).hasSize(1); assertThat(list.get(0).getType()).isEqualTo(HttpEndpoint.TYPE); assertThat(list.get(0).getLocation().getString("endpoint")).isEqualTo("http://172.17.0.2:80"); }
@Test public void testHttpImport() { services.add(buildService("172.17.0.2", "web", "web", new String[]{"rails", "http-endpoint"}, 80, "passing")); discovery = ServiceDiscovery.create(vertx) .registerServiceImporter(new ConsulServiceImporter(), new JsonObject().put("host", "localhost").put("port", 5601)); await().until(() -> getAllRecordsBlocking().size() > 0); List<Record> list = getAllRecordsBlocking(); assertThat(list).hasSize(1); assertThat(list.get(0).getType()).isEqualTo(HttpEndpoint.TYPE); assertThat(list.get(0).getLocation().getString("endpoint")).isEqualTo("http://172.17.0.2:80"); }
@Test public void testImportServicesWithWarningStatusThreshold() { services.add(buildService("10.1.10.12", "redis", "redis", null, 8000, "passing")); services.add(buildService("10.1.10.12", "warning", "warning", null, 8001, "warning")); discovery = ServiceDiscovery.create(vertx) .registerServiceImporter(new ConsulServiceImporter(), new JsonObject().put("host", "localhost").put("port", 5601).put("up_threshold", "warning")); await().until(() -> getAllRecordsBlocking().size() > 0); List<Record> list = getAllRecordsBlocking(); assertThat(list).hasSize(2); }
@Test public void testImportServicesWithWarningStatusThreshold() { services.add(buildService("10.1.10.12", "redis", "redis", null, 8000, "passing")); services.add(buildService("10.1.10.12", "warning", "warning", null, 8001, "warning")); discovery = ServiceDiscovery.create(vertx) .registerServiceImporter(new ConsulServiceImporter(), new JsonObject().put("host", "localhost").put("port", 5601).put("up_threshold", "warning")); await().until(() -> getAllRecordsBlocking().size() > 0); List<Record> list = getAllRecordsBlocking(); assertThat(list).hasSize(2); }
@Test public void testDoesNotImportServicesWithWarningStatus() { // add 2 services so we can await on 1 being added below services.add(buildService("10.1.10.12", "redis", "redis", null, 8000, "passing")); services.add(buildService("10.1.10.12", "warning", "warning", null, 8001, "warning")); discovery = ServiceDiscovery.create(vertx) .registerServiceImporter(new ConsulServiceImporter(), new JsonObject().put("host", "localhost").put("port", 5601)); await().until(() -> getAllRecordsBlocking().size() > 0); List<Record> list = getAllRecordsBlocking(); assertThat(list).hasSize(1); }
@Test public void testDoesNotImportServicesWithWarningStatus() { // add 2 services so we can await on 1 being added below services.add(buildService("10.1.10.12", "redis", "redis", null, 8000, "passing")); services.add(buildService("10.1.10.12", "warning", "warning", null, 8001, "warning")); discovery = ServiceDiscovery.create(vertx) .registerServiceImporter(new ConsulServiceImporter(), new JsonObject().put("host", "localhost").put("port", 5601)); await().until(() -> getAllRecordsBlocking().size() > 0); List<Record> list = getAllRecordsBlocking(); assertThat(list).hasSize(1); }
@Test public void testAServiceBeingTwiceInConsul() { services.add(buildService("10.4.7.221", "ubuntu221:mysql:3306", "db", new String[] {"master", "backups"}, 32769, "passing")); services.add(buildService("10.4.7.220", "ubuntu220:mysql:3306", "db", new String[] {"master", "backups"}, 32771, "passing")); discovery = ServiceDiscovery.create(vertx) .registerServiceImporter(new ConsulServiceImporter(), new JsonObject().put("host", "localhost").put("port", 5601)); await().until(() -> getAllRecordsBlocking().size() > 0); List<Record> list = getAllRecordsBlocking(); assertThat(list).hasSize(2); }
@Test public void testAServiceBeingTwiceInConsul() { services.add(buildService("10.4.7.221", "ubuntu221:mysql:3306", "db", new String[] {"master", "backups"}, 32769, "passing")); services.add(buildService("10.4.7.220", "ubuntu220:mysql:3306", "db", new String[] {"master", "backups"}, 32771, "passing")); discovery = ServiceDiscovery.create(vertx) .registerServiceImporter(new ConsulServiceImporter(), new JsonObject().put("host", "localhost").put("port", 5601)); await().until(() -> getAllRecordsBlocking().size() > 0); List<Record> list = getAllRecordsBlocking(); assertThat(list).hasSize(2); }
@Test public void testBasicImport() { services.add(buildService("10.1.10.12", "redis", "redis", null, 8000, "passing")); discovery = ServiceDiscovery.create(vertx) .registerServiceImporter(new ConsulServiceImporter(), new JsonObject().put("host", "localhost").put("port", 5601)); await().until(() -> getAllRecordsBlocking().size() > 0); List<Record> list = getAllRecordsBlocking(); assertThat(list).hasSize(1); Record record = list.get(0); assertThat(record.getLocation().getString("host")).isEqualTo("10.1.10.12"); assertThat(record.getLocation().getInteger("port")).isEqualTo(8000); assertThat(record.getLocation().getString("path")).isNull(); assertThat(record.getName()).isEqualTo("redis"); assertThat(record.getRegistration()).isNotEmpty(); }
@Test public void testBasicImport() { services.add(buildService("10.1.10.12", "redis", "redis", null, 8000, "passing")); discovery = ServiceDiscovery.create(vertx) .registerServiceImporter(new ConsulServiceImporter(), new JsonObject().put("host", "localhost").put("port", 5601)); await().until(() -> getAllRecordsBlocking().size() > 0); List<Record> list = getAllRecordsBlocking(); assertThat(list).hasSize(1); Record record = list.get(0); assertThat(record.getLocation().getString("host")).isEqualTo("10.1.10.12"); assertThat(record.getLocation().getInteger("port")).isEqualTo(8000); assertThat(record.getLocation().getString("path")).isNull(); assertThat(record.getName()).isEqualTo("redis"); assertThat(record.getRegistration()).isNotEmpty(); }
@Before public void setUp() { init(); client = DockerClientBuilder.getInstance().build(); List<Container> running = client.listContainersCmd().withStatusFilter("running").exec(); if (running != null) { running.forEach(container -> client.stopContainerCmd(container.getId()).exec()); } vertx = Vertx.vertx(); discovery = ServiceDiscovery.create(vertx); bridge = new DockerServiceImporter(); discovery.registerServiceImporter(bridge, new JsonObject().put("scan-period", -1)); await().until(() -> bridge.started); }
@Before public void setUp() { init(); client = DockerClientBuilder.getInstance().build(); List<Container> running = client.listContainersCmd().withStatusFilter("running").exec(); if (running != null) { running.forEach(container -> client.stopContainerCmd(container.getId()).exec()); } vertx = Vertx.vertx(); discovery = ServiceDiscovery.create(vertx); bridge = new DockerServiceImporter(); discovery.registerServiceImporter(bridge, new JsonObject().put("scan-period", -1)); await().until(() -> bridge.started); }