From 3922d1222ed567aa30d93efd5d128547f965fdf0 Mon Sep 17 00:00:00 2001 From: Ludovic Claude <ludovic.claude54@gmail.com> Date: Fri, 20 Apr 2018 11:05:13 +0200 Subject: [PATCH] Use Artery TCP for Akka remoting --- Dockerfile | 4 +++- .../hbp/mip/akka/WokenClientController.java | 8 +++---- .../mip/configuration/AkkaConfiguration.java | 2 +- src/main/resources/application.conf | 22 ++++++++++--------- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index 62f9a2624..1ddc78d9a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,7 +24,9 @@ COPY docker/README.md docker/run.sh / COPY --from=java-build-env /project/target/portal-backend.jar /usr/share/jars/ -EXPOSE 8080 +# 8080: Web service API, health checks on http://host:8087/health +# 4089: Akka cluster +EXPOSE 4089 8080 ENTRYPOINT ["/run.sh"] diff --git a/src/main/java/eu/hbp/mip/akka/WokenClientController.java b/src/main/java/eu/hbp/mip/akka/WokenClientController.java index f66b558ab..5931c13eb 100644 --- a/src/main/java/eu/hbp/mip/akka/WokenClientController.java +++ b/src/main/java/eu/hbp/mip/akka/WokenClientController.java @@ -51,7 +51,7 @@ public abstract class WokenClientController { protected <A, B> B askWoken(A message, int waitInSeconds) throws Exception { LOGGER.info("Akka is trying to reach remote " + wokenPath); - DistributedPubSubMediator.Send queryMessage = new DistributedPubSubMediator.Send(wokenPath, message, true); + DistributedPubSubMediator.Send queryMessage = new DistributedPubSubMediator.Send(wokenPath, message, false); Timeout timeout = new Timeout(Duration.create(waitInSeconds, "seconds")); Future<Object> future = Patterns.ask(wokenMediator, queryMessage, timeout); @@ -81,12 +81,12 @@ public abstract class WokenClientController { } } - protected <A extends Query> Future<Object> sendWokenQuery(A query, int timeout) { + protected <A extends Query> Future<Object> sendWokenQuery(A query, int waitInSeconds) { LOGGER.info("Akka is trying to reach remote " + wokenPath); - DistributedPubSubMediator.Send queryMessage = new DistributedPubSubMediator.Send(wokenPath, query, true); + DistributedPubSubMediator.Send queryMessage = new DistributedPubSubMediator.Send(wokenPath, query, false); - return Patterns.ask(wokenMediator, queryMessage, timeout); + return Patterns.ask(wokenMediator, queryMessage, waitInSeconds); } protected ExecutionContext getExecutor() { diff --git a/src/main/java/eu/hbp/mip/configuration/AkkaConfiguration.java b/src/main/java/eu/hbp/mip/configuration/AkkaConfiguration.java index 9cda0c97e..cfcfefe7d 100644 --- a/src/main/java/eu/hbp/mip/configuration/AkkaConfiguration.java +++ b/src/main/java/eu/hbp/mip/configuration/AkkaConfiguration.java @@ -35,7 +35,7 @@ class AkkaConfiguration { @Bean public ActorSystem actorSystem() { Config config = ConfigFactory.load("application.conf"); - ActorSystem system = ActorSystem.create("PortalBackend", config); + ActorSystem system = ActorSystem.create("woken", config); SPRING_EXTENSION_PROVIDER.get(system).initialize(applicationContext); return system; } diff --git a/src/main/resources/application.conf b/src/main/resources/application.conf index 9ba1bc59e..ef6b89391 100644 --- a/src/main/resources/application.conf +++ b/src/main/resources/application.conf @@ -14,6 +14,8 @@ akka { actor { provider = "cluster" + + allow-java-serialization = off } remote { @@ -27,23 +29,23 @@ akka { acceptable-heartbeat-pause = 20 s } - netty.tcp { - message-frame-size = 10000000b - send-buffer-size = 10000000b - receive-buffer-size = 10000000b - maximum-frame-size = 10000000b + artery { + enabled = on + transport = tcp + + canonical.hostname = ${clustering.ip} # external (logical) hostname + canonical.port = ${clustering.port} # external (logical) port - hostname = ${clustering.ip} # external (logical) hostname - port = ${clustering.port} # external (logical) port + bind.hostname = 0.0.0.0 # internal (bind) hostname + bind.port = ${clustering.port} # internal (bind) port - bind-hostname = 0.0.0.0 # internal (bind) hostname - bind-port = ${clustering.port} # internal (bind) port } + } cluster { seed-nodes = [ - "akka.tcp://"${clustering.cluster.name}"@"${clustering.seed-ip}":"${clustering.seed-port} + "akka://"${clustering.cluster.name}"@"${clustering.seed-ip}":"${clustering.seed-port} ] roles = ["portal"] -- GitLab