--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/07e6f9a4-68f8-4380-a5f4-9f1cc492aa86%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
On 7 Jan 2018, at 10:00, 'Gadi Eichhorn' via vert.x <ve...@googlegroups.com> wrote:Thanks Clement,I will try that idea/example.I am using zookeeper as cluster manager. does this supports round-robin?* docker discovery link* zookeeper cluster manager
A strange related issue I get with ZK is that when I restart (docker) I get some caching issue, I can still see the old services. is this because:1. my services records didnt get unpublished?2. ZK keep some cache internally
the only way to remove the old records is to clean docker with> docker system pruneThat removes all cache and then I see just the single record deployedI am using embedded vertx (docker) so maybe I am not getting the SIGTERM properly which keeps the records on ZK.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/d80e531a-bf51-426e-9df8-136c46013a91%40googlegroups.com.
On 7 Jan 2018, at 10:00, 'Gadi Eichhorn' via vert.x <ve...@googlegroups.com> wrote:Thanks Clement,I will try that idea/example.I am using zookeeper as cluster manager. does this supports round-robin?* docker discovery link* zookeeper cluster managerAre you using something like Docker Swarm? If so yes. If not… No I don’t think pure docker does round-robin.
A strange related issue I get with ZK is that when I restart (docker) I get some caching issue, I can still see the old services. is this because:1. my services records didnt get unpublished?2. ZK keep some cache internallyAre you using the Zookeeper Service Discovery Backend or just the Zookeeper cluster manager? In both case, your code must unpublish the services.
compile group: 'io.vertx', name: 'vertx-service-discovery', version: vertx
the only way to remove the old records is to clean docker with> docker system pruneThat removes all cache and then I see just the single record deployedI am using embedded vertx (docker) so maybe I am not getting the SIGTERM properly which keeps the records on ZK.Do you unpublish the services in the `stop` method (from your verticle) ?
On 7 Jan 2018, at 22:48, 'Gadi Eichhorn' via vert.x <ve...@googlegroups.com> wrote:On Sunday, January 7, 2018 at 10:05:46 AM UTC, clement escoffier wrote:On 7 Jan 2018, at 10:00, 'Gadi Eichhorn' via vert.x <ve...@googlegroups.com> wrote:Thanks Clement,I will try that idea/example.I am using zookeeper as cluster manager. does this supports round-robin?* docker discovery link* zookeeper cluster managerAre you using something like Docker Swarm? If so yes. If not… No I don’t think pure docker does round-robin.not using swarm yet, I see your point about the implementation, with a service swarm will handle that for me.A strange related issue I get with ZK is that when I restart (docker) I get some caching issue, I can still see the old services. is this because:1. my services records didnt get unpublished?2. ZK keep some cache internallyAre you using the Zookeeper Service Discovery Backend or just the Zookeeper cluster manager? In both case, your code must unpublish the services.So far just the cluster manager. I didnt see a special backend for zookeeper. I use this:compile group: 'io.vertx', name: 'vertx-service-discovery', version: vertxcompile group: 'io.vertx', name: 'vertx-service-discovery-bridge-docker-links', version: vertxthe only way to remove the old records is to clean docker with> docker system pruneThat removes all cache and then I see just the single record deployedI am using embedded vertx (docker) so maybe I am not getting the SIGTERM properly which keeps the records on ZK.Do you unpublish the services in the `stop` method (from your verticle) ?Yes. With Hazelcast it worked fine, so it is something to do with the ZK implementation that doesn't clean up properly.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/9548cefb-60a5-4be4-abe7-160749ccda81%40googlegroups.com.
compile group: 'io.vertx', name: 'vertx-service-discovery', version: vertx
compile group: 'io.vertx', name: 'vertx-service-discovery-backend-zookeeper', version: vertx
```
vertx.setPeriodic(10000, t -> {
serviceDiscovery.getRecords(r -> r.getType().equals(HttpEndpoint.TYPE), ar -> {
if (ar.succeeded()) {
log.debug("Lookup... {}", ar.result().size());
ar.result().stream()
.forEach(r -> {
records.computeIfAbsent(r.getName(), k -> r);
});
} else {
log.error("Lookup failed", ar.cause());
}
});
log.debug("Records: {}", records);
});
private void onDashboard(RoutingContext context) {
HttpServerRequest request = context.request();
if (records.containsKey(WebClientProvider.SERVICE_NAME)) {
// I have a record to match the name I am after
circuitBreaker.<HttpClientResponse>execute(future -> {
try (ServiceReference serviceReference = serviceDiscovery.getReference(records.get(WebClientProvider.SERVICE_NAME))) {
HttpClient client = serviceReference.getAs(HttpClient.class);
// here I try to delegate the request to the endpoint
client.request(request.method(), request.uri(), dashboard -> {
dashboard.bodyHandler(body -> {
context.response().end(body);
});
future.complete();
});
serviceDiscovery.release(serviceReference);
} catch (Exception ex) {
log.error("Exception", ex);
future.fail(ex);
}
}).setHandler(result -> {
if(result.succeeded()){
// do I return anything here?
}else{
context.response().setStatusCode(500).end(Json.encode(result.cause()));
}
});
} else {
log.warn("Missing client service reference: {}", WebClientProvider.SERVICE_NAME);
log.debug("Clients: {}", records);
}
}
{
cause: null,
stackTrace: [ ],
message: "operation timeout",
localizedMessage: "operation timeout",
suppressed: [ ]
}
gateway_1 | Jan 12, 2018 10:13:59 PM io.vertx.core.http.impl.ConnectionManager
gateway_1 | WARNING: Reusing a connection with a different context: an HttpClient is probably shared between different Verticles
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/9eb4dbe0-204e-4355-8f4e-bda0458b6569%40googlegroups.com.
private void onDashboard(RoutingContext context) {
HttpServerRequest request = context.request();
log.debug("Method: {}", request.method().name());
log.debug("URI: {}", request.uri());
if (records.containsKey(WebClientProvider.SERVICE_NAME)) {
Record record = records.get(WebClientProvider.SERVICE_NAME);
circuitBreaker.executeWithFallback(
future ->
vertx.createHttpClient().request(
request.method(),
record.getLocation().getInteger("port"),
record.getLocation().getString("host"),
request.uri(),
response -> {
response
.exceptionHandler(future::fail)
.bodyHandler(future::complete);
}).exceptionHandler(future::fail).setTimeout(5000).end(),
t -> Buffer.buffer("{\"message\":\"No web client service, or unable to call it\"}")
).setHandler(ar -> context.response().end(ar.result()));