HttpEndpointReference(Vertx vertx, ServiceDiscovery discovery, Record record, JsonObject config) { super(vertx, discovery, record); this.config = config; this.location = new HttpLocation(record.getLocation()); }
private boolean areTheSameService(Record record1, Record record2) { String uuid = record1.getMetadata().getString(KUBERNETES_UUID, ""); String uuid2 = record2.getMetadata().getString(KUBERNETES_UUID, ""); String endpoint = record1.getLocation().getString(Record.ENDPOINT, ""); String endpoint2 = record2.getLocation().getString(Record.ENDPOINT, ""); // Check the uuid and location return uuid.equals(uuid2) && endpoint.equals(endpoint2); }
@Override public ConcurrentMap<String, Record> getRegistryData() { final ConcurrentMap<String, Record> map = this.readData(EtcdPath.IPC); for (final Record record : map.values()) { record.setStatus(Status.UP); record.setType("IPC"); // Alpn Enabled for Rpc, ssl must be true. record.getLocation().put("ssl", Boolean.TRUE); } return map; }
@Override public ConcurrentMap<String, Record> getRegistryData() { final ConcurrentMap<String, Record> map = this.readData(EtcdPath.IPC); for (final Record record : map.values()) { record.setStatus(Status.UP); record.setType("IPC"); // Alpn Enabled for Rpc, ssl must be true. record.getLocation().put("ssl", Boolean.TRUE); } return map; }
public static void in(final IpcData data, final Record record) { if (null != record) { data.setHost(record.getLocation().getString("host")); data.setPort(record.getLocation().getInteger("port")); data.setName(record.getName()); } }
@Override public boolean erasing(final Record record) { final String host = record.getLocation().getString(HOST); final Integer port = record.getLocation().getInteger(PORT); final String name = record.getName(); if (!Ut.netOk(host, port)) { this.registry.erasingStatus(name, host, port, this.getPath()); } return true; }
public static void in(final IpcData data, final Record record) { if (null != record) { data.setHost(record.getLocation().getString("host")); data.setPort(record.getLocation().getInteger("port")); data.setName(record.getName()); } }
/** * Creates the event bus consumer for the service. * * @return the consumer */ @Override public MessageConsumer<X> retrieve() { return vertx.eventBus().consumer(record().getLocation().getString(Record.ENDPOINT)); }
@Override public boolean erasing(final Record record) { final String host = record.getLocation().getString(HOST); final Integer port = record.getLocation().getInteger(PORT); final String name = record.getName(); if (!Ut.netOk(host, port)) { this.registry.erasingStatus(name, host, port, this.getPath()); } return true; }
/** * Creates the event bus consumer for the service. * * @return the consumer */ @Override public MessageConsumer<X> retrieve() { return vertx.eventBus().consumer(record().getLocation().getString(Record.ENDPOINT)); }
/** * Unregisters the published schema indicated by the provided registration. * * @param registration the schema registration */ @Override protected void unregister(SchemaRegistration registration) { consumerManager.unregisterConsumer(registration.getRecord().getLocation().getString(Record.ENDPOINT)); super.unregister(registration); }
private void successLog(final Record record) { final String key = this.getID(record); final String id = record.getRegistration(); final String endpoint = MessageFormat.format("http://{0}:{1}{2}", record.getLocation().getString(Origin.HOST), String.valueOf(record.getLocation().getInteger(Origin.PORT)), record.getMetadata().getString(Origin.PATH)); LOGGER.debug(Info.REG_SUCCESS, record.getStatus(), record.getType(), record.getName(), endpoint, key, id); }
private void successLog(final Record record) { final String key = this.getID(record); final String id = record.getRegistration(); final String endpoint = MessageFormat.format("http://{0}:{1}{2}", record.getLocation().getString(Origin.HOST), String.valueOf(record.getLocation().getInteger(Origin.PORT)), record.getMetadata().getString(Origin.PATH)); LOGGER.debug(Info.REG_SUCCESS, record.getStatus(), record.getType(), record.getName(), endpoint, key, id); }
private void assertRedis(Record record) { assertThat(record.getName()).isEqualTo("DISCOVERY_REDIS"); assertThat(record.getLocation().getString("endpoint")).isEqualToIgnoringCase("tcp://172.17.0.2:6379"); assertThat(record.getMetadata().getString("PORT_6379_TCP_PORT")).isEqualToIgnoringCase("6379"); }
@Test public void testHttpRecordCreation() { Service service = getHttpService(); Record record = KubernetesServiceImporter.createRecord(new JsonObject(Json.encodeToBuffer(service))); assertThat(record).isNotNull(); assertThat(record.getName()).isEqualTo("my-service"); assertThat(record.getMetadata().getString("kubernetes.name")).isEqualTo("my-service"); assertThat(record.getMetadata().getString("kubernetes.namespace")).isEqualTo("my-project"); assertThat(record.getMetadata().getString("kubernetes.uuid")).isEqualTo("uuid"); assertThat(record.getType()).isEqualTo(HttpEndpoint.TYPE); assertThat(record.getLocation().getInteger("port")).isEqualTo(8080); assertThat(record.getLocation().getBoolean("ssl")).isFalse(); }
private void assertRedis(Record record) { assertThat(record.getName()).isEqualTo("DISCOVERY_REDIS"); assertThat(record.getLocation().getString("endpoint")).isEqualToIgnoringCase("tcp://172.17.0.2:6379"); assertThat(record.getMetadata().getString("PORT_6379_TCP_PORT")).isEqualToIgnoringCase("6379"); }
static RequestOptions getOptions(final Record record, final String normalizedUri) { final RequestOptions options = new RequestOptions(); options.setURI(normalizedUri); // Extract host / port final JsonObject location = record.getLocation(); options.setHost(location.getString("host")); options.setPort(location.getInteger("port")); LOGGER.info("[ ZERO ] Found remote host: {0}, port: {1}, uri: {2}", options.getHost(), String.valueOf(options.getPort()), options.getURI()); return options; } }
static RequestOptions getOptions(final Record record, final String normalizedUri) { final RequestOptions options = new RequestOptions(); options.setURI(normalizedUri); // Extract host / port final JsonObject location = record.getLocation(); options.setHost(location.getString("host")); options.setPort(location.getInteger("port")); LOGGER.info("[ ZERO ] Found remote host: {0}, port: {1}, uri: {2}", options.getHost(), String.valueOf(options.getPort()), options.getURI()); return options; } }
@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"); }