From 9d75a87dd6d0d72c988cec92cdb1768a474a64de Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 17 Nov 2021 19:54:04 +0100 Subject: [PATCH] deployment script & tasklist & executor fixes --- .deployment/docker-compose.yml | 10 ++++++---- .../adapter/out/web/NotifyExecutorPoolAdapter.java | 2 -- .../executorBase/executor/domain/ExecutorBase.java | 3 +++ .../adapter/out/web/CanTaskBeDeletedWebAdapter.java | 7 ++++--- .../out/web/PublishNewTaskAddedEventWebAdapter.java | 6 ++++-- tapas-tasks/src/main/resources/application.properties | 1 + 6 files changed, 18 insertions(+), 11 deletions(-) diff --git a/.deployment/docker-compose.yml b/.deployment/docker-compose.yml index 333820a..1dab865 100644 --- a/.deployment/docker-compose.yml +++ b/.deployment/docker-compose.yml @@ -32,6 +32,8 @@ services: restart: unless-stopped volumes: - ./:/data/ + environment: + roster.uri: http://roster:8082 labels: - "traefik.enable=true" - "traefik.http.routers.tapas-tasks.rule=Host(`tapas-tasks.${PUB_IP}.nip.io`)" @@ -96,8 +98,8 @@ services: volumes: - ./:/data/ environment: - executor_pool_uri: executor-pool.86-119-35-40.nip.io - roster_uri: roster.86-119-35-40.nip.io" + executor_pool_uri: http://executor-pool:8083 + roster_uri: http://roster:8082 labels: - "traefik.enable=true" - "traefik.http.routers.executor-computation.rule=Host(`executor-computation.${PUB_IP}.nip.io`)" @@ -116,8 +118,8 @@ services: volumes: - ./:/data/ environment: - executor_pool_uri: executor-pool.86-119-35-40.nip.io - roster_uri: roster.86-119-35-40.nip.io + executor_pool_uri: http://executor-pool:8083 + roster_uri: http://roster:8082 labels: - "traefik.enable=true" - "traefik.http.routers.executor-robot.rule=Host(`executor-robot.${PUB_IP}.nip.io`)" diff --git a/executor-base/src/main/java/ch/unisg/executorBase/executor/adapter/out/web/NotifyExecutorPoolAdapter.java b/executor-base/src/main/java/ch/unisg/executorBase/executor/adapter/out/web/NotifyExecutorPoolAdapter.java index ebb6fc6..bb38e66 100644 --- a/executor-base/src/main/java/ch/unisg/executorBase/executor/adapter/out/web/NotifyExecutorPoolAdapter.java +++ b/executor-base/src/main/java/ch/unisg/executorBase/executor/adapter/out/web/NotifyExecutorPoolAdapter.java @@ -34,8 +34,6 @@ public class NotifyExecutorPoolAdapter implements NotifyExecutorPoolPort { @Override public boolean notifyExecutorPool(ExecutorURI executorURI, ExecutorType executorType) { - System.out.println(server); - String body = new JSONObject() .put("executorTaskType", executorType) .put("executorUri", executorURI.getValue()) diff --git a/executor-base/src/main/java/ch/unisg/executorBase/executor/domain/ExecutorBase.java b/executor-base/src/main/java/ch/unisg/executorBase/executor/domain/ExecutorBase.java index 14582e7..9f70dd1 100644 --- a/executor-base/src/main/java/ch/unisg/executorBase/executor/domain/ExecutorBase.java +++ b/executor-base/src/main/java/ch/unisg/executorBase/executor/domain/ExecutorBase.java @@ -1,5 +1,6 @@ package ch.unisg.executorbase.executor.domain; +import java.util.logging.Level; import java.util.logging.Logger; import ch.unisg.common.valueobject.ExecutorURI; @@ -41,8 +42,10 @@ public abstract class ExecutorBase { // TODO do this in main // Notify executor-pool about existence. If executor-pools response is successfull start with getting an assignment, else shut down executor. if(!notifyExecutorPoolService.notifyExecutorPool(this.executorURI, this.executorType)) { + logger.log(Level.WARNING, "Executor could not connect to executor pool! Shuting down!"); System.exit(0); } else { + logger.info("Executor conntected to executor pool"); this.status = ExecutorStatus.IDLING; getAssignment(); } diff --git a/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/adapter/out/web/CanTaskBeDeletedWebAdapter.java b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/adapter/out/web/CanTaskBeDeletedWebAdapter.java index 5061e3d..a69f2e5 100644 --- a/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/adapter/out/web/CanTaskBeDeletedWebAdapter.java +++ b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/adapter/out/web/CanTaskBeDeletedWebAdapter.java @@ -5,6 +5,8 @@ import ch.unisg.tapastasks.tasks.application.port.out.CanTaskBeDeletedPort; import ch.unisg.tapastasks.tasks.domain.DeleteTaskEvent; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Component; @@ -19,9 +21,8 @@ import java.util.HashMap; @Primary public class CanTaskBeDeletedWebAdapter implements CanTaskBeDeletedPort { - // Base URI of the service interested in this event - //Todo: Add the right IP address - String server = null; + @Value("${roster.uri}") + String server; @Override public void canTaskBeDeletedEvent(DeleteTaskEvent event){ diff --git a/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/adapter/out/web/PublishNewTaskAddedEventWebAdapter.java b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/adapter/out/web/PublishNewTaskAddedEventWebAdapter.java index 80b3d09..53435d0 100644 --- a/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/adapter/out/web/PublishNewTaskAddedEventWebAdapter.java +++ b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/adapter/out/web/PublishNewTaskAddedEventWebAdapter.java @@ -4,6 +4,8 @@ import ch.unisg.tapastasks.tasks.application.port.out.NewTaskAddedEventPort; import ch.unisg.tapastasks.tasks.domain.NewTaskAddedEvent; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Component; @@ -18,8 +20,8 @@ import java.util.HashMap; @Primary public class PublishNewTaskAddedEventWebAdapter implements NewTaskAddedEventPort { - //This is the base URI of the service interested in this event (in my setup, running locally as separate Spring Boot application) - String server = "http://127.0.0.1:8082"; + @Value("${roster.uri}") + String server; @Override public void publishNewTaskAddedEvent(NewTaskAddedEvent event) { diff --git a/tapas-tasks/src/main/resources/application.properties b/tapas-tasks/src/main/resources/application.properties index fe25873..485e4e7 100644 --- a/tapas-tasks/src/main/resources/application.properties +++ b/tapas-tasks/src/main/resources/application.properties @@ -1,2 +1,3 @@ server.port=8081 baseuri=https://tapas-tasks.86-119-34-23.nip.io/ +roster.uri=http://127.0.0.1:8082