From 1d78bb63abb03a7c4898ed5f98372b9df3153064 Mon Sep 17 00:00:00 2001 From: Marcel Date: Mon, 11 Oct 2021 19:21:22 +0200 Subject: [PATCH 01/17] basic implementation of an executor --- .editorconfig | 12 +++ executor1/pom.xml | 16 ++++ .../unisg/executor1/Executor1Application.java | 3 + .../ch/unisg/executor1/TestController.java | 12 --- .../executor1/common/SelfValidating.java | 29 ++++++ .../in/web/TaskAvailableController.java | 32 +++++++ .../out/web/ExecutionFinishedAdapter.java | 58 ++++++++++++ .../adapter/out/web/GetAssignmentAdapter.java | 44 +++++++++ .../out/web/NotifyExecutorPoolAdapter.java | 61 ++++++++++++ .../port/in/TaskAvailableCommand.java | 19 ++++ .../port/in/TaskAvailableUseCase.java | 5 + .../port/out/ExecutionFinishedEventPort.java | 7 ++ .../port/out/GetAssignmentPort.java | 7 ++ .../port/out/NotifyExecutorPoolPort.java | 5 + .../service/NotifyExecutorPoolService.java | 17 ++++ .../service/TaskAvailableService.java | 27 ++++++ .../domain/ExecutionFinishedEvent.java | 21 +++++ .../executor1/executor/domain/Executor.java | 93 +++++++++++++++++++ .../executor/domain/ExecutorStatus.java | 7 ++ .../unisg/executor1/executor/domain/Task.java | 20 ++++ .../tapastasks/TapasTasksApplication.java | 4 +- 21 files changed, 485 insertions(+), 14 deletions(-) create mode 100644 .editorconfig delete mode 100644 executor1/src/main/java/ch/unisg/executor1/TestController.java create mode 100644 executor1/src/main/java/ch/unisg/executor1/common/SelfValidating.java create mode 100644 executor1/src/main/java/ch/unisg/executor1/executor/adapter/in/web/TaskAvailableController.java create mode 100644 executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/web/ExecutionFinishedAdapter.java create mode 100644 executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/web/GetAssignmentAdapter.java create mode 100644 executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/web/NotifyExecutorPoolAdapter.java create mode 100644 executor1/src/main/java/ch/unisg/executor1/executor/application/port/in/TaskAvailableCommand.java create mode 100644 executor1/src/main/java/ch/unisg/executor1/executor/application/port/in/TaskAvailableUseCase.java create mode 100644 executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/ExecutionFinishedEventPort.java create mode 100644 executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/GetAssignmentPort.java create mode 100644 executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/NotifyExecutorPoolPort.java create mode 100644 executor1/src/main/java/ch/unisg/executor1/executor/application/service/NotifyExecutorPoolService.java create mode 100644 executor1/src/main/java/ch/unisg/executor1/executor/application/service/TaskAvailableService.java create mode 100644 executor1/src/main/java/ch/unisg/executor1/executor/domain/ExecutionFinishedEvent.java create mode 100644 executor1/src/main/java/ch/unisg/executor1/executor/domain/Executor.java create mode 100644 executor1/src/main/java/ch/unisg/executor1/executor/domain/ExecutorStatus.java create mode 100644 executor1/src/main/java/ch/unisg/executor1/executor/domain/Task.java diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..74c6104 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true + +[*.{java}] +indent_style = space +indent_size = 4 +tab_width = 4 +trim_trailing_whitespace = true +max_line_length = 100 diff --git a/executor1/pom.xml b/executor1/pom.xml index 1534025..8df7a04 100644 --- a/executor1/pom.xml +++ b/executor1/pom.xml @@ -30,6 +30,10 @@ runtime true + + org.springframework.boot + spring-boot-starter-validation + org.projectlombok lombok @@ -40,6 +44,18 @@ spring-boot-starter-test test + + + javax.validation + validation-api + 1.1.0.Final + + + + javax.transaction + javax.transaction-api + 1.2 + diff --git a/executor1/src/main/java/ch/unisg/executor1/Executor1Application.java b/executor1/src/main/java/ch/unisg/executor1/Executor1Application.java index 4eed560..dfb8d8c 100644 --- a/executor1/src/main/java/ch/unisg/executor1/Executor1Application.java +++ b/executor1/src/main/java/ch/unisg/executor1/Executor1Application.java @@ -3,11 +3,14 @@ package ch.unisg.executor1; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import ch.unisg.executor1.executor.domain.Executor; + @SpringBootApplication public class Executor1Application { public static void main(String[] args) { SpringApplication.run(Executor1Application.class, args); + Executor.getExecutor(); } } diff --git a/executor1/src/main/java/ch/unisg/executor1/TestController.java b/executor1/src/main/java/ch/unisg/executor1/TestController.java deleted file mode 100644 index a2f32b4..0000000 --- a/executor1/src/main/java/ch/unisg/executor1/TestController.java +++ /dev/null @@ -1,12 +0,0 @@ -package ch.unisg.executor1; - -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class TestController { - @RequestMapping("/") - public String index() { - return "Hello World! Executor1"; - } -} diff --git a/executor1/src/main/java/ch/unisg/executor1/common/SelfValidating.java b/executor1/src/main/java/ch/unisg/executor1/common/SelfValidating.java new file mode 100644 index 0000000..bc9816a --- /dev/null +++ b/executor1/src/main/java/ch/unisg/executor1/common/SelfValidating.java @@ -0,0 +1,29 @@ +package ch.unisg.executor1.common; + +import javax.validation.ConstraintViolation; +import javax.validation.ConstraintViolationException; +import javax.validation.Validation; +import javax.validation.Validator; +import javax.validation.ValidatorFactory; +import java.util.Set; + +public class SelfValidating { + + private Validator validator; + + public SelfValidating() { + ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); + validator = factory.getValidator(); + } + + /** + * Evaluates all Bean Validations on the attributes of this + * instance. + */ + protected void validateSelf() { + Set> violations = validator.validate((T) this); + if (!violations.isEmpty()) { + throw new ConstraintViolationException(violations); + } + } +} diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/adapter/in/web/TaskAvailableController.java b/executor1/src/main/java/ch/unisg/executor1/executor/adapter/in/web/TaskAvailableController.java new file mode 100644 index 0000000..14dc3e6 --- /dev/null +++ b/executor1/src/main/java/ch/unisg/executor1/executor/adapter/in/web/TaskAvailableController.java @@ -0,0 +1,32 @@ +package ch.unisg.executor1.executor.adapter.in.web; + +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +import ch.unisg.executor1.executor.application.port.in.TaskAvailableCommand; +import ch.unisg.executor1.executor.application.port.in.TaskAvailableUseCase; + +@RestController +public class TaskAvailableController { + private final TaskAvailableUseCase taskAvailableUseCase; + + public TaskAvailableController(TaskAvailableUseCase taskAvailableUseCase) { + this.taskAvailableUseCase = taskAvailableUseCase; + } + + @GetMapping(path = "/newtask/{taskType}") + public ResponseEntity retrieveTaskFromTaskList(@PathVariable("taskType") String taskType) { + TaskAvailableCommand command = new TaskAvailableCommand(taskType); + + taskAvailableUseCase.newTaskAvailable(command); + + // Add the content type as a response header + HttpHeaders responseHeaders = new HttpHeaders(); + + return new ResponseEntity<>("OK", responseHeaders, HttpStatus.OK); + } +} diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/web/ExecutionFinishedAdapter.java b/executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/web/ExecutionFinishedAdapter.java new file mode 100644 index 0000000..e1c3a5d --- /dev/null +++ b/executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/web/ExecutionFinishedAdapter.java @@ -0,0 +1,58 @@ +package ch.unisg.executor1.executor.adapter.out.web; + +import java.io.IOException; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.util.HashMap; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.core.JsonProcessingException; + +import ch.unisg.executor1.executor.application.port.out.ExecutionFinishedEventPort; +import ch.unisg.executor1.executor.domain.ExecutionFinishedEvent; + +public class ExecutionFinishedAdapter implements ExecutionFinishedEventPort { + + //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"; + + @Override + public void publishExecutionFinishedEvent(ExecutionFinishedEvent event) { + ///Here we would need to work with DTOs in case the payload of calls becomes more complex + + var values = new HashMap() {{ + put("result",event.getResult()); + put("status",event.getStatus()); + }}; + + var objectMapper = new ObjectMapper(); + String requestBody = null; + try { + requestBody = objectMapper.writeValueAsString(values); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + + HttpClient client = HttpClient.newHttpClient(); + HttpRequest request = HttpRequest.newBuilder() + .uri(URI.create(server+"/task/"+event.getTaskID())) + .PUT(HttpRequest.BodyPublishers.ofString(requestBody)) + .build(); + + /** Needs the other service running + try { + HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); + } catch (IOException e) { + e.printStackTrace(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + **/ + + System.out.println("Finish execution event sent"); + + } + +} diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/web/GetAssignmentAdapter.java b/executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/web/GetAssignmentAdapter.java new file mode 100644 index 0000000..2c32f84 --- /dev/null +++ b/executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/web/GetAssignmentAdapter.java @@ -0,0 +1,44 @@ +package ch.unisg.executor1.executor.adapter.out.web; + +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; + +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Component; + +import ch.unisg.executor1.executor.application.port.out.GetAssignmentPort; +import ch.unisg.executor1.executor.domain.Task; + +@Component +@Primary +public class GetAssignmentAdapter implements GetAssignmentPort { + + //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"; + + @Override + public Task getAssignment(String executorType) { + + HttpClient client = HttpClient.newHttpClient(); + HttpRequest request = HttpRequest.newBuilder() + .uri(URI.create(server+"/assignment/" + executorType)) + .GET() + .build(); + + /** Needs the other service running + try { + HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); + } catch (IOException e) { + e.printStackTrace(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + **/ + + // TODO return null or a new Task here depending on the response of the http call + + return new Task("1234"); + } + +} diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/web/NotifyExecutorPoolAdapter.java b/executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/web/NotifyExecutorPoolAdapter.java new file mode 100644 index 0000000..866ab91 --- /dev/null +++ b/executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/web/NotifyExecutorPoolAdapter.java @@ -0,0 +1,61 @@ +package ch.unisg.executor1.executor.adapter.out.web; + +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.util.HashMap; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Component; + +import ch.unisg.executor1.executor.application.port.out.NotifyExecutorPoolPort; + +@Component +@Primary +public class NotifyExecutorPoolAdapter implements NotifyExecutorPoolPort { + + //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:8083"; + + @Override + public boolean notifyExecutorPool(String ip, int port, String executorType) { + + var values = new HashMap() {{ + put("ip", ip); + put("port", Integer.toString(port)); + put("executorType", executorType); + }}; + + var objectMapper = new ObjectMapper(); + String requestBody = null; + try { + requestBody = objectMapper.writeValueAsString(values); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + + HttpClient client = HttpClient.newHttpClient(); + HttpRequest request = HttpRequest.newBuilder() + .uri(URI.create(server+"/executor/new/")) + .POST(HttpRequest.BodyPublishers.ofString(requestBody)) + .build(); + + /** Needs the other service running + try { + HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); + } catch (IOException e) { + e.printStackTrace(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + **/ + + // TODO return true or false depending on result of http request; + + return true; + } + +} diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/application/port/in/TaskAvailableCommand.java b/executor1/src/main/java/ch/unisg/executor1/executor/application/port/in/TaskAvailableCommand.java new file mode 100644 index 0000000..a5d530d --- /dev/null +++ b/executor1/src/main/java/ch/unisg/executor1/executor/application/port/in/TaskAvailableCommand.java @@ -0,0 +1,19 @@ +package ch.unisg.executor1.executor.application.port.in; + +import ch.unisg.executor1.common.SelfValidating; + +import javax.validation.constraints.NotNull; + +import lombok.Value; + +@Value +public class TaskAvailableCommand extends SelfValidating { + + @NotNull + private final String taskType; + + public TaskAvailableCommand(String taskType) { + this.taskType = taskType; + this.validateSelf(); + } +} diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/application/port/in/TaskAvailableUseCase.java b/executor1/src/main/java/ch/unisg/executor1/executor/application/port/in/TaskAvailableUseCase.java new file mode 100644 index 0000000..d8184c1 --- /dev/null +++ b/executor1/src/main/java/ch/unisg/executor1/executor/application/port/in/TaskAvailableUseCase.java @@ -0,0 +1,5 @@ +package ch.unisg.executor1.executor.application.port.in; + +public interface TaskAvailableUseCase { + void newTaskAvailable(TaskAvailableCommand command); +} diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/ExecutionFinishedEventPort.java b/executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/ExecutionFinishedEventPort.java new file mode 100644 index 0000000..6bfea70 --- /dev/null +++ b/executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/ExecutionFinishedEventPort.java @@ -0,0 +1,7 @@ +package ch.unisg.executor1.executor.application.port.out; + +import ch.unisg.executor1.executor.domain.ExecutionFinishedEvent; + +public interface ExecutionFinishedEventPort { + void publishExecutionFinishedEvent(ExecutionFinishedEvent event); +} diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/GetAssignmentPort.java b/executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/GetAssignmentPort.java new file mode 100644 index 0000000..bbf9124 --- /dev/null +++ b/executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/GetAssignmentPort.java @@ -0,0 +1,7 @@ +package ch.unisg.executor1.executor.application.port.out; + +import ch.unisg.executor1.executor.domain.Task; + +public interface GetAssignmentPort { + Task getAssignment(String executorType); +} diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/NotifyExecutorPoolPort.java b/executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/NotifyExecutorPoolPort.java new file mode 100644 index 0000000..856163f --- /dev/null +++ b/executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/NotifyExecutorPoolPort.java @@ -0,0 +1,5 @@ +package ch.unisg.executor1.executor.application.port.out; + +public interface NotifyExecutorPoolPort { + boolean notifyExecutorPool(String ip, int port, String executorType); +} diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/application/service/NotifyExecutorPoolService.java b/executor1/src/main/java/ch/unisg/executor1/executor/application/service/NotifyExecutorPoolService.java new file mode 100644 index 0000000..0c05fda --- /dev/null +++ b/executor1/src/main/java/ch/unisg/executor1/executor/application/service/NotifyExecutorPoolService.java @@ -0,0 +1,17 @@ +package ch.unisg.executor1.executor.application.service; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import ch.unisg.executor1.executor.application.port.out.NotifyExecutorPoolPort; +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +public class NotifyExecutorPoolService { + + private final NotifyExecutorPoolPort notifyExecutorPoolPort; + + public boolean notifyExecutorPool(String ip, int port, String executorType) { + return notifyExecutorPoolPort.notifyExecutorPool(ip, port, executorType); + } +} diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/application/service/TaskAvailableService.java b/executor1/src/main/java/ch/unisg/executor1/executor/application/service/TaskAvailableService.java new file mode 100644 index 0000000..795cd8b --- /dev/null +++ b/executor1/src/main/java/ch/unisg/executor1/executor/application/service/TaskAvailableService.java @@ -0,0 +1,27 @@ +package ch.unisg.executor1.executor.application.service; + +import org.springframework.stereotype.Component; + +import ch.unisg.executor1.executor.application.port.in.TaskAvailableCommand; +import ch.unisg.executor1.executor.application.port.in.TaskAvailableUseCase; +import ch.unisg.executor1.executor.domain.Executor; +import ch.unisg.executor1.executor.domain.ExecutorStatus; +import lombok.RequiredArgsConstructor; + +import javax.transaction.Transactional; + +@RequiredArgsConstructor +@Component +@Transactional +public class TaskAvailableService implements TaskAvailableUseCase { + + @Override + public void newTaskAvailable(TaskAvailableCommand command) { + Executor executor = Executor.getExecutor(); + + if (executor.getExecutorType().equalsIgnoreCase(command.getTaskType()) && + executor.getStatus() == ExecutorStatus.IDLING) { + executor.getAssignment(); + } + } +} diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/domain/ExecutionFinishedEvent.java b/executor1/src/main/java/ch/unisg/executor1/executor/domain/ExecutionFinishedEvent.java new file mode 100644 index 0000000..4455572 --- /dev/null +++ b/executor1/src/main/java/ch/unisg/executor1/executor/domain/ExecutionFinishedEvent.java @@ -0,0 +1,21 @@ +package ch.unisg.executor1.executor.domain; + +import lombok.Getter; + +public class ExecutionFinishedEvent { + + @Getter + private String taskID; + + @Getter + private String result; + + @Getter + private String status; + + public ExecutionFinishedEvent(String taskID, String result, String status) { + this.taskID = taskID; + this.result = result; + this.status = status; + } +} diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/domain/Executor.java b/executor1/src/main/java/ch/unisg/executor1/executor/domain/Executor.java new file mode 100644 index 0000000..6329f29 --- /dev/null +++ b/executor1/src/main/java/ch/unisg/executor1/executor/domain/Executor.java @@ -0,0 +1,93 @@ +package ch.unisg.executor1.executor.domain; + +import ch.unisg.executor1.executor.application.port.out.ExecutionFinishedEventPort; +import ch.unisg.executor1.executor.application.port.out.GetAssignmentPort; +import ch.unisg.executor1.executor.application.port.out.NotifyExecutorPoolPort; + +import java.util.concurrent.TimeUnit; + +import javax.transaction.Transactional; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Configurable; + +import ch.unisg.executor1.executor.adapter.out.web.ExecutionFinishedAdapter; +import ch.unisg.executor1.executor.adapter.out.web.GetAssignmentAdapter; +import ch.unisg.executor1.executor.adapter.out.web.NotifyExecutorPoolAdapter; +import ch.unisg.executor1.executor.application.service.NotifyExecutorPoolService; +import lombok.Getter; + +public class Executor { + + @Getter + private String ip; + + @Getter + private String executorType = "addition"; + + @Getter + private int port; + + @Getter + private ExecutorStatus status; + + private static final Executor executor = new Executor(); + + // TODO Violation of the Dependency Inversion Principle?, but we havn't really got a better solutions to send a http request / access a service from a domain model + // TODO I guess we can somehow autowire this but I don't know why it's not working :D + private final NotifyExecutorPoolPort notifyExecutorPoolPort = new NotifyExecutorPoolAdapter(); + private final NotifyExecutorPoolService notifyExecutorPoolService = new NotifyExecutorPoolService(notifyExecutorPoolPort); + private final GetAssignmentPort getAssignmentPort = new GetAssignmentAdapter(); + private final ExecutionFinishedEventPort executionFinishedEventPort = new ExecutionFinishedAdapter(); + + private Executor() { + System.out.println("Starting Executor"); + // TODO set this automaticly + this.ip = "localhost"; + this.port = 8084; + + this.status = ExecutorStatus.STARTING_UP; + if(!notifyExecutorPoolService.notifyExecutorPool(this.ip, this.port, this.executorType)) { + System.exit(0); + } else { + System.out.println(true); + this.status = ExecutorStatus.IDLING; + getAssignment(); + } + } + + public static Executor getExecutor() { + return executor; + } + + public void getAssignment() { + Task newTask = getAssignmentPort.getAssignment(this.getExecutorType()); + if (newTask != null) { + this.executeTask(newTask); + } else { + this.status = ExecutorStatus.IDLING; + } + } + + private void executeTask(Task task) { + System.out.println("Starting execution"); + this.status = ExecutorStatus.EXECUTING; + int a = 10; + int b = 20; + try { + TimeUnit.SECONDS.sleep(10); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + int result = a + b; + + task.setResult(Integer.toString(result)); + + executionFinishedEventPort.publishExecutionFinishedEvent(new ExecutionFinishedEvent(task.getTaskID(), task.getResult(), "SUCCESS")); + + System.out.println("Finish execution"); + getAssignment(); + } + +} diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/domain/ExecutorStatus.java b/executor1/src/main/java/ch/unisg/executor1/executor/domain/ExecutorStatus.java new file mode 100644 index 0000000..92af024 --- /dev/null +++ b/executor1/src/main/java/ch/unisg/executor1/executor/domain/ExecutorStatus.java @@ -0,0 +1,7 @@ +package ch.unisg.executor1.executor.domain; + +public enum ExecutorStatus { + STARTING_UP, + EXECUTING, + IDLING, +} diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/domain/Task.java b/executor1/src/main/java/ch/unisg/executor1/executor/domain/Task.java new file mode 100644 index 0000000..2287b6c --- /dev/null +++ b/executor1/src/main/java/ch/unisg/executor1/executor/domain/Task.java @@ -0,0 +1,20 @@ +package ch.unisg.executor1.executor.domain; + +import lombok.Data; +import lombok.Getter; +import lombok.Setter; + +public class Task { + + @Getter + private String taskID; + + @Getter + @Setter + private String result; + + public Task(String taskID) { + this.taskID = taskID; + } + +} diff --git a/tapas-tasks/src/main/java/ch/unisg/tapastasks/TapasTasksApplication.java b/tapas-tasks/src/main/java/ch/unisg/tapastasks/TapasTasksApplication.java index 40fa5da..90d1716 100644 --- a/tapas-tasks/src/main/java/ch/unisg/tapastasks/TapasTasksApplication.java +++ b/tapas-tasks/src/main/java/ch/unisg/tapastasks/TapasTasksApplication.java @@ -10,8 +10,8 @@ public class TapasTasksApplication { public static void main(String[] args) { - SpringApplication tapasTasksApp = new SpringApplication(TapasTasksApplication.class); - tapasTasksApp.run(args); + SpringApplication tapasTasksApp = new SpringApplication(TapasTasksApplication.class); + tapasTasksApp.run(args); } } From 3bc39b70aa6e62ee52edc375f97c74c4a73ccaef Mon Sep 17 00:00:00 2001 From: Marcel Date: Mon, 11 Oct 2021 21:20:45 +0200 Subject: [PATCH 02/17] Added abstraction --- .../in/web/TaskAvailableController.java | 10 ++- ...ava => ExecutionFinishedEventAdapter.java} | 4 +- .../adapter/out/web/GetAssignmentAdapter.java | 5 +- .../out/web/NotifyExecutorPoolAdapter.java | 5 +- .../port/in/TaskAvailableCommand.java | 5 +- .../port/out/GetAssignmentPort.java | 3 +- .../port/out/NotifyExecutorPoolPort.java | 4 +- .../service/NotifyExecutorPoolService.java | 3 +- .../service/TaskAvailableService.java | 2 +- .../executor1/executor/domain/Executor.java | 78 ++--------------- .../executor/domain/ExecutorBase.java | 87 +++++++++++++++++++ .../executor/domain/ExecutorType.java | 18 ++++ 12 files changed, 140 insertions(+), 84 deletions(-) rename executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/web/{ExecutionFinishedAdapter.java => ExecutionFinishedEventAdapter.java} (91%) create mode 100644 executor1/src/main/java/ch/unisg/executor1/executor/domain/ExecutorBase.java create mode 100644 executor1/src/main/java/ch/unisg/executor1/executor/domain/ExecutorType.java diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/adapter/in/web/TaskAvailableController.java b/executor1/src/main/java/ch/unisg/executor1/executor/adapter/in/web/TaskAvailableController.java index 14dc3e6..eecc4a3 100644 --- a/executor1/src/main/java/ch/unisg/executor1/executor/adapter/in/web/TaskAvailableController.java +++ b/executor1/src/main/java/ch/unisg/executor1/executor/adapter/in/web/TaskAvailableController.java @@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.RestController; import ch.unisg.executor1.executor.application.port.in.TaskAvailableCommand; import ch.unisg.executor1.executor.application.port.in.TaskAvailableUseCase; +import ch.unisg.executor1.executor.domain.ExecutorType; @RestController public class TaskAvailableController { @@ -20,10 +21,13 @@ public class TaskAvailableController { @GetMapping(path = "/newtask/{taskType}") public ResponseEntity retrieveTaskFromTaskList(@PathVariable("taskType") String taskType) { - TaskAvailableCommand command = new TaskAvailableCommand(taskType); - - taskAvailableUseCase.newTaskAvailable(command); + if (ExecutorType.contains(taskType.toUpperCase())) { + TaskAvailableCommand command = new TaskAvailableCommand( + ExecutorType.valueOf(taskType.toUpperCase())); + taskAvailableUseCase.newTaskAvailable(command); + } + // Add the content type as a response header HttpHeaders responseHeaders = new HttpHeaders(); diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/web/ExecutionFinishedAdapter.java b/executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/web/ExecutionFinishedEventAdapter.java similarity index 91% rename from executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/web/ExecutionFinishedAdapter.java rename to executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/web/ExecutionFinishedEventAdapter.java index e1c3a5d..41e68a6 100644 --- a/executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/web/ExecutionFinishedAdapter.java +++ b/executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/web/ExecutionFinishedEventAdapter.java @@ -13,7 +13,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import ch.unisg.executor1.executor.application.port.out.ExecutionFinishedEventPort; import ch.unisg.executor1.executor.domain.ExecutionFinishedEvent; -public class ExecutionFinishedAdapter implements ExecutionFinishedEventPort { +public class ExecutionFinishedEventAdapter implements ExecutionFinishedEventPort { //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"; @@ -51,7 +51,7 @@ public class ExecutionFinishedAdapter implements ExecutionFinishedEventPort { } **/ - System.out.println("Finish execution event sent"); + System.out.println("Finish execution event sent with result:" + event.getResult()); } diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/web/GetAssignmentAdapter.java b/executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/web/GetAssignmentAdapter.java index 2c32f84..c7d8485 100644 --- a/executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/web/GetAssignmentAdapter.java +++ b/executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/web/GetAssignmentAdapter.java @@ -8,6 +8,7 @@ import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Component; import ch.unisg.executor1.executor.application.port.out.GetAssignmentPort; +import ch.unisg.executor1.executor.domain.ExecutorType; import ch.unisg.executor1.executor.domain.Task; @Component @@ -18,7 +19,7 @@ public class GetAssignmentAdapter implements GetAssignmentPort { String server = "http://127.0.0.1:8082"; @Override - public Task getAssignment(String executorType) { + public Task getAssignment(ExecutorType executorType) { HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() @@ -38,7 +39,7 @@ public class GetAssignmentAdapter implements GetAssignmentPort { // TODO return null or a new Task here depending on the response of the http call - return new Task("1234"); + return null; } } diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/web/NotifyExecutorPoolAdapter.java b/executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/web/NotifyExecutorPoolAdapter.java index 866ab91..d7a9238 100644 --- a/executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/web/NotifyExecutorPoolAdapter.java +++ b/executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/web/NotifyExecutorPoolAdapter.java @@ -12,6 +12,7 @@ import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Component; import ch.unisg.executor1.executor.application.port.out.NotifyExecutorPoolPort; +import ch.unisg.executor1.executor.domain.ExecutorType; @Component @Primary @@ -21,12 +22,12 @@ public class NotifyExecutorPoolAdapter implements NotifyExecutorPoolPort { String server = "http://127.0.0.1:8083"; @Override - public boolean notifyExecutorPool(String ip, int port, String executorType) { + public boolean notifyExecutorPool(String ip, int port, ExecutorType executorType) { var values = new HashMap() {{ put("ip", ip); put("port", Integer.toString(port)); - put("executorType", executorType); + put("executorType", executorType.toString()); }}; var objectMapper = new ObjectMapper(); diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/application/port/in/TaskAvailableCommand.java b/executor1/src/main/java/ch/unisg/executor1/executor/application/port/in/TaskAvailableCommand.java index a5d530d..292d18b 100644 --- a/executor1/src/main/java/ch/unisg/executor1/executor/application/port/in/TaskAvailableCommand.java +++ b/executor1/src/main/java/ch/unisg/executor1/executor/application/port/in/TaskAvailableCommand.java @@ -1,6 +1,7 @@ package ch.unisg.executor1.executor.application.port.in; import ch.unisg.executor1.common.SelfValidating; +import ch.unisg.executor1.executor.domain.ExecutorType; import javax.validation.constraints.NotNull; @@ -10,9 +11,9 @@ import lombok.Value; public class TaskAvailableCommand extends SelfValidating { @NotNull - private final String taskType; + private final ExecutorType taskType; - public TaskAvailableCommand(String taskType) { + public TaskAvailableCommand(ExecutorType taskType) { this.taskType = taskType; this.validateSelf(); } diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/GetAssignmentPort.java b/executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/GetAssignmentPort.java index bbf9124..7b81b13 100644 --- a/executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/GetAssignmentPort.java +++ b/executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/GetAssignmentPort.java @@ -1,7 +1,8 @@ package ch.unisg.executor1.executor.application.port.out; +import ch.unisg.executor1.executor.domain.ExecutorType; import ch.unisg.executor1.executor.domain.Task; public interface GetAssignmentPort { - Task getAssignment(String executorType); + Task getAssignment(ExecutorType executorType); } diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/NotifyExecutorPoolPort.java b/executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/NotifyExecutorPoolPort.java index 856163f..4086258 100644 --- a/executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/NotifyExecutorPoolPort.java +++ b/executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/NotifyExecutorPoolPort.java @@ -1,5 +1,7 @@ package ch.unisg.executor1.executor.application.port.out; +import ch.unisg.executor1.executor.domain.ExecutorType; + public interface NotifyExecutorPoolPort { - boolean notifyExecutorPool(String ip, int port, String executorType); + boolean notifyExecutorPool(String ip, int port, ExecutorType executorType); } diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/application/service/NotifyExecutorPoolService.java b/executor1/src/main/java/ch/unisg/executor1/executor/application/service/NotifyExecutorPoolService.java index 0c05fda..acfae94 100644 --- a/executor1/src/main/java/ch/unisg/executor1/executor/application/service/NotifyExecutorPoolService.java +++ b/executor1/src/main/java/ch/unisg/executor1/executor/application/service/NotifyExecutorPoolService.java @@ -4,6 +4,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import ch.unisg.executor1.executor.application.port.out.NotifyExecutorPoolPort; +import ch.unisg.executor1.executor.domain.ExecutorType; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor @@ -11,7 +12,7 @@ public class NotifyExecutorPoolService { private final NotifyExecutorPoolPort notifyExecutorPoolPort; - public boolean notifyExecutorPool(String ip, int port, String executorType) { + public boolean notifyExecutorPool(String ip, int port, ExecutorType executorType) { return notifyExecutorPoolPort.notifyExecutorPool(ip, port, executorType); } } diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/application/service/TaskAvailableService.java b/executor1/src/main/java/ch/unisg/executor1/executor/application/service/TaskAvailableService.java index 795cd8b..6f15b47 100644 --- a/executor1/src/main/java/ch/unisg/executor1/executor/application/service/TaskAvailableService.java +++ b/executor1/src/main/java/ch/unisg/executor1/executor/application/service/TaskAvailableService.java @@ -19,7 +19,7 @@ public class TaskAvailableService implements TaskAvailableUseCase { public void newTaskAvailable(TaskAvailableCommand command) { Executor executor = Executor.getExecutor(); - if (executor.getExecutorType().equalsIgnoreCase(command.getTaskType()) && + if (executor.getExecutorType() == command.getTaskType() && executor.getStatus() == ExecutorStatus.IDLING) { executor.getAssignment(); } diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/domain/Executor.java b/executor1/src/main/java/ch/unisg/executor1/executor/domain/Executor.java index 6329f29..d8f9e0b 100644 --- a/executor1/src/main/java/ch/unisg/executor1/executor/domain/Executor.java +++ b/executor1/src/main/java/ch/unisg/executor1/executor/domain/Executor.java @@ -1,77 +1,22 @@ package ch.unisg.executor1.executor.domain; -import ch.unisg.executor1.executor.application.port.out.ExecutionFinishedEventPort; -import ch.unisg.executor1.executor.application.port.out.GetAssignmentPort; -import ch.unisg.executor1.executor.application.port.out.NotifyExecutorPoolPort; - import java.util.concurrent.TimeUnit; -import javax.transaction.Transactional; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Configurable; - -import ch.unisg.executor1.executor.adapter.out.web.ExecutionFinishedAdapter; -import ch.unisg.executor1.executor.adapter.out.web.GetAssignmentAdapter; -import ch.unisg.executor1.executor.adapter.out.web.NotifyExecutorPoolAdapter; -import ch.unisg.executor1.executor.application.service.NotifyExecutorPoolService; -import lombok.Getter; - -public class Executor { - - @Getter - private String ip; - - @Getter - private String executorType = "addition"; - - @Getter - private int port; - - @Getter - private ExecutorStatus status; - - private static final Executor executor = new Executor(); - - // TODO Violation of the Dependency Inversion Principle?, but we havn't really got a better solutions to send a http request / access a service from a domain model - // TODO I guess we can somehow autowire this but I don't know why it's not working :D - private final NotifyExecutorPoolPort notifyExecutorPoolPort = new NotifyExecutorPoolAdapter(); - private final NotifyExecutorPoolService notifyExecutorPoolService = new NotifyExecutorPoolService(notifyExecutorPoolPort); - private final GetAssignmentPort getAssignmentPort = new GetAssignmentAdapter(); - private final ExecutionFinishedEventPort executionFinishedEventPort = new ExecutionFinishedAdapter(); - - private Executor() { - System.out.println("Starting Executor"); - // TODO set this automaticly - this.ip = "localhost"; - this.port = 8084; +public class Executor extends ExecutorBase { - this.status = ExecutorStatus.STARTING_UP; - if(!notifyExecutorPoolService.notifyExecutorPool(this.ip, this.port, this.executorType)) { - System.exit(0); - } else { - System.out.println(true); - this.status = ExecutorStatus.IDLING; - getAssignment(); - } - } + private static final Executor executor = new Executor(ExecutorType.ADDITION); public static Executor getExecutor() { return executor; } - public void getAssignment() { - Task newTask = getAssignmentPort.getAssignment(this.getExecutorType()); - if (newTask != null) { - this.executeTask(newTask); - } else { - this.status = ExecutorStatus.IDLING; - } + private Executor(ExecutorType executorType) { + super(executorType); } - private void executeTask(Task task) { - System.out.println("Starting execution"); - this.status = ExecutorStatus.EXECUTING; + @Override + String execution() { + int a = 10; int b = 20; try { @@ -82,12 +27,7 @@ public class Executor { int result = a + b; - task.setResult(Integer.toString(result)); - - executionFinishedEventPort.publishExecutionFinishedEvent(new ExecutionFinishedEvent(task.getTaskID(), task.getResult(), "SUCCESS")); - - System.out.println("Finish execution"); - getAssignment(); + return Integer.toString(result); } - + } diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/domain/ExecutorBase.java b/executor1/src/main/java/ch/unisg/executor1/executor/domain/ExecutorBase.java new file mode 100644 index 0000000..fe65913 --- /dev/null +++ b/executor1/src/main/java/ch/unisg/executor1/executor/domain/ExecutorBase.java @@ -0,0 +1,87 @@ +package ch.unisg.executor1.executor.domain; + +import ch.unisg.executor1.executor.application.port.out.ExecutionFinishedEventPort; +import ch.unisg.executor1.executor.application.port.out.GetAssignmentPort; +import ch.unisg.executor1.executor.application.port.out.NotifyExecutorPoolPort; + +import java.util.concurrent.TimeUnit; + +import javax.transaction.Transactional; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Configurable; + +import ch.unisg.executor1.executor.adapter.out.web.ExecutionFinishedEventAdapter; +import ch.unisg.executor1.executor.adapter.out.web.GetAssignmentAdapter; +import ch.unisg.executor1.executor.adapter.out.web.NotifyExecutorPoolAdapter; +import ch.unisg.executor1.executor.application.service.NotifyExecutorPoolService; +import lombok.Getter; + +abstract class ExecutorBase { + + @Getter + private String ip; + + @Getter + private ExecutorType executorType; + + @Getter + private int port; + + @Getter + private ExecutorStatus status; + + // private static final ExecutorBase executor = new ExecutorBase(); + + // TODO Violation of the Dependency Inversion Principle?, but we havn't really got a better solutions to send a http request / access a service from a domain model + // TODO I guess we can somehow autowire this but I don't know why it's not working :D + private final NotifyExecutorPoolPort notifyExecutorPoolPort = new NotifyExecutorPoolAdapter(); + private final NotifyExecutorPoolService notifyExecutorPoolService = new NotifyExecutorPoolService(notifyExecutorPoolPort); + private final GetAssignmentPort getAssignmentPort = new GetAssignmentAdapter(); + private final ExecutionFinishedEventPort executionFinishedEventPort = new ExecutionFinishedEventAdapter(); + + public ExecutorBase(ExecutorType executorType) { + System.out.println("Starting Executor"); + // TODO set this automaticly + this.ip = "localhost"; + this.port = 8084; + this.executorType = executorType; + + this.status = ExecutorStatus.STARTING_UP; + if(!notifyExecutorPoolService.notifyExecutorPool(this.ip, this.port, this.executorType)) { + System.exit(0); + } else { + System.out.println(true); + this.status = ExecutorStatus.IDLING; + getAssignment(); + } + } + + // public static ExecutorBase getExecutor() { + // return executor; + // } + + public void getAssignment() { + Task newTask = getAssignmentPort.getAssignment(this.getExecutorType()); + if (newTask != null) { + this.executeTask(newTask); + } else { + this.status = ExecutorStatus.IDLING; + } + } + + private void executeTask(Task task) { + System.out.println("Starting execution"); + this.status = ExecutorStatus.EXECUTING; + + task.setResult(execution()); + + executionFinishedEventPort.publishExecutionFinishedEvent(new ExecutionFinishedEvent(task.getTaskID(), task.getResult(), "SUCCESS")); + + System.out.println("Finish execution"); + getAssignment(); + } + + abstract String execution(); + +} diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/domain/ExecutorType.java b/executor1/src/main/java/ch/unisg/executor1/executor/domain/ExecutorType.java new file mode 100644 index 0000000..58c9d91 --- /dev/null +++ b/executor1/src/main/java/ch/unisg/executor1/executor/domain/ExecutorType.java @@ -0,0 +1,18 @@ +package ch.unisg.executor1.executor.domain; + +public enum ExecutorType { + ADDITION, ROBOT; + + public static boolean contains(String test) { + + for (ExecutorType x : ExecutorType.values()) { + if (x.name().equals(test)) { + return true; + } + } + return false; + } +} + + + From 5e8434d679b8c114515e781c4b4576a1acdd35d3 Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 13 Oct 2021 12:40:24 +0200 Subject: [PATCH 03/17] refactored executor1 to have base classes in own project --- {executor1 => executor-base}/.gitignore | 0 .../.mvn/wrapper/MavenWrapperDownloader.java | 0 .../.mvn/wrapper/maven-wrapper.jar | Bin .../.mvn/wrapper/maven-wrapper.properties | 0 {executor1 => executor-base}/Dockerfile | 0 {executor1 => executor-base}/mvnw | 0 {executor1 => executor-base}/mvnw.cmd | 0 {executor1 => executor-base}/pom.xml | 4 ++-- .../executorBase}/Executor1Application.java | 5 +--- .../executorBase}/common/SelfValidating.java | 2 +- .../in/web/TaskAvailableController.java | 8 +++---- .../web/ExecutionFinishedEventAdapter.java | 6 ++--- .../adapter/out/web/GetAssignmentAdapter.java | 10 ++++---- .../out/web/NotifyExecutorPoolAdapter.java | 6 ++--- .../port/in/TaskAvailableCommand.java | 6 ++--- .../port/in/TaskAvailableUseCase.java | 2 +- .../port/out/ExecutionFinishedEventPort.java | 7 ++++++ .../port/out/GetAssignmentPort.java | 8 +++++++ .../port/out/NotifyExecutorPoolPort.java | 4 ++-- .../service/NotifyExecutorPoolService.java | 9 +++---- .../domain/ExecutionFinishedEvent.java | 2 +- .../executor/domain/ExecutorBase.java | 22 ++++++++---------- .../executor/domain/ExecutorStatus.java | 2 +- .../executor/domain/ExecutorType.java | 2 +- .../executorBase}/executor/domain/Task.java | 2 +- .../src/main/resources/application.properties | 0 .../Executor1ApplicationTests.java | 4 ++-- .../port/out/ExecutionFinishedEventPort.java | 7 ------ .../port/out/GetAssignmentPort.java | 8 ------- executor2/pom.xml | 5 ++++ .../unisg/executor2/Executor2Application.java | 3 +++ .../ch/unisg/executor2/TestController.java | 12 ---------- .../service/TaskAvailableService.java | 11 +++++---- .../executor2}/executor/domain/Executor.java | 7 ++++-- 34 files changed, 78 insertions(+), 86 deletions(-) rename {executor1 => executor-base}/.gitignore (100%) rename {executor1 => executor-base}/.mvn/wrapper/MavenWrapperDownloader.java (100%) rename {executor1 => executor-base}/.mvn/wrapper/maven-wrapper.jar (100%) rename {executor1 => executor-base}/.mvn/wrapper/maven-wrapper.properties (100%) rename {executor1 => executor-base}/Dockerfile (100%) rename {executor1 => executor-base}/mvnw (100%) rename {executor1 => executor-base}/mvnw.cmd (100%) rename {executor1 => executor-base}/pom.xml (97%) rename {executor1/src/main/java/ch/unisg/executor1 => executor-base/src/main/java/ch/unisg/executorBase}/Executor1Application.java (72%) rename {executor1/src/main/java/ch/unisg/executor1 => executor-base/src/main/java/ch/unisg/executorBase}/common/SelfValidating.java (95%) rename {executor1/src/main/java/ch/unisg/executor1 => executor-base/src/main/java/ch/unisg/executorBase}/executor/adapter/in/web/TaskAvailableController.java (81%) rename {executor1/src/main/java/ch/unisg/executor1 => executor-base/src/main/java/ch/unisg/executorBase}/executor/adapter/out/web/ExecutionFinishedEventAdapter.java (89%) rename {executor1/src/main/java/ch/unisg/executor1 => executor-base/src/main/java/ch/unisg/executorBase}/executor/adapter/out/web/GetAssignmentAdapter.java (81%) rename {executor1/src/main/java/ch/unisg/executor1 => executor-base/src/main/java/ch/unisg/executorBase}/executor/adapter/out/web/NotifyExecutorPoolAdapter.java (90%) rename {executor1/src/main/java/ch/unisg/executor1 => executor-base/src/main/java/ch/unisg/executorBase}/executor/application/port/in/TaskAvailableCommand.java (66%) rename {executor1/src/main/java/ch/unisg/executor1 => executor-base/src/main/java/ch/unisg/executorBase}/executor/application/port/in/TaskAvailableUseCase.java (62%) create mode 100644 executor-base/src/main/java/ch/unisg/executorBase/executor/application/port/out/ExecutionFinishedEventPort.java create mode 100644 executor-base/src/main/java/ch/unisg/executorBase/executor/application/port/out/GetAssignmentPort.java rename {executor1/src/main/java/ch/unisg/executor1 => executor-base/src/main/java/ch/unisg/executorBase}/executor/application/port/out/NotifyExecutorPoolPort.java (51%) rename {executor1/src/main/java/ch/unisg/executor1 => executor-base/src/main/java/ch/unisg/executorBase}/executor/application/service/NotifyExecutorPoolService.java (52%) rename {executor1/src/main/java/ch/unisg/executor1 => executor-base/src/main/java/ch/unisg/executorBase}/executor/domain/ExecutionFinishedEvent.java (88%) rename {executor1/src/main/java/ch/unisg/executor1 => executor-base/src/main/java/ch/unisg/executorBase}/executor/domain/ExecutorBase.java (76%) rename {executor1/src/main/java/ch/unisg/executor1 => executor-base/src/main/java/ch/unisg/executorBase}/executor/domain/ExecutorStatus.java (61%) rename {executor1/src/main/java/ch/unisg/executor1 => executor-base/src/main/java/ch/unisg/executorBase}/executor/domain/ExecutorType.java (85%) rename {executor1/src/main/java/ch/unisg/executor1 => executor-base/src/main/java/ch/unisg/executorBase}/executor/domain/Task.java (84%) rename {executor1 => executor-base}/src/main/resources/application.properties (100%) rename {executor1/src/test/java/ch/unisg/executor1 => executor-base/src/test/java/ch/unisg/executorBase}/Executor1ApplicationTests.java (68%) delete mode 100644 executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/ExecutionFinishedEventPort.java delete mode 100644 executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/GetAssignmentPort.java delete mode 100644 executor2/src/main/java/ch/unisg/executor2/TestController.java rename {executor1/src/main/java/ch/unisg/executor1 => executor2/src/main/java/ch/unisg/executor2}/executor/application/service/TaskAvailableService.java (63%) rename {executor1/src/main/java/ch/unisg/executor1 => executor2/src/main/java/ch/unisg/executor2}/executor/domain/Executor.java (76%) diff --git a/executor1/.gitignore b/executor-base/.gitignore similarity index 100% rename from executor1/.gitignore rename to executor-base/.gitignore diff --git a/executor1/.mvn/wrapper/MavenWrapperDownloader.java b/executor-base/.mvn/wrapper/MavenWrapperDownloader.java similarity index 100% rename from executor1/.mvn/wrapper/MavenWrapperDownloader.java rename to executor-base/.mvn/wrapper/MavenWrapperDownloader.java diff --git a/executor1/.mvn/wrapper/maven-wrapper.jar b/executor-base/.mvn/wrapper/maven-wrapper.jar similarity index 100% rename from executor1/.mvn/wrapper/maven-wrapper.jar rename to executor-base/.mvn/wrapper/maven-wrapper.jar diff --git a/executor1/.mvn/wrapper/maven-wrapper.properties b/executor-base/.mvn/wrapper/maven-wrapper.properties similarity index 100% rename from executor1/.mvn/wrapper/maven-wrapper.properties rename to executor-base/.mvn/wrapper/maven-wrapper.properties diff --git a/executor1/Dockerfile b/executor-base/Dockerfile similarity index 100% rename from executor1/Dockerfile rename to executor-base/Dockerfile diff --git a/executor1/mvnw b/executor-base/mvnw similarity index 100% rename from executor1/mvnw rename to executor-base/mvnw diff --git a/executor1/mvnw.cmd b/executor-base/mvnw.cmd similarity index 100% rename from executor1/mvnw.cmd rename to executor-base/mvnw.cmd diff --git a/executor1/pom.xml b/executor-base/pom.xml similarity index 97% rename from executor1/pom.xml rename to executor-base/pom.xml index 8df7a04..6ad675a 100644 --- a/executor1/pom.xml +++ b/executor-base/pom.xml @@ -9,9 +9,9 @@ ch.unisg - executor1 + executorBase 0.0.1-SNAPSHOT - executor1 + executorBase Demo project for Spring Boot 11 diff --git a/executor1/src/main/java/ch/unisg/executor1/Executor1Application.java b/executor-base/src/main/java/ch/unisg/executorBase/Executor1Application.java similarity index 72% rename from executor1/src/main/java/ch/unisg/executor1/Executor1Application.java rename to executor-base/src/main/java/ch/unisg/executorBase/Executor1Application.java index dfb8d8c..9bd3fa5 100644 --- a/executor1/src/main/java/ch/unisg/executor1/Executor1Application.java +++ b/executor-base/src/main/java/ch/unisg/executorBase/Executor1Application.java @@ -1,16 +1,13 @@ -package ch.unisg.executor1; +package ch.unisg.executorBase; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import ch.unisg.executor1.executor.domain.Executor; - @SpringBootApplication public class Executor1Application { public static void main(String[] args) { SpringApplication.run(Executor1Application.class, args); - Executor.getExecutor(); } } diff --git a/executor1/src/main/java/ch/unisg/executor1/common/SelfValidating.java b/executor-base/src/main/java/ch/unisg/executorBase/common/SelfValidating.java similarity index 95% rename from executor1/src/main/java/ch/unisg/executor1/common/SelfValidating.java rename to executor-base/src/main/java/ch/unisg/executorBase/common/SelfValidating.java index bc9816a..1d4a80a 100644 --- a/executor1/src/main/java/ch/unisg/executor1/common/SelfValidating.java +++ b/executor-base/src/main/java/ch/unisg/executorBase/common/SelfValidating.java @@ -1,4 +1,4 @@ -package ch.unisg.executor1.common; +package ch.unisg.executorBase.common; import javax.validation.ConstraintViolation; import javax.validation.ConstraintViolationException; diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/adapter/in/web/TaskAvailableController.java b/executor-base/src/main/java/ch/unisg/executorBase/executor/adapter/in/web/TaskAvailableController.java similarity index 81% rename from executor1/src/main/java/ch/unisg/executor1/executor/adapter/in/web/TaskAvailableController.java rename to executor-base/src/main/java/ch/unisg/executorBase/executor/adapter/in/web/TaskAvailableController.java index eecc4a3..75d3a02 100644 --- a/executor1/src/main/java/ch/unisg/executor1/executor/adapter/in/web/TaskAvailableController.java +++ b/executor-base/src/main/java/ch/unisg/executorBase/executor/adapter/in/web/TaskAvailableController.java @@ -1,4 +1,4 @@ -package ch.unisg.executor1.executor.adapter.in.web; +package ch.unisg.executorBase.executor.adapter.in.web; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; @@ -7,9 +7,9 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RestController; -import ch.unisg.executor1.executor.application.port.in.TaskAvailableCommand; -import ch.unisg.executor1.executor.application.port.in.TaskAvailableUseCase; -import ch.unisg.executor1.executor.domain.ExecutorType; +import ch.unisg.executorBase.executor.application.port.in.TaskAvailableCommand; +import ch.unisg.executorBase.executor.application.port.in.TaskAvailableUseCase; +import ch.unisg.executorBase.executor.domain.ExecutorType; @RestController public class TaskAvailableController { diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/web/ExecutionFinishedEventAdapter.java b/executor-base/src/main/java/ch/unisg/executorBase/executor/adapter/out/web/ExecutionFinishedEventAdapter.java similarity index 89% rename from executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/web/ExecutionFinishedEventAdapter.java rename to executor-base/src/main/java/ch/unisg/executorBase/executor/adapter/out/web/ExecutionFinishedEventAdapter.java index 41e68a6..2f53a2b 100644 --- a/executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/web/ExecutionFinishedEventAdapter.java +++ b/executor-base/src/main/java/ch/unisg/executorBase/executor/adapter/out/web/ExecutionFinishedEventAdapter.java @@ -1,4 +1,4 @@ -package ch.unisg.executor1.executor.adapter.out.web; +package ch.unisg.executorBase.executor.adapter.out.web; import java.io.IOException; import java.net.URI; @@ -10,8 +10,8 @@ import java.util.HashMap; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.core.JsonProcessingException; -import ch.unisg.executor1.executor.application.port.out.ExecutionFinishedEventPort; -import ch.unisg.executor1.executor.domain.ExecutionFinishedEvent; +import ch.unisg.executorBase.executor.application.port.out.ExecutionFinishedEventPort; +import ch.unisg.executorBase.executor.domain.ExecutionFinishedEvent; public class ExecutionFinishedEventAdapter implements ExecutionFinishedEventPort { diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/web/GetAssignmentAdapter.java b/executor-base/src/main/java/ch/unisg/executorBase/executor/adapter/out/web/GetAssignmentAdapter.java similarity index 81% rename from executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/web/GetAssignmentAdapter.java rename to executor-base/src/main/java/ch/unisg/executorBase/executor/adapter/out/web/GetAssignmentAdapter.java index c7d8485..b3e7875 100644 --- a/executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/web/GetAssignmentAdapter.java +++ b/executor-base/src/main/java/ch/unisg/executorBase/executor/adapter/out/web/GetAssignmentAdapter.java @@ -1,4 +1,4 @@ -package ch.unisg.executor1.executor.adapter.out.web; +package ch.unisg.executorBase.executor.adapter.out.web; import java.net.URI; import java.net.http.HttpClient; @@ -7,9 +7,9 @@ import java.net.http.HttpRequest; import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Component; -import ch.unisg.executor1.executor.application.port.out.GetAssignmentPort; -import ch.unisg.executor1.executor.domain.ExecutorType; -import ch.unisg.executor1.executor.domain.Task; +import ch.unisg.executorBase.executor.application.port.out.GetAssignmentPort; +import ch.unisg.executorBase.executor.domain.ExecutorType; +import ch.unisg.executorBase.executor.domain.Task; @Component @Primary @@ -39,7 +39,7 @@ public class GetAssignmentAdapter implements GetAssignmentPort { // TODO return null or a new Task here depending on the response of the http call - return null; + return new Task("123"); } } diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/web/NotifyExecutorPoolAdapter.java b/executor-base/src/main/java/ch/unisg/executorBase/executor/adapter/out/web/NotifyExecutorPoolAdapter.java similarity index 90% rename from executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/web/NotifyExecutorPoolAdapter.java rename to executor-base/src/main/java/ch/unisg/executorBase/executor/adapter/out/web/NotifyExecutorPoolAdapter.java index d7a9238..feeca69 100644 --- a/executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/web/NotifyExecutorPoolAdapter.java +++ b/executor-base/src/main/java/ch/unisg/executorBase/executor/adapter/out/web/NotifyExecutorPoolAdapter.java @@ -1,4 +1,4 @@ -package ch.unisg.executor1.executor.adapter.out.web; +package ch.unisg.executorBase.executor.adapter.out.web; import java.net.URI; import java.net.http.HttpClient; @@ -11,8 +11,8 @@ import com.fasterxml.jackson.databind.ObjectMapper; import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Component; -import ch.unisg.executor1.executor.application.port.out.NotifyExecutorPoolPort; -import ch.unisg.executor1.executor.domain.ExecutorType; +import ch.unisg.executorBase.executor.application.port.out.NotifyExecutorPoolPort; +import ch.unisg.executorBase.executor.domain.ExecutorType; @Component @Primary diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/application/port/in/TaskAvailableCommand.java b/executor-base/src/main/java/ch/unisg/executorBase/executor/application/port/in/TaskAvailableCommand.java similarity index 66% rename from executor1/src/main/java/ch/unisg/executor1/executor/application/port/in/TaskAvailableCommand.java rename to executor-base/src/main/java/ch/unisg/executorBase/executor/application/port/in/TaskAvailableCommand.java index 292d18b..916c8eb 100644 --- a/executor1/src/main/java/ch/unisg/executor1/executor/application/port/in/TaskAvailableCommand.java +++ b/executor-base/src/main/java/ch/unisg/executorBase/executor/application/port/in/TaskAvailableCommand.java @@ -1,7 +1,7 @@ -package ch.unisg.executor1.executor.application.port.in; +package ch.unisg.executorBase.executor.application.port.in; -import ch.unisg.executor1.common.SelfValidating; -import ch.unisg.executor1.executor.domain.ExecutorType; +import ch.unisg.executorBase.common.SelfValidating; +import ch.unisg.executorBase.executor.domain.ExecutorType; import javax.validation.constraints.NotNull; diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/application/port/in/TaskAvailableUseCase.java b/executor-base/src/main/java/ch/unisg/executorBase/executor/application/port/in/TaskAvailableUseCase.java similarity index 62% rename from executor1/src/main/java/ch/unisg/executor1/executor/application/port/in/TaskAvailableUseCase.java rename to executor-base/src/main/java/ch/unisg/executorBase/executor/application/port/in/TaskAvailableUseCase.java index d8184c1..cc5215f 100644 --- a/executor1/src/main/java/ch/unisg/executor1/executor/application/port/in/TaskAvailableUseCase.java +++ b/executor-base/src/main/java/ch/unisg/executorBase/executor/application/port/in/TaskAvailableUseCase.java @@ -1,4 +1,4 @@ -package ch.unisg.executor1.executor.application.port.in; +package ch.unisg.executorBase.executor.application.port.in; public interface TaskAvailableUseCase { void newTaskAvailable(TaskAvailableCommand command); diff --git a/executor-base/src/main/java/ch/unisg/executorBase/executor/application/port/out/ExecutionFinishedEventPort.java b/executor-base/src/main/java/ch/unisg/executorBase/executor/application/port/out/ExecutionFinishedEventPort.java new file mode 100644 index 0000000..1bf668e --- /dev/null +++ b/executor-base/src/main/java/ch/unisg/executorBase/executor/application/port/out/ExecutionFinishedEventPort.java @@ -0,0 +1,7 @@ +package ch.unisg.executorBase.executor.application.port.out; + +import ch.unisg.executorBase.executor.domain.ExecutionFinishedEvent; + +public interface ExecutionFinishedEventPort { + void publishExecutionFinishedEvent(ExecutionFinishedEvent event); +} diff --git a/executor-base/src/main/java/ch/unisg/executorBase/executor/application/port/out/GetAssignmentPort.java b/executor-base/src/main/java/ch/unisg/executorBase/executor/application/port/out/GetAssignmentPort.java new file mode 100644 index 0000000..1f205b8 --- /dev/null +++ b/executor-base/src/main/java/ch/unisg/executorBase/executor/application/port/out/GetAssignmentPort.java @@ -0,0 +1,8 @@ +package ch.unisg.executorBase.executor.application.port.out; + +import ch.unisg.executorBase.executor.domain.ExecutorType; +import ch.unisg.executorBase.executor.domain.Task; + +public interface GetAssignmentPort { + Task getAssignment(ExecutorType executorType); +} diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/NotifyExecutorPoolPort.java b/executor-base/src/main/java/ch/unisg/executorBase/executor/application/port/out/NotifyExecutorPoolPort.java similarity index 51% rename from executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/NotifyExecutorPoolPort.java rename to executor-base/src/main/java/ch/unisg/executorBase/executor/application/port/out/NotifyExecutorPoolPort.java index 4086258..6d41ab4 100644 --- a/executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/NotifyExecutorPoolPort.java +++ b/executor-base/src/main/java/ch/unisg/executorBase/executor/application/port/out/NotifyExecutorPoolPort.java @@ -1,6 +1,6 @@ -package ch.unisg.executor1.executor.application.port.out; +package ch.unisg.executorBase.executor.application.port.out; -import ch.unisg.executor1.executor.domain.ExecutorType; +import ch.unisg.executorBase.executor.domain.ExecutorType; public interface NotifyExecutorPoolPort { boolean notifyExecutorPool(String ip, int port, ExecutorType executorType); diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/application/service/NotifyExecutorPoolService.java b/executor-base/src/main/java/ch/unisg/executorBase/executor/application/service/NotifyExecutorPoolService.java similarity index 52% rename from executor1/src/main/java/ch/unisg/executor1/executor/application/service/NotifyExecutorPoolService.java rename to executor-base/src/main/java/ch/unisg/executorBase/executor/application/service/NotifyExecutorPoolService.java index acfae94..a5ccb64 100644 --- a/executor1/src/main/java/ch/unisg/executor1/executor/application/service/NotifyExecutorPoolService.java +++ b/executor-base/src/main/java/ch/unisg/executorBase/executor/application/service/NotifyExecutorPoolService.java @@ -1,10 +1,7 @@ -package ch.unisg.executor1.executor.application.service; +package ch.unisg.executorBase.executor.application.service; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import ch.unisg.executor1.executor.application.port.out.NotifyExecutorPoolPort; -import ch.unisg.executor1.executor.domain.ExecutorType; +import ch.unisg.executorBase.executor.application.port.out.NotifyExecutorPoolPort; +import ch.unisg.executorBase.executor.domain.ExecutorType; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/domain/ExecutionFinishedEvent.java b/executor-base/src/main/java/ch/unisg/executorBase/executor/domain/ExecutionFinishedEvent.java similarity index 88% rename from executor1/src/main/java/ch/unisg/executor1/executor/domain/ExecutionFinishedEvent.java rename to executor-base/src/main/java/ch/unisg/executorBase/executor/domain/ExecutionFinishedEvent.java index 4455572..31fd0e6 100644 --- a/executor1/src/main/java/ch/unisg/executor1/executor/domain/ExecutionFinishedEvent.java +++ b/executor-base/src/main/java/ch/unisg/executorBase/executor/domain/ExecutionFinishedEvent.java @@ -1,4 +1,4 @@ -package ch.unisg.executor1.executor.domain; +package ch.unisg.executorBase.executor.domain; import lombok.Getter; diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/domain/ExecutorBase.java b/executor-base/src/main/java/ch/unisg/executorBase/executor/domain/ExecutorBase.java similarity index 76% rename from executor1/src/main/java/ch/unisg/executor1/executor/domain/ExecutorBase.java rename to executor-base/src/main/java/ch/unisg/executorBase/executor/domain/ExecutorBase.java index fe65913..e639cb3 100644 --- a/executor1/src/main/java/ch/unisg/executor1/executor/domain/ExecutorBase.java +++ b/executor-base/src/main/java/ch/unisg/executorBase/executor/domain/ExecutorBase.java @@ -1,8 +1,8 @@ -package ch.unisg.executor1.executor.domain; +package ch.unisg.executorBase.executor.domain; -import ch.unisg.executor1.executor.application.port.out.ExecutionFinishedEventPort; -import ch.unisg.executor1.executor.application.port.out.GetAssignmentPort; -import ch.unisg.executor1.executor.application.port.out.NotifyExecutorPoolPort; +import ch.unisg.executorBase.executor.application.port.out.ExecutionFinishedEventPort; +import ch.unisg.executorBase.executor.application.port.out.GetAssignmentPort; +import ch.unisg.executorBase.executor.application.port.out.NotifyExecutorPoolPort; import java.util.concurrent.TimeUnit; @@ -11,13 +11,13 @@ import javax.transaction.Transactional; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Configurable; -import ch.unisg.executor1.executor.adapter.out.web.ExecutionFinishedEventAdapter; -import ch.unisg.executor1.executor.adapter.out.web.GetAssignmentAdapter; -import ch.unisg.executor1.executor.adapter.out.web.NotifyExecutorPoolAdapter; -import ch.unisg.executor1.executor.application.service.NotifyExecutorPoolService; +import ch.unisg.executorBase.executor.adapter.out.web.ExecutionFinishedEventAdapter; +import ch.unisg.executorBase.executor.adapter.out.web.GetAssignmentAdapter; +import ch.unisg.executorBase.executor.adapter.out.web.NotifyExecutorPoolAdapter; +import ch.unisg.executorBase.executor.application.service.NotifyExecutorPoolService; import lombok.Getter; -abstract class ExecutorBase { +public abstract class ExecutorBase { @Getter private String ip; @@ -31,8 +31,6 @@ abstract class ExecutorBase { @Getter private ExecutorStatus status; - // private static final ExecutorBase executor = new ExecutorBase(); - // TODO Violation of the Dependency Inversion Principle?, but we havn't really got a better solutions to send a http request / access a service from a domain model // TODO I guess we can somehow autowire this but I don't know why it's not working :D private final NotifyExecutorPoolPort notifyExecutorPoolPort = new NotifyExecutorPoolAdapter(); @@ -82,6 +80,6 @@ abstract class ExecutorBase { getAssignment(); } - abstract String execution(); + protected abstract String execution(); } diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/domain/ExecutorStatus.java b/executor-base/src/main/java/ch/unisg/executorBase/executor/domain/ExecutorStatus.java similarity index 61% rename from executor1/src/main/java/ch/unisg/executor1/executor/domain/ExecutorStatus.java rename to executor-base/src/main/java/ch/unisg/executorBase/executor/domain/ExecutorStatus.java index 92af024..8bd5bc3 100644 --- a/executor1/src/main/java/ch/unisg/executor1/executor/domain/ExecutorStatus.java +++ b/executor-base/src/main/java/ch/unisg/executorBase/executor/domain/ExecutorStatus.java @@ -1,4 +1,4 @@ -package ch.unisg.executor1.executor.domain; +package ch.unisg.executorBase.executor.domain; public enum ExecutorStatus { STARTING_UP, diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/domain/ExecutorType.java b/executor-base/src/main/java/ch/unisg/executorBase/executor/domain/ExecutorType.java similarity index 85% rename from executor1/src/main/java/ch/unisg/executor1/executor/domain/ExecutorType.java rename to executor-base/src/main/java/ch/unisg/executorBase/executor/domain/ExecutorType.java index 58c9d91..0b2b305 100644 --- a/executor1/src/main/java/ch/unisg/executor1/executor/domain/ExecutorType.java +++ b/executor-base/src/main/java/ch/unisg/executorBase/executor/domain/ExecutorType.java @@ -1,4 +1,4 @@ -package ch.unisg.executor1.executor.domain; +package ch.unisg.executorBase.executor.domain; public enum ExecutorType { ADDITION, ROBOT; diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/domain/Task.java b/executor-base/src/main/java/ch/unisg/executorBase/executor/domain/Task.java similarity index 84% rename from executor1/src/main/java/ch/unisg/executor1/executor/domain/Task.java rename to executor-base/src/main/java/ch/unisg/executorBase/executor/domain/Task.java index 2287b6c..6719613 100644 --- a/executor1/src/main/java/ch/unisg/executor1/executor/domain/Task.java +++ b/executor-base/src/main/java/ch/unisg/executorBase/executor/domain/Task.java @@ -1,4 +1,4 @@ -package ch.unisg.executor1.executor.domain; +package ch.unisg.executorBase.executor.domain; import lombok.Data; import lombok.Getter; diff --git a/executor1/src/main/resources/application.properties b/executor-base/src/main/resources/application.properties similarity index 100% rename from executor1/src/main/resources/application.properties rename to executor-base/src/main/resources/application.properties diff --git a/executor1/src/test/java/ch/unisg/executor1/Executor1ApplicationTests.java b/executor-base/src/test/java/ch/unisg/executorBase/Executor1ApplicationTests.java similarity index 68% rename from executor1/src/test/java/ch/unisg/executor1/Executor1ApplicationTests.java rename to executor-base/src/test/java/ch/unisg/executorBase/Executor1ApplicationTests.java index 889c9cd..6fec034 100644 --- a/executor1/src/test/java/ch/unisg/executor1/Executor1ApplicationTests.java +++ b/executor-base/src/test/java/ch/unisg/executorBase/Executor1ApplicationTests.java @@ -1,10 +1,10 @@ -package ch.unisg.executor1; +package ch.unisg.executorBase; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; @SpringBootTest -class Executor1ApplicationTests { +class executorBaseApplicationTests { @Test void contextLoads() { diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/ExecutionFinishedEventPort.java b/executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/ExecutionFinishedEventPort.java deleted file mode 100644 index 6bfea70..0000000 --- a/executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/ExecutionFinishedEventPort.java +++ /dev/null @@ -1,7 +0,0 @@ -package ch.unisg.executor1.executor.application.port.out; - -import ch.unisg.executor1.executor.domain.ExecutionFinishedEvent; - -public interface ExecutionFinishedEventPort { - void publishExecutionFinishedEvent(ExecutionFinishedEvent event); -} diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/GetAssignmentPort.java b/executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/GetAssignmentPort.java deleted file mode 100644 index 7b81b13..0000000 --- a/executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/GetAssignmentPort.java +++ /dev/null @@ -1,8 +0,0 @@ -package ch.unisg.executor1.executor.application.port.out; - -import ch.unisg.executor1.executor.domain.ExecutorType; -import ch.unisg.executor1.executor.domain.Task; - -public interface GetAssignmentPort { - Task getAssignment(ExecutorType executorType); -} diff --git a/executor2/pom.xml b/executor2/pom.xml index 681cebd..95c67ff 100644 --- a/executor2/pom.xml +++ b/executor2/pom.xml @@ -40,6 +40,11 @@ spring-boot-starter-test test + + ch.unisg + executorBase + 0.0.1-SNAPSHOT + diff --git a/executor2/src/main/java/ch/unisg/executor2/Executor2Application.java b/executor2/src/main/java/ch/unisg/executor2/Executor2Application.java index d31e277..03edb3d 100644 --- a/executor2/src/main/java/ch/unisg/executor2/Executor2Application.java +++ b/executor2/src/main/java/ch/unisg/executor2/Executor2Application.java @@ -3,11 +3,14 @@ package ch.unisg.executor2; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import ch.unisg.executor2.executor.domain.Executor; + @SpringBootApplication public class Executor2Application { public static void main(String[] args) { SpringApplication.run(Executor2Application.class, args); + Executor.getExecutor(); } } diff --git a/executor2/src/main/java/ch/unisg/executor2/TestController.java b/executor2/src/main/java/ch/unisg/executor2/TestController.java deleted file mode 100644 index c98bb02..0000000 --- a/executor2/src/main/java/ch/unisg/executor2/TestController.java +++ /dev/null @@ -1,12 +0,0 @@ -package ch.unisg.executor2; - -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class TestController { - @RequestMapping("/") - public String index() { - return "Hello World! Executor2"; - } -} diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/application/service/TaskAvailableService.java b/executor2/src/main/java/ch/unisg/executor2/executor/application/service/TaskAvailableService.java similarity index 63% rename from executor1/src/main/java/ch/unisg/executor1/executor/application/service/TaskAvailableService.java rename to executor2/src/main/java/ch/unisg/executor2/executor/application/service/TaskAvailableService.java index 6f15b47..4484ebb 100644 --- a/executor1/src/main/java/ch/unisg/executor1/executor/application/service/TaskAvailableService.java +++ b/executor2/src/main/java/ch/unisg/executor2/executor/application/service/TaskAvailableService.java @@ -1,11 +1,11 @@ -package ch.unisg.executor1.executor.application.service; +package ch.unisg.executor2.executor.application.service; import org.springframework.stereotype.Component; -import ch.unisg.executor1.executor.application.port.in.TaskAvailableCommand; -import ch.unisg.executor1.executor.application.port.in.TaskAvailableUseCase; -import ch.unisg.executor1.executor.domain.Executor; -import ch.unisg.executor1.executor.domain.ExecutorStatus; +import ch.unisg.executor2.executor.domain.Executor; +import ch.unisg.executorBase.executor.application.port.in.TaskAvailableCommand; +import ch.unisg.executorBase.executor.application.port.in.TaskAvailableUseCase; +import ch.unisg.executorBase.executor.domain.ExecutorStatus; import lombok.RequiredArgsConstructor; import javax.transaction.Transactional; @@ -17,6 +17,7 @@ public class TaskAvailableService implements TaskAvailableUseCase { @Override public void newTaskAvailable(TaskAvailableCommand command) { + Executor executor = Executor.getExecutor(); if (executor.getExecutorType() == command.getTaskType() && diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/domain/Executor.java b/executor2/src/main/java/ch/unisg/executor2/executor/domain/Executor.java similarity index 76% rename from executor1/src/main/java/ch/unisg/executor1/executor/domain/Executor.java rename to executor2/src/main/java/ch/unisg/executor2/executor/domain/Executor.java index d8f9e0b..bb9308b 100644 --- a/executor1/src/main/java/ch/unisg/executor1/executor/domain/Executor.java +++ b/executor2/src/main/java/ch/unisg/executor2/executor/domain/Executor.java @@ -1,6 +1,8 @@ -package ch.unisg.executor1.executor.domain; +package ch.unisg.executor2.executor.domain; import java.util.concurrent.TimeUnit; +import ch.unisg.executorBase.executor.domain.ExecutorBase; +import ch.unisg.executorBase.executor.domain.ExecutorType; public class Executor extends ExecutorBase { @@ -15,9 +17,10 @@ public class Executor extends ExecutorBase { } @Override + protected String execution() { - int a = 10; + int a = 20; int b = 20; try { TimeUnit.SECONDS.sleep(10); From a7f62a8b23b380afcfbf789b7ee5fb546acdecdd Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 13 Oct 2021 16:24:38 +0200 Subject: [PATCH 04/17] edited editorconfig --- .editorconfig | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.editorconfig b/.editorconfig index 74c6104..c4f3e5b 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,12 +1,9 @@ root = true [*] -end_of_line = lf -insert_final_newline = true - -[*.{java}] +charset = utf-8 indent_style = space indent_size = 4 -tab_width = 4 trim_trailing_whitespace = true -max_line_length = 100 +end_of_line = lf +insert_final_newline = true From 4a85548a9e78890a2f3e6d94e7f22fd0b8749957 Mon Sep 17 00:00:00 2001 From: Marcel Date: Thu, 14 Oct 2021 17:49:09 +0200 Subject: [PATCH 05/17] github actions fixes & improvements --- .github/workflows/build-and-deploy.yml | 143 ++++++++++++++----------- .github/workflows/ci.executor1.yml | 78 +++++++------- .github/workflows/ci.executor2.yml | 78 +++++++------- 3 files changed, 163 insertions(+), 136 deletions(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 43bb471..42b93ad 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -4,75 +4,94 @@ name: Build and Deploy on: - push: - branches: - - main + push: + branches: + - main - workflow_dispatch: + workflow_dispatch: jobs: - build: - runs-on: ubuntu-latest - permissions: - contents: read + build: + runs-on: ubuntu-latest + permissions: + contents: read - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v2 - with: - java-version: "11" - distribution: "adopt" + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + java-version: "11" + distribution: "adopt" - - run: mkdir ./target + - run: mkdir ./target - - name: Build with Maven - run: mvn -f tapas-tasks/pom.xml --batch-mode --update-snapshots verify - - run: cp ./tapas-tasks/target/tapas-tasks-0.0.1-SNAPSHOT.jar ./target + - name: Cache Maven packages + uses: actions/cache@v1 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 - - name: Build with Maven - run: mvn -f app/pom.xml --batch-mode --update-snapshots verify - - run: cp ./app/target/app-0.1.0.jar ./target + - name: Build with Maven + run: mvn -f assignment/pom.xml --batch-mode --update-snapshots verify + - run: cp ./assignment/target/assignment-0.0.1-SNAPSHOT.jar ./target - - run: cp ./.deployment/docker-compose.yml ./target - - name: Archive artifacts - uses: actions/upload-artifact@v1 - with: - name: app - path: ./target/ + - name: Build with Maven + run: mvn -f executor-pool/pom.xml --batch-mode --update-snapshots verify + - run: cp ./executor-pool/target/executor-pool-0.0.1.jar ./target - deploy: - runs-on: ubuntu-latest - needs: [build] - steps: - - name: Download app artifacts - uses: actions/download-artifact@v1 - with: - name: app - - name: Copy host via scp - uses: appleboy/scp-action@master - env: - HOST: ${{ secrets.SSH_HOST }} - USERNAME: ${{ secrets.SSH_USER }} - PORT: 22 - KEY: ${{ secrets.SSH_PRIVATE_KEY }} - with: - source: "app/*" - target: "/home/${{ secrets.SSH_USER }}/" - strip_components: 1 - rm: false - overwrite: true + - name: Build with Maven + run: mvn -f executor1/pom.xml --batch-mode --update-snapshots verify + - run: cp ./executor1/target/executor1-0.0.1.jar ./target - - name: Executing remote command - uses: appleboy/ssh-action@master - with: - host: ${{ secrets.SSH_HOST }} - USERNAME: ${{ secrets.SSH_USER }} - PORT: 22 - KEY: ${{ secrets.SSH_PRIVATE_KEY }} - script: | - cd /home/${{ secrets.SSH_USER }}/ - touch acme.json - sudo chmod 0600 acme.json - sudo echo "PUB_IP=$(wget -qO- http://ipecho.net/plain | xargs echo)" | sed -e 's/\./-/g' > .env - sudo docker-compose up -d + - name: Build with Maven + run: mvn -f executor2/pom.xml --batch-mode --update-snapshots verify + - run: cp ./executor2/target/executor2-0.0.1.jar ./target + + - name: Build with Maven + run: mvn -f tapas-tasks/pom.xml --batch-mode --update-snapshots verify + - run: cp ./tapas-tasks/target/tapas-tasks-0.0.1.jar ./target + + - run: cp ./.deployment/docker-compose.yml ./target + - name: Archive artifacts + uses: actions/upload-artifact@v1 + with: + name: app + path: ./target/ + + deploy: + runs-on: ubuntu-latest + needs: [build] + steps: + - name: Download app artifacts + uses: actions/download-artifact@v1 + with: + name: app + - name: Copy host via scp + uses: appleboy/scp-action@master + env: + HOST: ${{ secrets.SSH_HOST }} + USERNAME: ${{ secrets.SSH_USER }} + PORT: 22 + KEY: ${{ secrets.SSH_PRIVATE_KEY }} + with: + source: "app/*" + target: "/home/${{ secrets.SSH_USER }}/" + strip_components: 1 + rm: false + overwrite: true + + - name: Executing remote command + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.SSH_HOST }} + USERNAME: ${{ secrets.SSH_USER }} + PORT: 22 + KEY: ${{ secrets.SSH_PRIVATE_KEY }} + script: | + cd /home/${{ secrets.SSH_USER }}/ + touch acme.json + sudo chmod 0600 acme.json + sudo echo "PUB_IP=$(wget -qO- http://ipecho.net/plain | xargs echo)" | sed -e 's/\./-/g' > .env + sudo docker-compose up -d diff --git a/.github/workflows/ci.executor1.yml b/.github/workflows/ci.executor1.yml index 277d313..5d48580 100644 --- a/.github/workflows/ci.executor1.yml +++ b/.github/workflows/ci.executor1.yml @@ -1,41 +1,45 @@ name: CI Executor 1 on: - push: - branches: [main, dev] - paths: - - "executor1/**" - pull_request: - branches: [main, dev] - paths: - - "executor1/**" + push: + branches: [main, dev] + paths: + - "executor-base/**" + - "executor1/**" + pull_request: + branches: [main, dev] + paths: + - "executor-base/**" + - "executor1/**" - workflow_dispatch: + workflow_dispatch: jobs: - build: - name: Build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Set up JDK 11 - uses: actions/setup-java@v1 - with: - java-version: 11 - - name: Cache SonarCloud packages - uses: actions/cache@v1 - with: - path: ~/.sonar/cache - key: ${{ runner.os }}-sonar - restore-keys: ${{ runner.os }}-sonar - - name: Cache Maven packages - uses: actions/cache@v1 - with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2 - - name: Build and analyze - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: mvn -f executor1/pom.xml -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=scs-asse-fs21-group1_tapas-executor1 + build: + name: Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + - name: Cache SonarCloud packages + uses: actions/cache@v1 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + - name: Cache Maven packages + uses: actions/cache@v1 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + - name: Build executorBase + run: mvn -f executor-base/pom.xml -B verify + - name: Build and analyze + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: mvn -f executor1/pom.xml -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=scs-asse-fs21-group1_tapas-executor1 diff --git a/.github/workflows/ci.executor2.yml b/.github/workflows/ci.executor2.yml index d763cd1..32a59a8 100644 --- a/.github/workflows/ci.executor2.yml +++ b/.github/workflows/ci.executor2.yml @@ -1,41 +1,45 @@ name: CI Executor 2 on: - push: - branches: [main, dev] - paths: - - "executor2/**" - pull_request: - branches: [main, dev] - paths: - - "executor2/**" + push: + branches: [main, dev] + paths: + - "executor-base/**" + - "executor2/**" + pull_request: + branches: [main, dev] + paths: + - "executor-base/**" + - "executor2/**" - workflow_dispatch: + workflow_dispatch: jobs: - build: - name: Build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Set up JDK 11 - uses: actions/setup-java@v1 - with: - java-version: 11 - - name: Cache SonarCloud packages - uses: actions/cache@v1 - with: - path: ~/.sonar/cache - key: ${{ runner.os }}-sonar - restore-keys: ${{ runner.os }}-sonar - - name: Cache Maven packages - uses: actions/cache@v1 - with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2 - - name: Build and analyze - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: mvn -f executor2/pom.xml -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=scs-asse-fs21-group1_tapas-executor2 + build: + name: Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + - name: Cache SonarCloud packages + uses: actions/cache@v1 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + - name: Cache Maven packages + uses: actions/cache@v1 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + - name: Build executorBase + run: mvn -f executor-base/pom.xml -B verify + - name: Build and analyze + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: mvn -f executor2/pom.xml -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=scs-asse-fs21-group1_tapas-executor2 From 6a8ce604349e173779e3a2751dd81018182f17bf Mon Sep 17 00:00:00 2001 From: jj187 Date: Sat, 16 Oct 2021 19:16:20 +0200 Subject: [PATCH 06/17] adding all changes made to task list --- .../in/web/CompleteTaskWebController.java | 41 ++++++++++++++++ .../in/web/DeleteTaskWebController.java | 48 +++++++++++++++++++ .../in/web/TaskAssignedWebController.java | 42 ++++++++++++++++ .../tasks/adapter/in/web/TaskMediaType.java | 2 +- .../PublishNewTaskAddedEventWebAdapter.java | 2 + .../port/in/CompleteTaskCommand.java | 23 +++++++++ .../port/in/CompleteTaskUseCase.java | 7 +++ .../port/in/DeleteTaskCommand.java | 18 +++++++ .../port/in/DeleteTaskUseCase.java | 9 ++++ .../port/in/TaskAssignedCommand.java | 18 +++++++ .../port/in/TaskAssignedUseCase.java | 7 +++ .../service/AddNewTaskToTaskListService.java | 2 +- .../service/CompleteTaskService.java | 35 ++++++++++++++ .../service/DeleteTaskService.java | 25 ++++++++++ .../service/TaskAssignedService.java | 31 ++++++++++++ .../tasks/domain/NewTaskAddedEvent.java | 7 ++- .../unisg/tapastasks/tasks/domain/Task.java | 12 ++++- .../tapastasks/tasks/domain/TaskList.java | 14 +++++- 18 files changed, 337 insertions(+), 6 deletions(-) create mode 100644 tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/adapter/in/web/CompleteTaskWebController.java create mode 100644 tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/adapter/in/web/DeleteTaskWebController.java create mode 100644 tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/adapter/in/web/TaskAssignedWebController.java create mode 100644 tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/port/in/CompleteTaskCommand.java create mode 100644 tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/port/in/CompleteTaskUseCase.java create mode 100644 tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/port/in/DeleteTaskCommand.java create mode 100644 tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/port/in/DeleteTaskUseCase.java create mode 100644 tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/port/in/TaskAssignedCommand.java create mode 100644 tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/port/in/TaskAssignedUseCase.java create mode 100644 tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/service/CompleteTaskService.java create mode 100644 tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/service/DeleteTaskService.java create mode 100644 tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/service/TaskAssignedService.java diff --git a/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/adapter/in/web/CompleteTaskWebController.java b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/adapter/in/web/CompleteTaskWebController.java new file mode 100644 index 0000000..e160c2b --- /dev/null +++ b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/adapter/in/web/CompleteTaskWebController.java @@ -0,0 +1,41 @@ +package ch.unisg.tapastasks.tasks.adapter.in.web; + +import ch.unisg.tapastasks.tasks.application.port.in.CompleteTaskCommand; +import ch.unisg.tapastasks.tasks.application.port.in.CompleteTaskUseCase; +import ch.unisg.tapastasks.tasks.domain.Task; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.server.ResponseStatusException; + +import javax.validation.ConstraintViolationException; + +@RestController +public class CompleteTaskWebController { + private final CompleteTaskUseCase completeTaskUseCase; + + public CompleteTaskWebController(CompleteTaskUseCase completeTaskUseCase){ + this.completeTaskUseCase = completeTaskUseCase; + } + + @PostMapping(path = "/tasks/completeTask", consumes = {TaskMediaType.TASK_MEDIA_TYPE}) + public ResponseEntity completeTask (@RequestBody Task task){ + try { + CompleteTaskCommand command = new CompleteTaskCommand( + task.getTaskId(), task.getTaskResult() + ); + + Task updateATask = completeTaskUseCase.completeTask(command); + + HttpHeaders responseHeaders = new HttpHeaders(); + responseHeaders.add(HttpHeaders.CONTENT_TYPE, TaskMediaType.TASK_MEDIA_TYPE); + + return new ResponseEntity<>(TaskMediaType.serialize(updateATask), responseHeaders, HttpStatus.ACCEPTED); + } catch(ConstraintViolationException e){ + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, e.getMessage()); + } + } +} diff --git a/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/adapter/in/web/DeleteTaskWebController.java b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/adapter/in/web/DeleteTaskWebController.java new file mode 100644 index 0000000..6758337 --- /dev/null +++ b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/adapter/in/web/DeleteTaskWebController.java @@ -0,0 +1,48 @@ +package ch.unisg.tapastasks.tasks.adapter.in.web; + + +import ch.unisg.tapastasks.tasks.application.port.in.DeleteTaskCommand; +import ch.unisg.tapastasks.tasks.application.port.in.DeleteTaskUseCase; +import ch.unisg.tapastasks.tasks.domain.Task; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.server.ResponseStatusException; + +import javax.validation.ConstraintViolationException; +import java.util.Optional; + +@RestController +public class DeleteTaskWebController { + private final DeleteTaskUseCase deleteClassUseCase; + + public DeleteTaskWebController(DeleteTaskUseCase deleteClassUseCase){ + this.deleteClassUseCase = deleteClassUseCase; + } + + @PostMapping(path="/tasks/deleteTask", consumes = {TaskMediaType.TASK_MEDIA_TYPE}) + public ResponseEntity deleteTask (@RequestBody Task task){ + try { + DeleteTaskCommand command = new DeleteTaskCommand(task.getTaskId()); + + Optional deleteATask = deleteClassUseCase.deleteTask(command); + + // Check if the task with the given identifier exists + if (deleteATask.isEmpty()) { + // If not, through a 404 Not Found status code + throw new ResponseStatusException(HttpStatus.NOT_FOUND); + } + + HttpHeaders responseHeaders = new HttpHeaders(); + responseHeaders.add(HttpHeaders.CONTENT_TYPE, TaskMediaType.TASK_MEDIA_TYPE); + + + return new ResponseEntity<>(TaskMediaType.serialize(deleteATask.get()), responseHeaders, HttpStatus.ACCEPTED); + } catch(ConstraintViolationException e){ + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, e.getMessage()); + } + } +} diff --git a/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/adapter/in/web/TaskAssignedWebController.java b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/adapter/in/web/TaskAssignedWebController.java new file mode 100644 index 0000000..9dfa6a2 --- /dev/null +++ b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/adapter/in/web/TaskAssignedWebController.java @@ -0,0 +1,42 @@ +package ch.unisg.tapastasks.tasks.adapter.in.web; + +import ch.unisg.tapastasks.tasks.application.port.in.TaskAssignedCommand; +import ch.unisg.tapastasks.tasks.application.port.in.TaskAssignedUseCase; +import ch.unisg.tapastasks.tasks.domain.Task; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.server.ResponseStatusException; + +import javax.validation.ConstraintViolationException; + +@RestController +public class TaskAssignedWebController { + private final TaskAssignedUseCase taskAssignedUseCase; + + public TaskAssignedWebController(TaskAssignedUseCase taskAssignedUseCase){ + this.taskAssignedUseCase = taskAssignedUseCase; + } + + @PostMapping(path="/tasks/assignTask", consumes= {TaskMediaType.TASK_MEDIA_TYPE}) + public ResponseEntity assignTask(@RequestBody Task task){ + try{ + TaskAssignedCommand command = new TaskAssignedCommand( + task.getTaskId() + ); + + Task updateATask = taskAssignedUseCase.assignTask(command); + + HttpHeaders responseHeaders = new HttpHeaders(); + responseHeaders.add(HttpHeaders.CONTENT_TYPE, TaskMediaType.TASK_MEDIA_TYPE); + + return new ResponseEntity<>(TaskMediaType.serialize(updateATask), responseHeaders, HttpStatus.ACCEPTED); + } catch (ConstraintViolationException e){ + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, e.getMessage()); + } + } + +} diff --git a/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/adapter/in/web/TaskMediaType.java b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/adapter/in/web/TaskMediaType.java index 3c555e5..d9a0a46 100644 --- a/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/adapter/in/web/TaskMediaType.java +++ b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/adapter/in/web/TaskMediaType.java @@ -15,7 +15,7 @@ final public class TaskMediaType { payload.put("taskType", task.getTaskType().getValue()); payload.put("taskState", task.getTaskState().getValue()); payload.put("taskListName", TaskList.getTapasTaskList().getTaskListName().getValue()); - + payload.put("taskResult", task.getTaskResult().getValue()); return payload.toString(); } 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 db02f2a..7ae8e90 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 @@ -29,6 +29,8 @@ public class PublishNewTaskAddedEventWebAdapter implements NewTaskAddedEventPort var values = new HashMap() {{ put("taskname",event.taskName); put("tasklist",event.taskListName); + put("taskId", event.taskId); + put("taskType", event.taskType); }}; var objectMapper = new ObjectMapper(); diff --git a/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/port/in/CompleteTaskCommand.java b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/port/in/CompleteTaskCommand.java new file mode 100644 index 0000000..0634165 --- /dev/null +++ b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/port/in/CompleteTaskCommand.java @@ -0,0 +1,23 @@ +package ch.unisg.tapastasks.tasks.application.port.in; + +import ch.unisg.tapastasks.common.SelfValidating; +import ch.unisg.tapastasks.tasks.domain.Task.TaskId; +import ch.unisg.tapastasks.tasks.domain.Task.TaskResult; +import lombok.Value; + +import javax.validation.constraints.NotNull; + +@Value +public class CompleteTaskCommand extends SelfValidating { + @NotNull + private final TaskId taskId; + + @NotNull + private final TaskResult taskResult; + + public CompleteTaskCommand(TaskId taskId, TaskResult taskResult){ + this.taskId = taskId; + this.taskResult = taskResult; + this.validateSelf(); + } +} diff --git a/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/port/in/CompleteTaskUseCase.java b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/port/in/CompleteTaskUseCase.java new file mode 100644 index 0000000..6fba7e6 --- /dev/null +++ b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/port/in/CompleteTaskUseCase.java @@ -0,0 +1,7 @@ +package ch.unisg.tapastasks.tasks.application.port.in; + +import ch.unisg.tapastasks.tasks.domain.Task; + +public interface CompleteTaskUseCase { + Task completeTask(CompleteTaskCommand command); +} diff --git a/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/port/in/DeleteTaskCommand.java b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/port/in/DeleteTaskCommand.java new file mode 100644 index 0000000..24acbb8 --- /dev/null +++ b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/port/in/DeleteTaskCommand.java @@ -0,0 +1,18 @@ +package ch.unisg.tapastasks.tasks.application.port.in; + +import ch.unisg.tapastasks.common.SelfValidating; +import ch.unisg.tapastasks.tasks.domain.Task.TaskId; +import lombok.Value; + +import javax.validation.constraints.NotNull; + +@Value +public class DeleteTaskCommand extends SelfValidating { + @NotNull + private final TaskId taskId; + + public DeleteTaskCommand(TaskId taskId){ + this.taskId=taskId; + this.validateSelf(); + } +} diff --git a/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/port/in/DeleteTaskUseCase.java b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/port/in/DeleteTaskUseCase.java new file mode 100644 index 0000000..8ba206f --- /dev/null +++ b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/port/in/DeleteTaskUseCase.java @@ -0,0 +1,9 @@ +package ch.unisg.tapastasks.tasks.application.port.in; + +import ch.unisg.tapastasks.tasks.domain.Task; + +import java.util.Optional; + +public interface DeleteTaskUseCase { + Optional deleteTask(DeleteTaskCommand command); +} diff --git a/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/port/in/TaskAssignedCommand.java b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/port/in/TaskAssignedCommand.java new file mode 100644 index 0000000..7a5e383 --- /dev/null +++ b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/port/in/TaskAssignedCommand.java @@ -0,0 +1,18 @@ +package ch.unisg.tapastasks.tasks.application.port.in; + +import ch.unisg.tapastasks.common.SelfValidating; +import ch.unisg.tapastasks.tasks.domain.Task.TaskId; +import lombok.Value; + +import javax.validation.constraints.NotNull; + +@Value +public class TaskAssignedCommand extends SelfValidating { + @NotNull + private final TaskId taskId; + + public TaskAssignedCommand(TaskId taskId){ + this.taskId=taskId; + this.validateSelf(); + } +} diff --git a/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/port/in/TaskAssignedUseCase.java b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/port/in/TaskAssignedUseCase.java new file mode 100644 index 0000000..3a84587 --- /dev/null +++ b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/port/in/TaskAssignedUseCase.java @@ -0,0 +1,7 @@ +package ch.unisg.tapastasks.tasks.application.port.in; + +import ch.unisg.tapastasks.tasks.domain.Task; + +public interface TaskAssignedUseCase { + Task assignTask(TaskAssignedCommand command); +} diff --git a/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/service/AddNewTaskToTaskListService.java b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/service/AddNewTaskToTaskListService.java index 48c75a6..f1a6a8c 100644 --- a/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/service/AddNewTaskToTaskListService.java +++ b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/service/AddNewTaskToTaskListService.java @@ -30,7 +30,7 @@ public class AddNewTaskToTaskListService implements AddNewTaskToTaskListUseCase //the core and then the integration event in the application layer. if (newTask != null) { NewTaskAddedEvent newTaskAdded = new NewTaskAddedEvent(newTask.getTaskName().getValue(), - taskList.getTaskListName().getValue()); + taskList.getTaskListName().getValue(), newTask.getTaskId().getValue(), newTask.getTaskType().getValue()); newTaskAddedEventPort.publishNewTaskAddedEvent(newTaskAdded); } diff --git a/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/service/CompleteTaskService.java b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/service/CompleteTaskService.java new file mode 100644 index 0000000..bade832 --- /dev/null +++ b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/service/CompleteTaskService.java @@ -0,0 +1,35 @@ +package ch.unisg.tapastasks.tasks.application.service; + +import ch.unisg.tapastasks.tasks.application.port.in.CompleteTaskCommand; +import ch.unisg.tapastasks.tasks.application.port.in.CompleteTaskUseCase; +import ch.unisg.tapastasks.tasks.domain.Task; +import ch.unisg.tapastasks.tasks.domain.Task.*; +import ch.unisg.tapastasks.tasks.domain.TaskList; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; + +import javax.transaction.Transactional; +import java.util.Optional; + +@RequiredArgsConstructor +@Component +@Transactional +public class CompleteTaskService implements CompleteTaskUseCase { + + @Override + public Task completeTask(CompleteTaskCommand command){ + // TODO Retrieve the task based on ID + TaskList taskList = TaskList.getTapasTaskList(); + Optional updatedTask = taskList.retrieveTaskById(command.getTaskId()); + + // TODO Update the status and result (and save?) + Task newTask = updatedTask.get(); + newTask.taskResult = new TaskResult(command.getTaskResult().getValue()); + newTask.taskState = new TaskState(Task.State.EXECUTED); + + + // TODO return the updated task + return newTask; + } +} diff --git a/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/service/DeleteTaskService.java b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/service/DeleteTaskService.java new file mode 100644 index 0000000..05d1da5 --- /dev/null +++ b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/service/DeleteTaskService.java @@ -0,0 +1,25 @@ +package ch.unisg.tapastasks.tasks.application.service; + + +import ch.unisg.tapastasks.tasks.application.port.in.DeleteTaskCommand; +import ch.unisg.tapastasks.tasks.application.port.in.DeleteTaskUseCase; +import ch.unisg.tapastasks.tasks.domain.Task; +import ch.unisg.tapastasks.tasks.domain.TaskList; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; + +import javax.transaction.Transactional; +import java.util.Optional; + +@RequiredArgsConstructor +@Component +@Transactional +public class DeleteTaskService implements DeleteTaskUseCase { + + @Override + public Optional deleteTask(DeleteTaskCommand command){ + TaskList taskList = TaskList.getTapasTaskList(); + return taskList.deleteTaskById(command.getTaskId()); + + } +} diff --git a/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/service/TaskAssignedService.java b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/service/TaskAssignedService.java new file mode 100644 index 0000000..baa6059 --- /dev/null +++ b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/service/TaskAssignedService.java @@ -0,0 +1,31 @@ +package ch.unisg.tapastasks.tasks.application.service; + +import ch.unisg.tapastasks.tasks.application.port.in.TaskAssignedCommand; +import ch.unisg.tapastasks.tasks.application.port.in.TaskAssignedUseCase; +import ch.unisg.tapastasks.tasks.domain.Task; +import ch.unisg.tapastasks.tasks.domain.Task.*; +import ch.unisg.tapastasks.tasks.domain.TaskList; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; + +import javax.transaction.Transactional; +import java.util.Optional; + +@RequiredArgsConstructor +@Component +@Transactional +public class TaskAssignedService implements TaskAssignedUseCase { + + @Override + public Task assignTask(TaskAssignedCommand command) { + // retrieve the task based on ID + TaskList taskList = TaskList.getTapasTaskList(); + Optional task = taskList.retrieveTaskById(command.getTaskId()); + + // update the status to assigned + Task updatedTask = task.get(); + updatedTask.taskState = new TaskState(State.ASSIGNED); + + return updatedTask; + } +} diff --git a/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/domain/NewTaskAddedEvent.java b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/domain/NewTaskAddedEvent.java index 32f5966..a4703f2 100644 --- a/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/domain/NewTaskAddedEvent.java +++ b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/domain/NewTaskAddedEvent.java @@ -4,9 +4,14 @@ package ch.unisg.tapastasks.tasks.domain; public class NewTaskAddedEvent { public String taskName; public String taskListName; + public String taskId; + public String taskType; - public NewTaskAddedEvent(String taskName, String taskListName) { + public NewTaskAddedEvent(String taskName, String taskListName, String taskId, String taskType) { this.taskName = taskName; this.taskListName = taskListName; + this.taskId = taskId; + this.taskType = taskType; } + } diff --git a/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/domain/Task.java b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/domain/Task.java index 0dcafc3..3decd1f 100644 --- a/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/domain/Task.java +++ b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/domain/Task.java @@ -22,13 +22,18 @@ public class Task { private final TaskType taskType; @Getter - private TaskState taskState; + public TaskState taskState; // had to make public for CompleteTaskService + + @Getter + public TaskResult taskResult; // same as above + public Task(TaskName taskName, TaskType taskType) { this.taskName = taskName; this.taskType = taskType; this.taskState = new TaskState(State.OPEN); this.taskId = new TaskId(UUID.randomUUID().toString()); + this.taskResult = new TaskResult(""); } protected static Task createTaskWithNameAndType(TaskName name, TaskType type) { @@ -56,4 +61,9 @@ public class Task { public static class TaskType { private String value; } + + @Value + public static class TaskResult{ + private String value; + } } diff --git a/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/domain/TaskList.java b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/domain/TaskList.java index 2b90da5..ccdc59a 100644 --- a/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/domain/TaskList.java +++ b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/domain/TaskList.java @@ -20,8 +20,7 @@ public class TaskList { //Note: We do not care about the management of task lists, there is only one within this service //--> using the Singleton pattern here to make lives easy; we will later load it from a repo - //TODO change "tutors" to your group name ("groupx") - private static final TaskList taskList = new TaskList(new TaskListName("tapas-tasks-tutors")); + private static final TaskList taskList = new TaskList(new TaskListName("tapas-tasks-group1")); private TaskList(TaskListName taskListName) { this.taskListName = taskListName; @@ -55,6 +54,17 @@ public class TaskList { return Optional.empty(); } + public Optional deleteTaskById(Task.TaskId id) { + for (Task task: listOfTasks.value){ + if(task.getTaskId().getValue().equalsIgnoreCase(id.getValue())){ + listOfTasks.value.remove(task); + return Optional.of(task); + } + } + + return Optional.empty(); + } + @Value public static class TaskListName { private String value; From dfdad08827629ab751681e5df46e42dfb0d2055c Mon Sep 17 00:00:00 2001 From: rahimiankeanu Date: Sat, 16 Oct 2021 20:36:28 +0200 Subject: [PATCH 07/17] Implementation of Executor1 --- executor1/.gitignore | 33 ++ .../.mvn/wrapper/MavenWrapperDownloader.java | 117 +++++++ executor1/.mvn/wrapper/maven-wrapper.jar | Bin 0 -> 50710 bytes .../.mvn/wrapper/maven-wrapper.properties | 2 + executor1/Dockerfile | 18 + executor1/mvnw | 310 ++++++++++++++++++ executor1/mvnw.cmd | 182 ++++++++++ executor1/pom.xml | 67 ++++ .../unisg/executor1/Executor1Application.java | 16 + .../out/DeleteUserFromRobotAdapter.java | 42 +++ .../out/InstructionToRobotAdapter.java | 46 +++ .../adapter/out/UserToRobotAdapter.java | 46 +++ .../port/out/DeleteUserFromRobotPort.java | 5 + .../port/out/InstructionToRobotPort.java | 5 + .../application/port/out/UserToRobotPort.java | 7 + .../service/TaskAvailableService.java | 28 ++ .../executor1/executor/domain/Executor.java | 42 +++ .../src/main/resources/application.properties | 1 + .../executor2/Executor2ApplicationTests.java | 13 + 19 files changed, 980 insertions(+) create mode 100644 executor1/.gitignore create mode 100644 executor1/.mvn/wrapper/MavenWrapperDownloader.java create mode 100644 executor1/.mvn/wrapper/maven-wrapper.jar create mode 100644 executor1/.mvn/wrapper/maven-wrapper.properties create mode 100644 executor1/Dockerfile create mode 100755 executor1/mvnw create mode 100644 executor1/mvnw.cmd create mode 100644 executor1/pom.xml create mode 100644 executor1/src/main/java/ch/unisg/executor1/Executor1Application.java create mode 100644 executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/DeleteUserFromRobotAdapter.java create mode 100644 executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/InstructionToRobotAdapter.java create mode 100644 executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/UserToRobotAdapter.java create mode 100644 executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/DeleteUserFromRobotPort.java create mode 100644 executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/InstructionToRobotPort.java create mode 100644 executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/UserToRobotPort.java create mode 100644 executor1/src/main/java/ch/unisg/executor1/executor/application/service/TaskAvailableService.java create mode 100644 executor1/src/main/java/ch/unisg/executor1/executor/domain/Executor.java create mode 100644 executor1/src/main/resources/application.properties create mode 100644 executor1/src/test/java/ch/unisg/executor2/Executor2ApplicationTests.java diff --git a/executor1/.gitignore b/executor1/.gitignore new file mode 100644 index 0000000..549e00a --- /dev/null +++ b/executor1/.gitignore @@ -0,0 +1,33 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/executor1/.mvn/wrapper/MavenWrapperDownloader.java b/executor1/.mvn/wrapper/MavenWrapperDownloader.java new file mode 100644 index 0000000..e76d1f3 --- /dev/null +++ b/executor1/.mvn/wrapper/MavenWrapperDownloader.java @@ -0,0 +1,117 @@ +/* + * Copyright 2007-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import java.net.*; +import java.io.*; +import java.nio.channels.*; +import java.util.Properties; + +public class MavenWrapperDownloader { + + private static final String WRAPPER_VERSION = "0.5.6"; + /** + * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. + */ + private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" + + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; + + /** + * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to + * use instead of the default one. + */ + private static final String MAVEN_WRAPPER_PROPERTIES_PATH = + ".mvn/wrapper/maven-wrapper.properties"; + + /** + * Path where the maven-wrapper.jar will be saved to. + */ + private static final String MAVEN_WRAPPER_JAR_PATH = + ".mvn/wrapper/maven-wrapper.jar"; + + /** + * Name of the property which should be used to override the default download url for the wrapper. + */ + private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; + + public static void main(String args[]) { + System.out.println("- Downloader started"); + File baseDirectory = new File(args[0]); + System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); + + // If the maven-wrapper.properties exists, read it and check if it contains a custom + // wrapperUrl parameter. + File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); + String url = DEFAULT_DOWNLOAD_URL; + if(mavenWrapperPropertyFile.exists()) { + FileInputStream mavenWrapperPropertyFileInputStream = null; + try { + mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); + Properties mavenWrapperProperties = new Properties(); + mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); + url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); + } catch (IOException e) { + System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); + } finally { + try { + if(mavenWrapperPropertyFileInputStream != null) { + mavenWrapperPropertyFileInputStream.close(); + } + } catch (IOException e) { + // Ignore ... + } + } + } + System.out.println("- Downloading from: " + url); + + File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); + if(!outputFile.getParentFile().exists()) { + if(!outputFile.getParentFile().mkdirs()) { + System.out.println( + "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); + } + } + System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); + try { + downloadFileFromURL(url, outputFile); + System.out.println("Done"); + System.exit(0); + } catch (Throwable e) { + System.out.println("- Error downloading"); + e.printStackTrace(); + System.exit(1); + } + } + + private static void downloadFileFromURL(String urlString, File destination) throws Exception { + if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { + String username = System.getenv("MVNW_USERNAME"); + char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); + Authenticator.setDefault(new Authenticator() { + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(username, password); + } + }); + } + URL website = new URL(urlString); + ReadableByteChannel rbc; + rbc = Channels.newChannel(website.openStream()); + FileOutputStream fos = new FileOutputStream(destination); + fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + fos.close(); + rbc.close(); + } + +} diff --git a/executor1/.mvn/wrapper/maven-wrapper.jar b/executor1/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..2cc7d4a55c0cd0092912bf49ae38b3a9e3fd0054 GIT binary patch literal 50710 zcmbTd1CVCTmM+|7+wQV$+qP}n>auOywyU~q+qUhh+uxis_~*a##hm*_WW?9E7Pb7N%LRFiwbEGCJ0XP=%-6oeT$XZcYgtzC2~q zk(K08IQL8oTl}>>+hE5YRgXTB@fZ4TH9>7=79e`%%tw*SQUa9~$xKD5rS!;ZG@ocK zQdcH}JX?W|0_Afv?y`-NgLum62B&WSD$-w;O6G0Sm;SMX65z)l%m1e-g8Q$QTI;(Q z+x$xth4KFvH@Bs6(zn!iF#nenk^Y^ce;XIItAoCsow38eq?Y-Auh!1in#Rt-_D>H^ z=EjbclGGGa6VnaMGmMLj`x3NcwA43Jb(0gzl;RUIRAUDcR1~99l2SAPkVhoRMMtN} zXvC<tOmX83grD8GSo_Lo?%lNfhD#EBgPo z*nf@ppMC#B!T)Ae0RG$mlJWmGl7CkuU~B8-==5i;rS;8i6rJ=PoQxf446XDX9g|c> zU64ePyMlsI^V5Jq5A+BPe#e73+kpc_r1tv#B)~EZ;7^67F0*QiYfrk0uVW;Qb=NsG zN>gsuCwvb?s-KQIppEaeXtEMdc9dy6Dfduz-tMTms+i01{eD9JE&h?Kht*$eOl#&L zJdM_-vXs(V#$Ed;5wyNWJdPNh+Z$+;$|%qR(t`4W@kDhd*{(7-33BOS6L$UPDeE_53j${QfKN-0v-HG z(QfyvFNbwPK%^!eIo4ac1;b>c0vyf9}Xby@YY!lkz-UvNp zwj#Gg|4B~?n?G^{;(W;|{SNoJbHTMpQJ*Wq5b{l9c8(%?Kd^1?H1om1de0Da9M;Q=n zUfn{f87iVb^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1iixd-6GlO7Vp*yU zp{VU^3?s?90i=!#>H`lxT!q8rk>W_$2~kbpz7eV{3wR|8E=8**5?qn8#n`*(bt1xRQrdGxyx2y%B$qmw#>ZV$c7%cO#%JM1lY$Y0q?Yuo> ze9KdJoiM)RH*SB%^;TAdX-zEjA7@%y=!0=Zg%iWK7jVI9b&Dk}0$Af&08KHo+ zOwDhFvA(E|ER%a^cdh@^wLUlmIv6?_3=BvX8jKk92L=Y}7Jf5OGMfh` zBdR1wFCi-i5@`9km{isRb0O%TX+f~)KNaEz{rXQa89`YIF;EN&gN)cigu6mNh>?Cm zAO&Im2flv6D{jwm+y<%WsPe4!89n~KN|7}Cb{Z;XweER73r}Qp2 zz}WP4j}U0&(uD&9yGy6`!+_v-S(yG*iytsTR#x_Rc>=6u^vnRDnf1gP{#2>`ffrAC% zTZ5WQ@hAK;P;>kX{D)mIXe4%a5p=LO1xXH@8T?mz7Q@d)$3pL{{B!2{-v70L*o1AO+|n5beiw~ zk@(>m?T3{2k2c;NWc^`4@P&Z?BjxXJ@;x1qhn)9Mn*IFdt_J-dIqx5#d`NfyfX~m( zIS~5)MfZ2Uy?_4W`47i}u0ZgPh<{D|w_d#;D}Q&U$Q-G}xM1A@1f{#%A$jh6Qp&0hQ<0bPOM z-{1Wm&p%%#eb_?x7i;bol EfAhh=DF6Tf literal 0 HcmV?d00001 diff --git a/executor1/.mvn/wrapper/maven-wrapper.properties b/executor1/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..abd303b --- /dev/null +++ b/executor1/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,2 @@ +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.2/apache-maven-3.8.2-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar diff --git a/executor1/Dockerfile b/executor1/Dockerfile new file mode 100644 index 0000000..db90fb6 --- /dev/null +++ b/executor1/Dockerfile @@ -0,0 +1,18 @@ +FROM openjdk:11 AS development + +WORKDIR /opt/app + +# ENV SPRING_DATASOURCE_URL=jdbc:mysql://backend-db:3306/db + +COPY .mvn/ .mvn +COPY mvnw pom.xml mvnw.cmd ./ + +RUN apt-get clean && apt-get update && apt-get install dos2unix +RUN dos2unix mvnw + +RUN ./mvnw dependency:go-offline + +COPY src /opt/app/src +COPY *target /opt/app/target + +CMD ["./mvnw", "spring-boot:run", "-Dspring-boot.run.jvmArguments=\"-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005\"", "-Dspring.devtools.restart.enabled=true"] diff --git a/executor1/mvnw b/executor1/mvnw new file mode 100755 index 0000000..a16b543 --- /dev/null +++ b/executor1/mvnw @@ -0,0 +1,310 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/executor1/mvnw.cmd b/executor1/mvnw.cmd new file mode 100644 index 0000000..c8d4337 --- /dev/null +++ b/executor1/mvnw.cmd @@ -0,0 +1,182 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + +FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/executor1/pom.xml b/executor1/pom.xml new file mode 100644 index 0000000..8a5b9e3 --- /dev/null +++ b/executor1/pom.xml @@ -0,0 +1,67 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.5.5 + + + ch.unisg + executor1 + 0.0.1-SNAPSHOT + executor1 + Demo project for Spring Boot + + 11 + scs-asse-fs21-group1 + https://sonarcloud.io + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-devtools + runtime + true + + + org.projectlombok + lombok + true + + + org.springframework.boot + spring-boot-starter-test + test + + + ch.unisg + executorBase + 0.0.1-SNAPSHOT + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.projectlombok + lombok + + + + + + + + diff --git a/executor1/src/main/java/ch/unisg/executor1/Executor1Application.java b/executor1/src/main/java/ch/unisg/executor1/Executor1Application.java new file mode 100644 index 0000000..dfb8d8c --- /dev/null +++ b/executor1/src/main/java/ch/unisg/executor1/Executor1Application.java @@ -0,0 +1,16 @@ +package ch.unisg.executor1; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +import ch.unisg.executor1.executor.domain.Executor; + +@SpringBootApplication +public class Executor1Application { + + public static void main(String[] args) { + SpringApplication.run(Executor1Application.class, args); + Executor.getExecutor(); + } + +} diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/DeleteUserFromRobotAdapter.java b/executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/DeleteUserFromRobotAdapter.java new file mode 100644 index 0000000..94c2309 --- /dev/null +++ b/executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/DeleteUserFromRobotAdapter.java @@ -0,0 +1,42 @@ +package ch.unisg.executor1.executor.adapter.out; +import java.io.IOException; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; + +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Component; + +import ch.unisg.executor1.executor.application.port.out.DeleteUserFromRobotPort; + +@Component +@Primary +public class DeleteUserFromRobotAdapter implements DeleteUserFromRobotPort { + + @Override + public boolean deleteUserFromRobot(String key) { + + String url = "https://api.interactions.ics.unisg.ch/leubot1/v1.3.0/user/" + key; + + var request = HttpRequest.newBuilder() + .uri(URI.create(url)) + .header("Content-Type", "application/json") + .DELETE() + .build(); + + var client = HttpClient.newHttpClient(); + + try { + var response = client.send(request, HttpResponse.BodyHandlers.ofString()); + System.out.println(response.statusCode()); + return true; + } catch (IOException e) { + e.printStackTrace(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + return false; + } + +} diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/InstructionToRobotAdapter.java b/executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/InstructionToRobotAdapter.java new file mode 100644 index 0000000..f8b7012 --- /dev/null +++ b/executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/InstructionToRobotAdapter.java @@ -0,0 +1,46 @@ +package ch.unisg.executor1.executor.adapter.out; +import java.io.IOException; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; + +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Component; + +import ch.unisg.executor1.executor.application.port.out.InstructionToRobotPort; + +@Component +@Primary +public class InstructionToRobotAdapter implements InstructionToRobotPort { + + @Override + public boolean instructionToRobot(String key) { + + String putEndpoint = "https://api.interactions.ics.unisg.ch/leubot1/v1.3.0/elbow"; + + String inputJson = "{ \"value\": 400}"; + var request = HttpRequest.newBuilder() + .uri(URI.create(putEndpoint)) + .header("Content-Type", "application/json") + .header("X-API-KEY", key) + .PUT(HttpRequest.BodyPublishers.ofString(inputJson)) + .build(); + + var client = HttpClient.newHttpClient(); + + try { + var response = client.send(request, HttpResponse.BodyHandlers.ofString()); + System.out.println(response.statusCode()); + System.out.println(response.headers()); + return true; + } catch (IOException e) { + e.printStackTrace(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + return false; + + } + +} diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/UserToRobotAdapter.java b/executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/UserToRobotAdapter.java new file mode 100644 index 0000000..f874892 --- /dev/null +++ b/executor1/src/main/java/ch/unisg/executor1/executor/adapter/out/UserToRobotAdapter.java @@ -0,0 +1,46 @@ +package ch.unisg.executor1.executor.adapter.out; +import java.io.IOException; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; + +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Component; + +import ch.unisg.executor1.executor.application.port.out.UserToRobotPort; + +@Component +@Primary +public class UserToRobotAdapter implements UserToRobotPort { + + @Override + public String userToRobot() { + String postEndpoint = "https://api.interactions.ics.unisg.ch/leubot1/v1.3.0/user"; + + String inputJson = "{ \"name\":\"keanu rahimian\", \"email\":\"keanu.rahimian@student.unisg.ch\"}"; + var request = HttpRequest.newBuilder() + .uri(URI.create(postEndpoint)) + .header("Content-Type", "application/json") + .POST(HttpRequest.BodyPublishers.ofString(inputJson)) + .build(); + + var client = HttpClient.newHttpClient(); + + try { + var response = client.send(request, HttpResponse.BodyHandlers.ofString()); + System.out.println(response.statusCode()); + System.out.println(response.headers()); + String url = response.headers().map().get("location").toString(); + String key = url.split("/")[url.split("/").length-1].split("]")[0]; + return key; + } catch (IOException e) { + e.printStackTrace(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + return null; + + } + +} diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/DeleteUserFromRobotPort.java b/executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/DeleteUserFromRobotPort.java new file mode 100644 index 0000000..fc6f5d7 --- /dev/null +++ b/executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/DeleteUserFromRobotPort.java @@ -0,0 +1,5 @@ +package ch.unisg.executor1.executor.application.port.out; + +public interface DeleteUserFromRobotPort { + boolean deleteUserFromRobot(String key); +} diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/InstructionToRobotPort.java b/executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/InstructionToRobotPort.java new file mode 100644 index 0000000..bbf4034 --- /dev/null +++ b/executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/InstructionToRobotPort.java @@ -0,0 +1,5 @@ +package ch.unisg.executor1.executor.application.port.out; + +public interface InstructionToRobotPort { + boolean instructionToRobot(String key); +} diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/UserToRobotPort.java b/executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/UserToRobotPort.java new file mode 100644 index 0000000..5b011c1 --- /dev/null +++ b/executor1/src/main/java/ch/unisg/executor1/executor/application/port/out/UserToRobotPort.java @@ -0,0 +1,7 @@ +package ch.unisg.executor1.executor.application.port.out; + +import ch.unisg.executorBase.executor.domain.ExecutorType; + +public interface UserToRobotPort { + String userToRobot(); +} diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/application/service/TaskAvailableService.java b/executor1/src/main/java/ch/unisg/executor1/executor/application/service/TaskAvailableService.java new file mode 100644 index 0000000..d502053 --- /dev/null +++ b/executor1/src/main/java/ch/unisg/executor1/executor/application/service/TaskAvailableService.java @@ -0,0 +1,28 @@ +package ch.unisg.executor1.executor.application.service; + +import org.springframework.stereotype.Component; + +import ch.unisg.executor1.executor.domain.Executor; +import ch.unisg.executorBase.executor.application.port.in.TaskAvailableCommand; +import ch.unisg.executorBase.executor.application.port.in.TaskAvailableUseCase; +import ch.unisg.executorBase.executor.domain.ExecutorStatus; +import lombok.RequiredArgsConstructor; + +import javax.transaction.Transactional; + +@RequiredArgsConstructor +@Component +@Transactional +public class TaskAvailableService implements TaskAvailableUseCase { + + @Override + public void newTaskAvailable(TaskAvailableCommand command) { + + Executor executor = Executor.getExecutor(); + + if (executor.getExecutorType() == command.getTaskType() && + executor.getStatus() == ExecutorStatus.IDLING) { + executor.getAssignment(); + } + } +} diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/domain/Executor.java b/executor1/src/main/java/ch/unisg/executor1/executor/domain/Executor.java new file mode 100644 index 0000000..4a7734c --- /dev/null +++ b/executor1/src/main/java/ch/unisg/executor1/executor/domain/Executor.java @@ -0,0 +1,42 @@ +package ch.unisg.executor1.executor.domain; + +import java.net.http.HttpClient; +import java.net.http.HttpResponse; +import java.util.concurrent.TimeUnit; + +import ch.unisg.executor1.executor.adapter.out.DeleteUserFromRobotAdapter; +import ch.unisg.executor1.executor.adapter.out.InstructionToRobotAdapter; +import ch.unisg.executor1.executor.adapter.out.UserToRobotAdapter; +import ch.unisg.executor1.executor.application.port.out.DeleteUserFromRobotPort; +import ch.unisg.executor1.executor.application.port.out.InstructionToRobotPort; +import ch.unisg.executor1.executor.application.port.out.UserToRobotPort; +import ch.unisg.executorBase.executor.domain.ExecutorBase; +import ch.unisg.executorBase.executor.domain.ExecutorType; + +public class Executor extends ExecutorBase { + + private static final Executor executor = new Executor(ExecutorType.ROBOT); + private final UserToRobotPort userToRobotPort = new UserToRobotAdapter(); + private final InstructionToRobotPort instructionToRobotPort = new InstructionToRobotAdapter(); + private final DeleteUserFromRobotPort deleteUserFromRobotPort = new DeleteUserFromRobotAdapter(); + + public static Executor getExecutor() { + return executor; + } + + private Executor(ExecutorType executorType) { + super(executorType); + } + + @Override + protected + String execution() { + + String key = userToRobotPort.userToRobot(); + boolean result1 = instructionToRobotPort.instructionToRobot(key); + deleteUserFromRobotPort.deleteUserFromRobot(key); + + return Boolean.toString(result1); + } + +} \ No newline at end of file diff --git a/executor1/src/main/resources/application.properties b/executor1/src/main/resources/application.properties new file mode 100644 index 0000000..4d360de --- /dev/null +++ b/executor1/src/main/resources/application.properties @@ -0,0 +1 @@ +server.port=8081 diff --git a/executor1/src/test/java/ch/unisg/executor2/Executor2ApplicationTests.java b/executor1/src/test/java/ch/unisg/executor2/Executor2ApplicationTests.java new file mode 100644 index 0000000..5724a1c --- /dev/null +++ b/executor1/src/test/java/ch/unisg/executor2/Executor2ApplicationTests.java @@ -0,0 +1,13 @@ +package ch.unisg.executor2; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class Executor2ApplicationTests { + + @Test + void contextLoads() { + } + +} From 89a49ba786fb42ac8911936f81982febd24848d2 Mon Sep 17 00:00:00 2001 From: jj187 Date: Sat, 16 Oct 2021 20:54:54 +0200 Subject: [PATCH 08/17] Added latest changes --- .../tapastasks/tasks/adapter/in/web/DeleteTaskWebController.java | 1 + 1 file changed, 1 insertion(+) diff --git a/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/adapter/in/web/DeleteTaskWebController.java b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/adapter/in/web/DeleteTaskWebController.java index 6758337..af721d1 100644 --- a/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/adapter/in/web/DeleteTaskWebController.java +++ b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/adapter/in/web/DeleteTaskWebController.java @@ -32,6 +32,7 @@ public class DeleteTaskWebController { // Check if the task with the given identifier exists if (deleteATask.isEmpty()) { + // If not, through a 404 Not Found status code throw new ResponseStatusException(HttpStatus.NOT_FOUND); } From a61f1118794b8526ed1a93dec9f046b21c95844a Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 17 Oct 2021 00:31:48 +0200 Subject: [PATCH 09/17] assignment service + executor pool improvments --- assignment/pom.xml | 23 ++++ .../ch/unisg/assignment/TestController.java | 12 -- .../in/web/ApplyForTaskController.java | 36 ++++++ .../adapter/in/web/NewTaskController.java | 41 ++++++ .../in/web/TaskCompletedController.java | 34 +++++ .../out/web/PublishNewTaskEventAdapter.java | 40 ++++++ .../web/PublishTaskAssignedEventAdapter.java | 46 +++++++ .../web/PublishTaskCompletedEventAdapter.java | 49 +++++++ .../port/in/ApplyForTaskCommand.java | 29 +++++ .../port/in/ApplyForTaskUseCase.java | 7 + .../application/port/in/NewTaskCommand.java | 23 ++++ .../application/port/in/NewTaskUseCase.java | 5 + .../port/in/TaskCompletedCommand.java | 33 +++++ .../port/in/TaskCompletedUseCase.java | 5 + .../port/out/NewTaskEventPort.java | 7 + .../port/out/TaskAssignedEventPort.java | 7 + .../port/out/TaskCompletedEventPort.java | 7 + .../service/ApplyForTaskService.java | 34 +++++ .../application/service/NewTaskService.java | 46 +++++++ .../service/TaskCompletedService.java | 31 +++++ .../assignment/domain/ExecutorInfo.java | 18 +++ .../assignment/domain/NewTaskEvent.java | 9 ++ .../assignment/assignment/domain/Roster.java | 49 +++++++ .../assignment/domain/RosterItem.java | 27 ++++ .../assignment/assignment/domain/Task.java | 27 ++++ .../assignment/domain/TaskAssignedEvent.java | 9 ++ .../assignment/domain/TaskCompletedEvent.java | 15 +++ .../assignment/common/SelfValidating.java | 31 +++++ .../src/main/resources/application.properties | 2 +- docker-compose.yaml | 120 +++++++++--------- executor-base/pom.xml | 6 + .../executorBase/common/SelfValidating.java | 1 + .../in/web/TaskAvailableController.java | 2 +- .../web/ExecutionFinishedEventAdapter.java | 38 +++--- .../adapter/out/web/GetAssignmentAdapter.java | 39 ++++-- .../port/in/TaskAvailableCommand.java | 2 +- .../port/out/GetAssignmentPort.java | 2 +- .../executor/domain/ExecutorBase.java | 24 +--- .../executorBase/executor/domain/Task.java | 3 +- .../in/web/TaskAvailableController.java | 36 ++++++ .../service/TaskAvailableService.java | 2 +- .../executor2/executor/domain/Executor.java | 4 +- .../src/main/resources/application.properties | 2 +- 43 files changed, 849 insertions(+), 134 deletions(-) delete mode 100644 assignment/src/main/java/ch/unisg/assignment/TestController.java create mode 100644 assignment/src/main/java/ch/unisg/assignment/assignment/adapter/in/web/ApplyForTaskController.java create mode 100644 assignment/src/main/java/ch/unisg/assignment/assignment/adapter/in/web/NewTaskController.java create mode 100644 assignment/src/main/java/ch/unisg/assignment/assignment/adapter/in/web/TaskCompletedController.java create mode 100644 assignment/src/main/java/ch/unisg/assignment/assignment/adapter/out/web/PublishNewTaskEventAdapter.java create mode 100644 assignment/src/main/java/ch/unisg/assignment/assignment/adapter/out/web/PublishTaskAssignedEventAdapter.java create mode 100644 assignment/src/main/java/ch/unisg/assignment/assignment/adapter/out/web/PublishTaskCompletedEventAdapter.java create mode 100644 assignment/src/main/java/ch/unisg/assignment/assignment/application/port/in/ApplyForTaskCommand.java create mode 100644 assignment/src/main/java/ch/unisg/assignment/assignment/application/port/in/ApplyForTaskUseCase.java create mode 100644 assignment/src/main/java/ch/unisg/assignment/assignment/application/port/in/NewTaskCommand.java create mode 100644 assignment/src/main/java/ch/unisg/assignment/assignment/application/port/in/NewTaskUseCase.java create mode 100644 assignment/src/main/java/ch/unisg/assignment/assignment/application/port/in/TaskCompletedCommand.java create mode 100644 assignment/src/main/java/ch/unisg/assignment/assignment/application/port/in/TaskCompletedUseCase.java create mode 100644 assignment/src/main/java/ch/unisg/assignment/assignment/application/port/out/NewTaskEventPort.java create mode 100644 assignment/src/main/java/ch/unisg/assignment/assignment/application/port/out/TaskAssignedEventPort.java create mode 100644 assignment/src/main/java/ch/unisg/assignment/assignment/application/port/out/TaskCompletedEventPort.java create mode 100644 assignment/src/main/java/ch/unisg/assignment/assignment/application/service/ApplyForTaskService.java create mode 100644 assignment/src/main/java/ch/unisg/assignment/assignment/application/service/NewTaskService.java create mode 100644 assignment/src/main/java/ch/unisg/assignment/assignment/application/service/TaskCompletedService.java create mode 100644 assignment/src/main/java/ch/unisg/assignment/assignment/domain/ExecutorInfo.java create mode 100644 assignment/src/main/java/ch/unisg/assignment/assignment/domain/NewTaskEvent.java create mode 100644 assignment/src/main/java/ch/unisg/assignment/assignment/domain/Roster.java create mode 100644 assignment/src/main/java/ch/unisg/assignment/assignment/domain/RosterItem.java create mode 100644 assignment/src/main/java/ch/unisg/assignment/assignment/domain/Task.java create mode 100644 assignment/src/main/java/ch/unisg/assignment/assignment/domain/TaskAssignedEvent.java create mode 100644 assignment/src/main/java/ch/unisg/assignment/assignment/domain/TaskCompletedEvent.java create mode 100644 assignment/src/main/java/ch/unisg/assignment/common/SelfValidating.java create mode 100644 executor2/src/main/java/ch/unisg/executor2/executor/adapter/in/web/TaskAvailableController.java diff --git a/assignment/pom.xml b/assignment/pom.xml index 43af6c3..99996b8 100644 --- a/assignment/pom.xml +++ b/assignment/pom.xml @@ -30,6 +30,11 @@ runtime true + + + org.springframework.boot + spring-boot-starter-validation + org.projectlombok lombok @@ -40,6 +45,24 @@ spring-boot-starter-test test + + javax.validation + validation-api + 1.1.0.Final + + + javax.transaction + javax.transaction-api + 1.2 + + + + org.json + json + 20210307 + + + diff --git a/assignment/src/main/java/ch/unisg/assignment/TestController.java b/assignment/src/main/java/ch/unisg/assignment/TestController.java deleted file mode 100644 index ac8e4f9..0000000 --- a/assignment/src/main/java/ch/unisg/assignment/TestController.java +++ /dev/null @@ -1,12 +0,0 @@ -package ch.unisg.assignment; - -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class TestController { - @RequestMapping("/") - public String index() { - return "Hello World! Assignment"; - } -} diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/in/web/ApplyForTaskController.java b/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/in/web/ApplyForTaskController.java new file mode 100644 index 0000000..e83e74d --- /dev/null +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/in/web/ApplyForTaskController.java @@ -0,0 +1,36 @@ +package ch.unisg.assignment.assignment.adapter.in.web; + +import javax.validation.ConstraintViolationException; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.server.ResponseStatusException; + +import ch.unisg.assignment.assignment.application.port.in.ApplyForTaskCommand; +import ch.unisg.assignment.assignment.application.port.in.ApplyForTaskUseCase; +import ch.unisg.assignment.assignment.domain.ExecutorInfo; +import ch.unisg.assignment.assignment.domain.Task; + +@RestController +public class ApplyForTaskController { + private final ApplyForTaskUseCase applyForTaskUseCase; + + public ApplyForTaskController(ApplyForTaskUseCase applyForTaskUseCase) { + this.applyForTaskUseCase = applyForTaskUseCase; + } + + @PostMapping(path = "/task/apply", consumes = {"application/json"}) + public Task applyForTask(@RequestBody ExecutorInfo executorInfo) { + try { + ApplyForTaskCommand command = new ApplyForTaskCommand(executorInfo.getExecutorType(), + executorInfo.getIp(), executorInfo.getPort()); + + return applyForTaskUseCase.applyForTask(command); + + } catch (ConstraintViolationException e) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, e.getMessage()); + } + } +} diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/in/web/NewTaskController.java b/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/in/web/NewTaskController.java new file mode 100644 index 0000000..d95fdd5 --- /dev/null +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/in/web/NewTaskController.java @@ -0,0 +1,41 @@ +package ch.unisg.assignment.assignment.adapter.in.web; + +import javax.validation.ConstraintViolationException; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.server.ResponseStatusException; + +import ch.unisg.assignment.assignment.application.port.in.NewTaskCommand; +import ch.unisg.assignment.assignment.application.port.in.NewTaskUseCase; +import ch.unisg.assignment.assignment.domain.Task; + +@RestController +public class NewTaskController { + private final NewTaskUseCase newTaskUseCase; + + public NewTaskController(NewTaskUseCase newTaskUseCase) { + this.newTaskUseCase = newTaskUseCase; + } + + @PostMapping(path = "/task", consumes = {"application/json"}) + public ResponseEntity addNewTaskTaskToTaskList(@RequestBody Task task) { + try { + NewTaskCommand command = new NewTaskCommand( + task.getTaskID(), task.getTaskType() + ); + + boolean success = newTaskUseCase.addNewTaskToQueue(command); + + if (success) { + return new ResponseEntity<>(HttpStatus.CREATED); + } + return new ResponseEntity<>(HttpStatus.CONFLICT); + } catch (ConstraintViolationException e) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, e.getMessage()); + } + } +} diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/in/web/TaskCompletedController.java b/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/in/web/TaskCompletedController.java new file mode 100644 index 0000000..e8335ed --- /dev/null +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/in/web/TaskCompletedController.java @@ -0,0 +1,34 @@ +package ch.unisg.assignment.assignment.adapter.in.web; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +import ch.unisg.assignment.assignment.application.port.in.TaskCompletedCommand; +import ch.unisg.assignment.assignment.application.port.in.TaskCompletedUseCase; +import ch.unisg.assignment.assignment.domain.Task; + +@RestController +public class TaskCompletedController { + + private final TaskCompletedUseCase taskCompletedUseCase; + + public TaskCompletedController(TaskCompletedUseCase taskCompletedUseCase) { + this.taskCompletedUseCase = taskCompletedUseCase; + } + + @PostMapping(path = "/task/completed", consumes = {"application/json"}) + public ResponseEntity addNewTaskTaskToTaskList(@RequestBody Task task) { + + TaskCompletedCommand command = new TaskCompletedCommand(task.getTaskID(), task.getTaskType(), + task.getStatus(), task.getResult()); + + taskCompletedUseCase.taskCompleted(command); + + return new ResponseEntity<>(HttpStatus.OK); + + } + +} diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/out/web/PublishNewTaskEventAdapter.java b/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/out/web/PublishNewTaskEventAdapter.java new file mode 100644 index 0000000..c08651b --- /dev/null +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/out/web/PublishNewTaskEventAdapter.java @@ -0,0 +1,40 @@ +package ch.unisg.assignment.assignment.adapter.out.web; + +import java.io.IOException; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; + +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Component; + +import ch.unisg.assignment.assignment.application.port.out.NewTaskEventPort; +import ch.unisg.assignment.assignment.domain.NewTaskEvent; + +@Component +@Primary +public class PublishNewTaskEventAdapter implements NewTaskEventPort { + + String server = "http://127.0.0.1:8085"; + + @Override + public void publishNewTaskEvent(NewTaskEvent event) { + + HttpClient client = HttpClient.newHttpClient(); + HttpRequest request = HttpRequest.newBuilder() + .uri(URI.create(server + "/newtask/" + event.taskType)) + .GET() + .build(); + + + try { + client.send(request, HttpResponse.BodyHandlers.ofString()); + } catch (IOException | InterruptedException e) { + e.printStackTrace(); + // Restore interrupted state... + Thread.currentThread().interrupt(); + } + } + +} diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/out/web/PublishTaskAssignedEventAdapter.java b/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/out/web/PublishTaskAssignedEventAdapter.java new file mode 100644 index 0000000..7f38d60 --- /dev/null +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/out/web/PublishTaskAssignedEventAdapter.java @@ -0,0 +1,46 @@ +package ch.unisg.assignment.assignment.adapter.out.web; + +import java.io.IOException; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; + +import org.json.JSONObject; +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Component; + +import ch.unisg.assignment.assignment.application.port.out.TaskAssignedEventPort; +import ch.unisg.assignment.assignment.domain.TaskAssignedEvent; + +@Component +@Primary +public class PublishTaskAssignedEventAdapter implements TaskAssignedEventPort { + + String server = "http://127.0.0.1:8085"; + + @Override + public void publishTaskAssignedEvent(TaskAssignedEvent event) { + + String body = new JSONObject() + .put("taskId", event.taskID) + .toString(); + + HttpClient client = HttpClient.newHttpClient(); + HttpRequest request = HttpRequest.newBuilder() + .uri(URI.create(server + "/tasks/completeTask")) + .header("Content-Type", "application/json") + .POST(HttpRequest.BodyPublishers.ofString(body)) + .build(); + + + try { + client.send(request, HttpResponse.BodyHandlers.ofString()); + } catch (IOException | InterruptedException e) { + e.printStackTrace(); + // Restore interrupted state... + Thread.currentThread().interrupt(); + } + } + +} diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/out/web/PublishTaskCompletedEventAdapter.java b/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/out/web/PublishTaskCompletedEventAdapter.java new file mode 100644 index 0000000..d63d710 --- /dev/null +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/out/web/PublishTaskCompletedEventAdapter.java @@ -0,0 +1,49 @@ +package ch.unisg.assignment.assignment.adapter.out.web; + +import java.io.IOException; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; + +import org.json.JSONObject; +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Component; + +import ch.unisg.assignment.assignment.application.port.out.TaskCompletedEventPort; +import ch.unisg.assignment.assignment.domain.TaskCompletedEvent; + +@Component +@Primary +public class PublishTaskCompletedEventAdapter implements TaskCompletedEventPort { + + String server = "http://127.0.0.1:8081"; + + @Override + public void publishTaskCompleted(TaskCompletedEvent event) { + + String body = new JSONObject() + .put("taskId", event.taskID) + .put("status", event.status) + .put("taskResult", event.result) + .toString(); + + HttpClient client = HttpClient.newHttpClient(); + HttpRequest request = HttpRequest.newBuilder() + .uri(URI.create(server + "/tasks/completeTask")) + .header("Content-Type", "application/json") + .POST(HttpRequest.BodyPublishers.ofString(body)) + .build(); + + + try { + client.send(request, HttpResponse.BodyHandlers.ofString()); + } catch (IOException | InterruptedException e) { + e.printStackTrace(); + // Restore interrupted state... + Thread.currentThread().interrupt(); + } + + } + +} diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/in/ApplyForTaskCommand.java b/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/in/ApplyForTaskCommand.java new file mode 100644 index 0000000..76d0e41 --- /dev/null +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/in/ApplyForTaskCommand.java @@ -0,0 +1,29 @@ +package ch.unisg.assignment.assignment.application.port.in; + +import javax.validation.constraints.NotNull; + +import ch.unisg.assignment.common.SelfValidating; +import lombok.EqualsAndHashCode; +import lombok.Value; + +@Value +@EqualsAndHashCode(callSuper=false) +public class ApplyForTaskCommand extends SelfValidating{ + + @NotNull + private final String taskType; + + @NotNull + private final String executorIP; + + + @NotNull + private final int executorPort; + + public ApplyForTaskCommand(String taskType, String executorIP, int executorPort) { + this.taskType = taskType; + this.executorIP = executorIP; + this.executorPort = executorPort; + this.validateSelf(); + } +} diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/in/ApplyForTaskUseCase.java b/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/in/ApplyForTaskUseCase.java new file mode 100644 index 0000000..1e7180a --- /dev/null +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/in/ApplyForTaskUseCase.java @@ -0,0 +1,7 @@ +package ch.unisg.assignment.assignment.application.port.in; + +import ch.unisg.assignment.assignment.domain.Task; + +public interface ApplyForTaskUseCase { + Task applyForTask(ApplyForTaskCommand applyForTaskCommand); +} diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/in/NewTaskCommand.java b/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/in/NewTaskCommand.java new file mode 100644 index 0000000..98f4579 --- /dev/null +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/in/NewTaskCommand.java @@ -0,0 +1,23 @@ +package ch.unisg.assignment.assignment.application.port.in; + +import javax.validation.constraints.NotNull; + +import ch.unisg.assignment.common.SelfValidating; + +import lombok.Value; + +@Value +public class NewTaskCommand extends SelfValidating { + + @NotNull + private final String taskID; + + @NotNull + private final String taskType; + + public NewTaskCommand(String taskID, String taskType) { + this.taskID = taskID; + this.taskType = taskType; + this.validateSelf(); + } +} diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/in/NewTaskUseCase.java b/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/in/NewTaskUseCase.java new file mode 100644 index 0000000..21f084e --- /dev/null +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/in/NewTaskUseCase.java @@ -0,0 +1,5 @@ +package ch.unisg.assignment.assignment.application.port.in; + +public interface NewTaskUseCase { + boolean addNewTaskToQueue(NewTaskCommand newTaskCommand); +} diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/in/TaskCompletedCommand.java b/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/in/TaskCompletedCommand.java new file mode 100644 index 0000000..474456d --- /dev/null +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/in/TaskCompletedCommand.java @@ -0,0 +1,33 @@ +package ch.unisg.assignment.assignment.application.port.in; + +import javax.validation.constraints.NotNull; + +import ch.unisg.assignment.common.SelfValidating; +import lombok.EqualsAndHashCode; +import lombok.Value; + +@Value +@EqualsAndHashCode(callSuper=false) +public class TaskCompletedCommand extends SelfValidating{ + + @NotNull + private final String taskID; + + @NotNull + private final String taskType; + + @NotNull + private final String taskStatus; + + @NotNull + private final String taskResult; + + public TaskCompletedCommand(String taskID, String taskType, String taskStatus, String taskResult) { + this.taskID = taskID; + this.taskType = taskType; + this.taskStatus = taskStatus; + this.taskResult = taskResult; + this.validateSelf(); + } + +} diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/in/TaskCompletedUseCase.java b/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/in/TaskCompletedUseCase.java new file mode 100644 index 0000000..1902952 --- /dev/null +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/in/TaskCompletedUseCase.java @@ -0,0 +1,5 @@ +package ch.unisg.assignment.assignment.application.port.in; + +public interface TaskCompletedUseCase { + void taskCompleted(TaskCompletedCommand taskCompletedCommand); +} diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/out/NewTaskEventPort.java b/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/out/NewTaskEventPort.java new file mode 100644 index 0000000..521af1a --- /dev/null +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/out/NewTaskEventPort.java @@ -0,0 +1,7 @@ +package ch.unisg.assignment.assignment.application.port.out; + +import ch.unisg.assignment.assignment.domain.NewTaskEvent; + +public interface NewTaskEventPort { + void publishNewTaskEvent(NewTaskEvent event); +} diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/out/TaskAssignedEventPort.java b/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/out/TaskAssignedEventPort.java new file mode 100644 index 0000000..0cd1cae --- /dev/null +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/out/TaskAssignedEventPort.java @@ -0,0 +1,7 @@ +package ch.unisg.assignment.assignment.application.port.out; + +import ch.unisg.assignment.assignment.domain.TaskAssignedEvent; + +public interface TaskAssignedEventPort { + void publishTaskAssignedEvent(TaskAssignedEvent taskAssignedEvent); +} diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/out/TaskCompletedEventPort.java b/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/out/TaskCompletedEventPort.java new file mode 100644 index 0000000..37b4ff3 --- /dev/null +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/out/TaskCompletedEventPort.java @@ -0,0 +1,7 @@ +package ch.unisg.assignment.assignment.application.port.out; + +import ch.unisg.assignment.assignment.domain.TaskCompletedEvent; + +public interface TaskCompletedEventPort { + void publishTaskCompleted(TaskCompletedEvent event); +} diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/application/service/ApplyForTaskService.java b/assignment/src/main/java/ch/unisg/assignment/assignment/application/service/ApplyForTaskService.java new file mode 100644 index 0000000..dac9a70 --- /dev/null +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/application/service/ApplyForTaskService.java @@ -0,0 +1,34 @@ +package ch.unisg.assignment.assignment.application.service; + +import javax.transaction.Transactional; + +import org.springframework.stereotype.Component; + +import ch.unisg.assignment.assignment.application.port.in.ApplyForTaskCommand; +import ch.unisg.assignment.assignment.application.port.in.ApplyForTaskUseCase; +import ch.unisg.assignment.assignment.application.port.out.TaskAssignedEventPort; +import ch.unisg.assignment.assignment.domain.Roster; +import ch.unisg.assignment.assignment.domain.Task; +import ch.unisg.assignment.assignment.domain.TaskAssignedEvent; +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +@Component +@Transactional +public class ApplyForTaskService implements ApplyForTaskUseCase { + + private final TaskAssignedEventPort taskAssignedEventPort; + + @Override + public Task applyForTask(ApplyForTaskCommand command) { + Task task = Roster.getInstance().assignTaskToExecutor(command.getTaskType(), + command.getExecutorIP(), command.getExecutorPort()); + + if (task != null) { + taskAssignedEventPort.publishTaskAssignedEvent(new TaskAssignedEvent(task.getTaskID())); + } + + return task; + } + +} diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/application/service/NewTaskService.java b/assignment/src/main/java/ch/unisg/assignment/assignment/application/service/NewTaskService.java new file mode 100644 index 0000000..b662cd2 --- /dev/null +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/application/service/NewTaskService.java @@ -0,0 +1,46 @@ +package ch.unisg.assignment.assignment.application.service; + +import java.util.Arrays; +import java.util.List; + +import javax.transaction.Transactional; + +import org.springframework.stereotype.Component; + +import ch.unisg.assignment.assignment.application.port.in.NewTaskCommand; +import ch.unisg.assignment.assignment.application.port.in.NewTaskUseCase; +import ch.unisg.assignment.assignment.application.port.out.NewTaskEventPort; +import ch.unisg.assignment.assignment.domain.NewTaskEvent; +import ch.unisg.assignment.assignment.domain.Roster; +import ch.unisg.assignment.assignment.domain.Task; +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +@Component +@Transactional +public class NewTaskService implements NewTaskUseCase { + + private final NewTaskEventPort newTaskEventPort; + + @Override + public boolean addNewTaskToQueue(NewTaskCommand command) { + + // TODO Get availableTaskTypes from executor pool + List availableTaskTypes = Arrays.asList("addition", "robot"); + + if (!availableTaskTypes.contains(command.getTaskType())) { + return false; + } + + Task task = new Task(command.getTaskID(), command.getTaskType()); + + Roster.getInstance().addTaskToQueue(task); + + // TODO this event should be in the roster function xyz + NewTaskEvent newTaskEvent = new NewTaskEvent(task.getTaskType()); + newTaskEventPort.publishNewTaskEvent(newTaskEvent); + + return true; + } + +} diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/application/service/TaskCompletedService.java b/assignment/src/main/java/ch/unisg/assignment/assignment/application/service/TaskCompletedService.java new file mode 100644 index 0000000..1295336 --- /dev/null +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/application/service/TaskCompletedService.java @@ -0,0 +1,31 @@ +package ch.unisg.assignment.assignment.application.service; + +import javax.transaction.Transactional; + +import org.springframework.stereotype.Component; + +import ch.unisg.assignment.assignment.application.port.in.TaskCompletedCommand; +import ch.unisg.assignment.assignment.application.port.in.TaskCompletedUseCase; +import ch.unisg.assignment.assignment.application.port.out.TaskCompletedEventPort; +import ch.unisg.assignment.assignment.domain.Roster; +import ch.unisg.assignment.assignment.domain.TaskCompletedEvent; +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +@Component +@Transactional +public class TaskCompletedService implements TaskCompletedUseCase { + + private final TaskCompletedEventPort taskCompletedEventPort; + + @Override + public void taskCompleted(TaskCompletedCommand command) { + + Roster.getInstance().taskCompleted(command.getTaskID()); + + taskCompletedEventPort.publishTaskCompleted(new TaskCompletedEvent(command.getTaskID(), + command.getTaskStatus(), command.getTaskResult())); + + } + +} diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/domain/ExecutorInfo.java b/assignment/src/main/java/ch/unisg/assignment/assignment/domain/ExecutorInfo.java new file mode 100644 index 0000000..3b7432c --- /dev/null +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/domain/ExecutorInfo.java @@ -0,0 +1,18 @@ +package ch.unisg.assignment.assignment.domain; + +import lombok.Getter; +import lombok.Setter; + +public class ExecutorInfo { + @Getter + @Setter + private String ip; + + @Getter + @Setter + private int port; + + @Getter + @Setter + private String executorType; +} diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/domain/NewTaskEvent.java b/assignment/src/main/java/ch/unisg/assignment/assignment/domain/NewTaskEvent.java new file mode 100644 index 0000000..57084ee --- /dev/null +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/domain/NewTaskEvent.java @@ -0,0 +1,9 @@ +package ch.unisg.assignment.assignment.domain; + +public class NewTaskEvent { + public String taskType; + + public NewTaskEvent(String taskType) { + this.taskType = taskType; + } +} diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/domain/Roster.java b/assignment/src/main/java/ch/unisg/assignment/assignment/domain/Roster.java new file mode 100644 index 0000000..054c094 --- /dev/null +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/domain/Roster.java @@ -0,0 +1,49 @@ +package ch.unisg.assignment.assignment.domain; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; + +public class Roster { + + private static final Roster roster = new Roster(); + + private HashMap> queues = new HashMap<>(); + + private HashMap rosterMap = new HashMap<>(); + + public static Roster getInstance() { + return roster; + } + + private Roster() {} + + public void addTaskToQueue(Task task) { + if (queues.containsKey(task.getTaskType().toUpperCase())) { + queues.get(task.getTaskType().toUpperCase()).add(task); + } else { + queues.put(task.getTaskType().toUpperCase(), new ArrayList<>(Arrays.asList(task))); + } + } + + public Task assignTaskToExecutor(String taskType, String executorIP, int executorPort) { + if (!queues.containsKey(taskType.toUpperCase())) { + return null; + } + if (queues.get(taskType.toUpperCase()).isEmpty()) { + return null; + } + + Task task = queues.get(taskType.toUpperCase()).remove(0); + + rosterMap.put(task.getTaskID(), new RosterItem(task.getTaskID(), task.getTaskType(), + executorIP, executorPort)); + + return task; + } + + public void taskCompleted(String taskID) { + rosterMap.remove(taskID); + } + +} diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/domain/RosterItem.java b/assignment/src/main/java/ch/unisg/assignment/assignment/domain/RosterItem.java new file mode 100644 index 0000000..6e050d4 --- /dev/null +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/domain/RosterItem.java @@ -0,0 +1,27 @@ +package ch.unisg.assignment.assignment.domain; + +import lombok.Getter; + +public class RosterItem { + + @Getter + private String taskID; + + @Getter + private String taskType; + + @Getter + private String executorIP; + + @Getter + private int executorPort; + + + public RosterItem(String taskID, String taskType, String executorIP, int executorPort) { + this.taskID = taskID; + this.taskType = taskType; + this.executorIP = executorIP; + this.executorPort = executorPort; + } + +} diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/domain/Task.java b/assignment/src/main/java/ch/unisg/assignment/assignment/domain/Task.java new file mode 100644 index 0000000..6db5111 --- /dev/null +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/domain/Task.java @@ -0,0 +1,27 @@ +package ch.unisg.assignment.assignment.domain; + +import lombok.Getter; +import lombok.Setter; + +public class Task { + + @Getter + private String taskID; + + @Getter + private String taskType; + + @Getter + @Setter + private String result; + + @Getter + @Setter + private String status; + + public Task(String taskID, String taskType) { + this.taskID = taskID; + this.taskType = taskType; + } + +} diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/domain/TaskAssignedEvent.java b/assignment/src/main/java/ch/unisg/assignment/assignment/domain/TaskAssignedEvent.java new file mode 100644 index 0000000..8acd144 --- /dev/null +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/domain/TaskAssignedEvent.java @@ -0,0 +1,9 @@ +package ch.unisg.assignment.assignment.domain; + +public class TaskAssignedEvent { + public String taskID; + + public TaskAssignedEvent(String taskID) { + this.taskID = taskID; + } +} diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/domain/TaskCompletedEvent.java b/assignment/src/main/java/ch/unisg/assignment/assignment/domain/TaskCompletedEvent.java new file mode 100644 index 0000000..89f26ae --- /dev/null +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/domain/TaskCompletedEvent.java @@ -0,0 +1,15 @@ +package ch.unisg.assignment.assignment.domain; + +public class TaskCompletedEvent { + public String taskID; + + public String status; + + public String result; + + public TaskCompletedEvent(String taskID, String status, String result) { + this.taskID = taskID; + this.status = status; + this.result = result; + } +} diff --git a/assignment/src/main/java/ch/unisg/assignment/common/SelfValidating.java b/assignment/src/main/java/ch/unisg/assignment/common/SelfValidating.java new file mode 100644 index 0000000..a8d366f --- /dev/null +++ b/assignment/src/main/java/ch/unisg/assignment/common/SelfValidating.java @@ -0,0 +1,31 @@ +package ch.unisg.assignment.common; + +import javax.validation.ConstraintViolation; +import javax.validation.ConstraintViolationException; +import javax.validation.Validation; +import javax.validation.Validator; +import javax.validation.ValidatorFactory; +import java.util.Set; + +public abstract class SelfValidating { + + private Validator validator; + + protected SelfValidating() { + ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); + validator = factory.getValidator(); + } + + /** + * Evaluates all Bean Validations on the attributes of this + * instance. + */ + protected void validateSelf() { + @SuppressWarnings("unchecked") + Set> violations = validator.validate((T) this); + if (!violations.isEmpty()) { + throw new ConstraintViolationException(violations); + } + } +} + diff --git a/assignment/src/main/resources/application.properties b/assignment/src/main/resources/application.properties index 4d360de..3cf12af 100644 --- a/assignment/src/main/resources/application.properties +++ b/assignment/src/main/resources/application.properties @@ -1 +1 @@ -server.port=8081 +server.port=8082 diff --git a/docker-compose.yaml b/docker-compose.yaml index 76b8af1..8c4bfcf 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,62 +1,62 @@ version: "3.6" services: - tapas-tasks: - container_name: tapas-tasks - build: - context: "./tapas-tasks" - dockerfile: "Dockerfile" - target: development - ports: - - "8081:8081" - - "5005:5005" - volumes: - - ./tapas-tasks/src:/opt/app/src - - ./tapas-tasks/target:/opt/app/target - assignment: - container_name: assignment - build: - context: "./assignment" - dockerfile: "Dockerfile" - target: development - ports: - - "8082:8081" - - "5006:5005" - volumes: - - ./assignment/src:/opt/app/src - - ./assignment/target:/opt/app/target - executor-pool: - container_name: executor-pool - build: - context: "./executor-pool" - dockerfile: "Dockerfile" - target: development - ports: - - "8083:8081" - - "5007:5005" - volumes: - - ./executor-pool/src:/opt/app/src - - ./executor-pool/target:/opt/app/target - executor1: - container_name: executor1 - build: - context: "./executor1" - dockerfile: "Dockerfile" - target: development - ports: - - "8084:8081" - - "5008:5005" - volumes: - - ./executor1/src:/opt/app/src - - ./executor1/target:/opt/app/target - executor2: - container_name: executor2 - build: - context: "./executor2" - dockerfile: "Dockerfile" - target: development - ports: - - "8085:8081" - - "5009:5005" - volumes: - - ./executor2/src:/opt/app/src - - ./executor2/target:/opt/app/target + tapas-tasks: + container_name: tapas-tasks + build: + context: "./tapas-tasks" + dockerfile: "Dockerfile" + target: development + ports: + - "8081:8081" + - "5005:5005" + volumes: + - ./tapas-tasks/src:/opt/app/src + - ./tapas-tasks/target:/opt/app/target + assignment: + container_name: assignment + build: + context: "./assignment" + dockerfile: "Dockerfile" + target: development + ports: + - "8082:8082" + - "5006:5005" + volumes: + - ./assignment/src:/opt/app/src + - ./assignment/target:/opt/app/target + executor-pool: + container_name: executor-pool + build: + context: "./executor-pool" + dockerfile: "Dockerfile" + target: development + ports: + - "8083:8081" + - "5007:5005" + volumes: + - ./executor-pool/src:/opt/app/src + - ./executor-pool/target:/opt/app/target + executor1: + container_name: executor1 + build: + context: "./executor1" + dockerfile: "Dockerfile" + target: development + ports: + - "8084:8081" + - "5008:5005" + volumes: + - ./executor1/src:/opt/app/src + - ./executor1/target:/opt/app/target + executor2: + container_name: executor2 + build: + context: "./executor2" + dockerfile: "Dockerfile" + target: development + ports: + - "8085:8085" + - "5009:5005" + volumes: + - ./executor2/src:/opt/app/src + - ./executor2/target:/opt/app/target diff --git a/executor-base/pom.xml b/executor-base/pom.xml index 6ad675a..32ec88a 100644 --- a/executor-base/pom.xml +++ b/executor-base/pom.xml @@ -56,6 +56,12 @@ javax.transaction-api 1.2 + + + org.json + json + 20210307 + diff --git a/executor-base/src/main/java/ch/unisg/executorBase/common/SelfValidating.java b/executor-base/src/main/java/ch/unisg/executorBase/common/SelfValidating.java index 1d4a80a..5119ac5 100644 --- a/executor-base/src/main/java/ch/unisg/executorBase/common/SelfValidating.java +++ b/executor-base/src/main/java/ch/unisg/executorBase/common/SelfValidating.java @@ -21,6 +21,7 @@ public class SelfValidating { * instance. */ protected void validateSelf() { + @SuppressWarnings("unchecked") Set> violations = validator.validate((T) this); if (!violations.isEmpty()) { throw new ConstraintViolationException(violations); diff --git a/executor-base/src/main/java/ch/unisg/executorBase/executor/adapter/in/web/TaskAvailableController.java b/executor-base/src/main/java/ch/unisg/executorBase/executor/adapter/in/web/TaskAvailableController.java index 75d3a02..182f2ba 100644 --- a/executor-base/src/main/java/ch/unisg/executorBase/executor/adapter/in/web/TaskAvailableController.java +++ b/executor-base/src/main/java/ch/unisg/executorBase/executor/adapter/in/web/TaskAvailableController.java @@ -21,7 +21,7 @@ public class TaskAvailableController { @GetMapping(path = "/newtask/{taskType}") public ResponseEntity retrieveTaskFromTaskList(@PathVariable("taskType") String taskType) { - + if (ExecutorType.contains(taskType.toUpperCase())) { TaskAvailableCommand command = new TaskAvailableCommand( ExecutorType.valueOf(taskType.toUpperCase())); diff --git a/executor-base/src/main/java/ch/unisg/executorBase/executor/adapter/out/web/ExecutionFinishedEventAdapter.java b/executor-base/src/main/java/ch/unisg/executorBase/executor/adapter/out/web/ExecutionFinishedEventAdapter.java index 2f53a2b..e688868 100644 --- a/executor-base/src/main/java/ch/unisg/executorBase/executor/adapter/out/web/ExecutionFinishedEventAdapter.java +++ b/executor-base/src/main/java/ch/unisg/executorBase/executor/adapter/out/web/ExecutionFinishedEventAdapter.java @@ -8,6 +8,9 @@ import java.net.http.HttpResponse; import java.util.HashMap; import com.fasterxml.jackson.databind.ObjectMapper; + +import org.json.JSONObject; + import com.fasterxml.jackson.core.JsonProcessingException; import ch.unisg.executorBase.executor.application.port.out.ExecutionFinishedEventPort; @@ -20,39 +23,30 @@ public class ExecutionFinishedEventAdapter implements ExecutionFinishedEventPort @Override public void publishExecutionFinishedEvent(ExecutionFinishedEvent event) { - ///Here we would need to work with DTOs in case the payload of calls becomes more complex - var values = new HashMap() {{ - put("result",event.getResult()); - put("status",event.getStatus()); - }}; - - var objectMapper = new ObjectMapper(); - String requestBody = null; - try { - requestBody = objectMapper.writeValueAsString(values); - } catch (JsonProcessingException e) { - e.printStackTrace(); - } + String body = new JSONObject() + .put("taskID", event.getTaskID()) + .put("result", event.getResult()) + .put("status", event.getStatus()) + .toString(); HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create(server+"/task/"+event.getTaskID())) - .PUT(HttpRequest.BodyPublishers.ofString(requestBody)) + .header("Content-Type", "application/json") + .PUT(HttpRequest.BodyPublishers.ofString(body)) .build(); - /** Needs the other service running try { - HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); - } catch (IOException e) { - e.printStackTrace(); - } catch (InterruptedException e) { + client.send(request, HttpResponse.BodyHandlers.ofString()); + } catch (IOException | InterruptedException e) { e.printStackTrace(); + // Restore interrupted state... + Thread.currentThread().interrupt(); } - **/ System.out.println("Finish execution event sent with result:" + event.getResult()); - + } - + } diff --git a/executor-base/src/main/java/ch/unisg/executorBase/executor/adapter/out/web/GetAssignmentAdapter.java b/executor-base/src/main/java/ch/unisg/executorBase/executor/adapter/out/web/GetAssignmentAdapter.java index b3e7875..b558075 100644 --- a/executor-base/src/main/java/ch/unisg/executorBase/executor/adapter/out/web/GetAssignmentAdapter.java +++ b/executor-base/src/main/java/ch/unisg/executorBase/executor/adapter/out/web/GetAssignmentAdapter.java @@ -1,8 +1,10 @@ package ch.unisg.executorBase.executor.adapter.out.web; +import java.io.IOException; import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; +import java.net.http.HttpResponse; import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Component; @@ -11,6 +13,8 @@ import ch.unisg.executorBase.executor.application.port.out.GetAssignmentPort; import ch.unisg.executorBase.executor.domain.ExecutorType; import ch.unisg.executorBase.executor.domain.Task; +import org.json.JSONObject; + @Component @Primary public class GetAssignmentAdapter implements GetAssignmentPort { @@ -19,27 +23,36 @@ public class GetAssignmentAdapter implements GetAssignmentPort { String server = "http://127.0.0.1:8082"; @Override - public Task getAssignment(ExecutorType executorType) { - + public Task getAssignment(ExecutorType executorType, String ip, int port) { + + String body = new JSONObject() + .put("executorType", executorType) + .put("ip", ip) + .put("port", port) + .toString(); + HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() - .uri(URI.create(server+"/assignment/" + executorType)) - .GET() + .uri(URI.create(server+"/task/apply")) + .header("Content-Type", "application/json") + .POST(HttpRequest.BodyPublishers.ofString(body)) .build(); - /** Needs the other service running try { HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); - } catch (IOException e) { - e.printStackTrace(); - } catch (InterruptedException e) { + if (response.body().equals("")) { + return null; + } + + return new Task(new JSONObject(response.body()).getString("taskID")); + + } catch (IOException | InterruptedException e) { e.printStackTrace(); + // Restore interrupted state... + Thread.currentThread().interrupt(); } - **/ - // TODO return null or a new Task here depending on the response of the http call - - return new Task("123"); + return null; } - + } diff --git a/executor-base/src/main/java/ch/unisg/executorBase/executor/application/port/in/TaskAvailableCommand.java b/executor-base/src/main/java/ch/unisg/executorBase/executor/application/port/in/TaskAvailableCommand.java index 916c8eb..cfa32bb 100644 --- a/executor-base/src/main/java/ch/unisg/executorBase/executor/application/port/in/TaskAvailableCommand.java +++ b/executor-base/src/main/java/ch/unisg/executorBase/executor/application/port/in/TaskAvailableCommand.java @@ -9,7 +9,7 @@ import lombok.Value; @Value public class TaskAvailableCommand extends SelfValidating { - + @NotNull private final ExecutorType taskType; diff --git a/executor-base/src/main/java/ch/unisg/executorBase/executor/application/port/out/GetAssignmentPort.java b/executor-base/src/main/java/ch/unisg/executorBase/executor/application/port/out/GetAssignmentPort.java index 1f205b8..79d3a0a 100644 --- a/executor-base/src/main/java/ch/unisg/executorBase/executor/application/port/out/GetAssignmentPort.java +++ b/executor-base/src/main/java/ch/unisg/executorBase/executor/application/port/out/GetAssignmentPort.java @@ -4,5 +4,5 @@ import ch.unisg.executorBase.executor.domain.ExecutorType; import ch.unisg.executorBase.executor.domain.Task; public interface GetAssignmentPort { - Task getAssignment(ExecutorType executorType); + Task getAssignment(ExecutorType executorType, String ip, int port); } 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 e639cb3..c9df1a8 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 @@ -4,13 +4,6 @@ import ch.unisg.executorBase.executor.application.port.out.ExecutionFinishedEven import ch.unisg.executorBase.executor.application.port.out.GetAssignmentPort; import ch.unisg.executorBase.executor.application.port.out.NotifyExecutorPoolPort; -import java.util.concurrent.TimeUnit; - -import javax.transaction.Transactional; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Configurable; - import ch.unisg.executorBase.executor.adapter.out.web.ExecutionFinishedEventAdapter; import ch.unisg.executorBase.executor.adapter.out.web.GetAssignmentAdapter; import ch.unisg.executorBase.executor.adapter.out.web.NotifyExecutorPoolAdapter; @@ -44,23 +37,19 @@ public abstract class ExecutorBase { this.ip = "localhost"; this.port = 8084; this.executorType = executorType; - + this.status = ExecutorStatus.STARTING_UP; if(!notifyExecutorPoolService.notifyExecutorPool(this.ip, this.port, this.executorType)) { System.exit(0); } else { - System.out.println(true); this.status = ExecutorStatus.IDLING; getAssignment(); } } - // public static ExecutorBase getExecutor() { - // return executor; - // } - public void getAssignment() { - Task newTask = getAssignmentPort.getAssignment(this.getExecutorType()); + Task newTask = getAssignmentPort.getAssignment(this.getExecutorType(), this.getIp(), + this.getPort()); if (newTask != null) { this.executeTask(newTask); } else { @@ -71,15 +60,16 @@ public abstract class ExecutorBase { private void executeTask(Task task) { System.out.println("Starting execution"); this.status = ExecutorStatus.EXECUTING; - + task.setResult(execution()); - executionFinishedEventPort.publishExecutionFinishedEvent(new ExecutionFinishedEvent(task.getTaskID(), task.getResult(), "SUCCESS")); + executionFinishedEventPort.publishExecutionFinishedEvent( + new ExecutionFinishedEvent(task.getTaskID(), task.getResult(), "SUCCESS")); System.out.println("Finish execution"); getAssignment(); } protected abstract String execution(); - + } diff --git a/executor-base/src/main/java/ch/unisg/executorBase/executor/domain/Task.java b/executor-base/src/main/java/ch/unisg/executorBase/executor/domain/Task.java index 6719613..fec330f 100644 --- a/executor-base/src/main/java/ch/unisg/executorBase/executor/domain/Task.java +++ b/executor-base/src/main/java/ch/unisg/executorBase/executor/domain/Task.java @@ -1,11 +1,10 @@ package ch.unisg.executorBase.executor.domain; -import lombok.Data; import lombok.Getter; import lombok.Setter; public class Task { - + @Getter private String taskID; diff --git a/executor2/src/main/java/ch/unisg/executor2/executor/adapter/in/web/TaskAvailableController.java b/executor2/src/main/java/ch/unisg/executor2/executor/adapter/in/web/TaskAvailableController.java new file mode 100644 index 0000000..db1b4b5 --- /dev/null +++ b/executor2/src/main/java/ch/unisg/executor2/executor/adapter/in/web/TaskAvailableController.java @@ -0,0 +1,36 @@ +package ch.unisg.executor2.executor.adapter.in.web; + +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +import ch.unisg.executorBase.executor.application.port.in.TaskAvailableCommand; +import ch.unisg.executorBase.executor.application.port.in.TaskAvailableUseCase; +import ch.unisg.executorBase.executor.domain.ExecutorType; + +@RestController +public class TaskAvailableController { + private final TaskAvailableUseCase taskAvailableUseCase; + + public TaskAvailableController(TaskAvailableUseCase taskAvailableUseCase) { + this.taskAvailableUseCase = taskAvailableUseCase; + } + + @GetMapping(path = "/newtask/{taskType}") + public ResponseEntity retrieveTaskFromTaskList(@PathVariable("taskType") String taskType) { + + if (ExecutorType.contains(taskType.toUpperCase())) { + TaskAvailableCommand command = new TaskAvailableCommand( + ExecutorType.valueOf(taskType.toUpperCase())); + taskAvailableUseCase.newTaskAvailable(command); + } + + // Add the content type as a response header + HttpHeaders responseHeaders = new HttpHeaders(); + + return new ResponseEntity<>("OK", responseHeaders, HttpStatus.OK); + } +} diff --git a/executor2/src/main/java/ch/unisg/executor2/executor/application/service/TaskAvailableService.java b/executor2/src/main/java/ch/unisg/executor2/executor/application/service/TaskAvailableService.java index 4484ebb..6fa918d 100644 --- a/executor2/src/main/java/ch/unisg/executor2/executor/application/service/TaskAvailableService.java +++ b/executor2/src/main/java/ch/unisg/executor2/executor/application/service/TaskAvailableService.java @@ -20,7 +20,7 @@ public class TaskAvailableService implements TaskAvailableUseCase { Executor executor = Executor.getExecutor(); - if (executor.getExecutorType() == command.getTaskType() && + if (executor.getExecutorType() == command.getTaskType() && executor.getStatus() == ExecutorStatus.IDLING) { executor.getAssignment(); } diff --git a/executor2/src/main/java/ch/unisg/executor2/executor/domain/Executor.java b/executor2/src/main/java/ch/unisg/executor2/executor/domain/Executor.java index bb9308b..6aa1656 100644 --- a/executor2/src/main/java/ch/unisg/executor2/executor/domain/Executor.java +++ b/executor2/src/main/java/ch/unisg/executor2/executor/domain/Executor.java @@ -5,7 +5,7 @@ import ch.unisg.executorBase.executor.domain.ExecutorBase; import ch.unisg.executorBase.executor.domain.ExecutorType; public class Executor extends ExecutorBase { - + private static final Executor executor = new Executor(ExecutorType.ADDITION); public static Executor getExecutor() { @@ -19,7 +19,7 @@ public class Executor extends ExecutorBase { @Override protected String execution() { - + int a = 20; int b = 20; try { diff --git a/executor2/src/main/resources/application.properties b/executor2/src/main/resources/application.properties index 4d360de..cd2d02b 100644 --- a/executor2/src/main/resources/application.properties +++ b/executor2/src/main/resources/application.properties @@ -1 +1 @@ -server.port=8081 +server.port=8085 From 46969deb0f9df05669c7efb0757cc372b171d63a Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 17 Oct 2021 10:33:26 +0200 Subject: [PATCH 10/17] added valueObjects & CustomErrors --- .../in/web/ApplyForTaskController.java | 15 +++------ .../adapter/in/web/NewTaskController.java | 15 +++------ .../in/web/WebControllerExceptionHandler.java | 31 +++++++++++++++++++ .../out/web/PublishNewTaskEventAdapter.java | 4 +-- .../web/PublishTaskAssignedEventAdapter.java | 2 +- .../web/PublishTaskCompletedEventAdapter.java | 2 +- .../port/in/ApplyForTaskCommand.java | 11 ++++--- .../application/port/in/NewTaskCommand.java | 8 +++-- .../port/in/TaskCompletedCommand.java | 5 +-- .../port/out/NewTaskEventPort.java | 2 +- .../port/out/TaskAssignedEventPort.java | 2 +- .../port/out/TaskCompletedEventPort.java | 2 +- .../service/ApplyForTaskService.java | 2 +- .../application/service/NewTaskService.java | 6 ++-- .../service/TaskCompletedService.java | 2 +- .../assignment/domain/ExecutorInfo.java | 9 ++++-- .../assignment/domain/NewTaskEvent.java | 9 ------ .../assignment/assignment/domain/Roster.java | 22 +++++++------ .../assignment/domain/RosterItem.java | 8 +++-- .../assignment/assignment/domain/Task.java | 10 +++++- .../assignment/domain/event/NewTaskEvent.java | 11 +++++++ .../domain/{ => event}/TaskAssignedEvent.java | 2 +- .../{ => event}/TaskCompletedEvent.java | 8 ++--- .../domain/valueobject/ExecutorType.java | 12 +++++++ .../domain/valueobject/IP4Adress.java | 23 ++++++++++++++ .../assignment/domain/valueobject/Port.java | 17 ++++++++++ .../common/exception/ErrorResponse.java | 13 ++++++++ .../common/exception/InvalidIP4Exception.java | 7 +++++ .../exception/PortOutOfRangeException.java | 7 +++++ .../web/ExecutionFinishedEventAdapter.java | 5 --- .../out/web/NotifyExecutorPoolAdapter.java | 28 +++++------------ executor2/pom.xml | 6 ++++ .../in/web/TaskAvailableController.java | 9 +++--- .../service/TaskAvailableService.java | 2 ++ 34 files changed, 214 insertions(+), 103 deletions(-) create mode 100644 assignment/src/main/java/ch/unisg/assignment/assignment/adapter/in/web/WebControllerExceptionHandler.java delete mode 100644 assignment/src/main/java/ch/unisg/assignment/assignment/domain/NewTaskEvent.java create mode 100644 assignment/src/main/java/ch/unisg/assignment/assignment/domain/event/NewTaskEvent.java rename assignment/src/main/java/ch/unisg/assignment/assignment/domain/{ => event}/TaskAssignedEvent.java (73%) rename assignment/src/main/java/ch/unisg/assignment/assignment/domain/{ => event}/TaskCompletedEvent.java (58%) create mode 100644 assignment/src/main/java/ch/unisg/assignment/assignment/domain/valueobject/ExecutorType.java create mode 100644 assignment/src/main/java/ch/unisg/assignment/assignment/domain/valueobject/IP4Adress.java create mode 100644 assignment/src/main/java/ch/unisg/assignment/assignment/domain/valueobject/Port.java create mode 100644 assignment/src/main/java/ch/unisg/assignment/common/exception/ErrorResponse.java create mode 100644 assignment/src/main/java/ch/unisg/assignment/common/exception/InvalidIP4Exception.java create mode 100644 assignment/src/main/java/ch/unisg/assignment/common/exception/PortOutOfRangeException.java diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/in/web/ApplyForTaskController.java b/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/in/web/ApplyForTaskController.java index e83e74d..1d0111d 100644 --- a/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/in/web/ApplyForTaskController.java +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/in/web/ApplyForTaskController.java @@ -1,12 +1,8 @@ package ch.unisg.assignment.assignment.adapter.in.web; -import javax.validation.ConstraintViolationException; - -import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.server.ResponseStatusException; import ch.unisg.assignment.assignment.application.port.in.ApplyForTaskCommand; import ch.unisg.assignment.assignment.application.port.in.ApplyForTaskUseCase; @@ -23,14 +19,11 @@ public class ApplyForTaskController { @PostMapping(path = "/task/apply", consumes = {"application/json"}) public Task applyForTask(@RequestBody ExecutorInfo executorInfo) { - try { - ApplyForTaskCommand command = new ApplyForTaskCommand(executorInfo.getExecutorType(), - executorInfo.getIp(), executorInfo.getPort()); - return applyForTaskUseCase.applyForTask(command); + ApplyForTaskCommand command = new ApplyForTaskCommand(executorInfo.getExecutorType(), + executorInfo.getIp(), executorInfo.getPort()); + + return applyForTaskUseCase.applyForTask(command); - } catch (ConstraintViolationException e) { - throw new ResponseStatusException(HttpStatus.BAD_REQUEST, e.getMessage()); - } } } diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/in/web/NewTaskController.java b/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/in/web/NewTaskController.java index d95fdd5..18bad8f 100644 --- a/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/in/web/NewTaskController.java +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/in/web/NewTaskController.java @@ -1,13 +1,10 @@ package ch.unisg.assignment.assignment.adapter.in.web; -import javax.validation.ConstraintViolationException; - import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.server.ResponseStatusException; import ch.unisg.assignment.assignment.application.port.in.NewTaskCommand; import ch.unisg.assignment.assignment.application.port.in.NewTaskUseCase; @@ -22,11 +19,9 @@ public class NewTaskController { } @PostMapping(path = "/task", consumes = {"application/json"}) - public ResponseEntity addNewTaskTaskToTaskList(@RequestBody Task task) { - try { - NewTaskCommand command = new NewTaskCommand( - task.getTaskID(), task.getTaskType() - ); + public ResponseEntity newTaskController(@RequestBody Task task) { + + NewTaskCommand command = new NewTaskCommand(task.getTaskID(), task.getTaskType()); boolean success = newTaskUseCase.addNewTaskToQueue(command); @@ -34,8 +29,6 @@ public class NewTaskController { return new ResponseEntity<>(HttpStatus.CREATED); } return new ResponseEntity<>(HttpStatus.CONFLICT); - } catch (ConstraintViolationException e) { - throw new ResponseStatusException(HttpStatus.BAD_REQUEST, e.getMessage()); - } + } } diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/in/web/WebControllerExceptionHandler.java b/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/in/web/WebControllerExceptionHandler.java new file mode 100644 index 0000000..08a0895 --- /dev/null +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/in/web/WebControllerExceptionHandler.java @@ -0,0 +1,31 @@ +package ch.unisg.assignment.assignment.adapter.in.web; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; + +import ch.unisg.assignment.common.exception.ErrorResponse; +import ch.unisg.assignment.common.exception.InvalidIP4Exception; +import ch.unisg.assignment.common.exception.PortOutOfRangeException; + +@ControllerAdvice +public class WebControllerExceptionHandler { + + @ExceptionHandler(PortOutOfRangeException.class) + public ResponseEntity handleException(PortOutOfRangeException e){ + + ErrorResponse error = new ErrorResponse(HttpStatus.BAD_REQUEST, e.getLocalizedMessage()); + return new ResponseEntity<>(error, error.getHttpStatus()); + + } + + @ExceptionHandler(InvalidIP4Exception.class) + public ResponseEntity handleException(InvalidIP4Exception e){ + + ErrorResponse error = new ErrorResponse(HttpStatus.BAD_REQUEST, e.getLocalizedMessage()); + return new ResponseEntity<>(error, error.getHttpStatus()); + + } + +} diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/out/web/PublishNewTaskEventAdapter.java b/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/out/web/PublishNewTaskEventAdapter.java index c08651b..b764faa 100644 --- a/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/out/web/PublishNewTaskEventAdapter.java +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/out/web/PublishNewTaskEventAdapter.java @@ -10,7 +10,7 @@ import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Component; import ch.unisg.assignment.assignment.application.port.out.NewTaskEventPort; -import ch.unisg.assignment.assignment.domain.NewTaskEvent; +import ch.unisg.assignment.assignment.domain.event.NewTaskEvent; @Component @Primary @@ -23,7 +23,7 @@ public class PublishNewTaskEventAdapter implements NewTaskEventPort { HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() - .uri(URI.create(server + "/newtask/" + event.taskType)) + .uri(URI.create(server + "/newtask/" + event.taskType.getValue())) .GET() .build(); diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/out/web/PublishTaskAssignedEventAdapter.java b/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/out/web/PublishTaskAssignedEventAdapter.java index 7f38d60..99879f7 100644 --- a/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/out/web/PublishTaskAssignedEventAdapter.java +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/out/web/PublishTaskAssignedEventAdapter.java @@ -11,7 +11,7 @@ import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Component; import ch.unisg.assignment.assignment.application.port.out.TaskAssignedEventPort; -import ch.unisg.assignment.assignment.domain.TaskAssignedEvent; +import ch.unisg.assignment.assignment.domain.event.TaskAssignedEvent; @Component @Primary diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/out/web/PublishTaskCompletedEventAdapter.java b/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/out/web/PublishTaskCompletedEventAdapter.java index d63d710..59a27ce 100644 --- a/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/out/web/PublishTaskCompletedEventAdapter.java +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/out/web/PublishTaskCompletedEventAdapter.java @@ -11,7 +11,7 @@ import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Component; import ch.unisg.assignment.assignment.application.port.out.TaskCompletedEventPort; -import ch.unisg.assignment.assignment.domain.TaskCompletedEvent; +import ch.unisg.assignment.assignment.domain.event.TaskCompletedEvent; @Component @Primary diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/in/ApplyForTaskCommand.java b/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/in/ApplyForTaskCommand.java index 76d0e41..df36d58 100644 --- a/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/in/ApplyForTaskCommand.java +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/in/ApplyForTaskCommand.java @@ -2,6 +2,9 @@ package ch.unisg.assignment.assignment.application.port.in; import javax.validation.constraints.NotNull; +import ch.unisg.assignment.assignment.domain.valueobject.ExecutorType; +import ch.unisg.assignment.assignment.domain.valueobject.IP4Adress; +import ch.unisg.assignment.assignment.domain.valueobject.Port; import ch.unisg.assignment.common.SelfValidating; import lombok.EqualsAndHashCode; import lombok.Value; @@ -11,16 +14,16 @@ import lombok.Value; public class ApplyForTaskCommand extends SelfValidating{ @NotNull - private final String taskType; + private final ExecutorType taskType; @NotNull - private final String executorIP; + private final IP4Adress executorIP; @NotNull - private final int executorPort; + private final Port executorPort; - public ApplyForTaskCommand(String taskType, String executorIP, int executorPort) { + public ApplyForTaskCommand(ExecutorType taskType, IP4Adress executorIP, Port executorPort) { this.taskType = taskType; this.executorIP = executorIP; this.executorPort = executorPort; diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/in/NewTaskCommand.java b/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/in/NewTaskCommand.java index 98f4579..ab6838e 100644 --- a/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/in/NewTaskCommand.java +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/in/NewTaskCommand.java @@ -2,20 +2,22 @@ package ch.unisg.assignment.assignment.application.port.in; import javax.validation.constraints.NotNull; +import ch.unisg.assignment.assignment.domain.valueobject.ExecutorType; import ch.unisg.assignment.common.SelfValidating; - +import lombok.EqualsAndHashCode; import lombok.Value; @Value +@EqualsAndHashCode(callSuper=false) public class NewTaskCommand extends SelfValidating { @NotNull private final String taskID; @NotNull - private final String taskType; + private final ExecutorType taskType; - public NewTaskCommand(String taskID, String taskType) { + public NewTaskCommand(String taskID, ExecutorType taskType) { this.taskID = taskID; this.taskType = taskType; this.validateSelf(); diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/in/TaskCompletedCommand.java b/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/in/TaskCompletedCommand.java index 474456d..e324e89 100644 --- a/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/in/TaskCompletedCommand.java +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/in/TaskCompletedCommand.java @@ -2,6 +2,7 @@ package ch.unisg.assignment.assignment.application.port.in; import javax.validation.constraints.NotNull; +import ch.unisg.assignment.assignment.domain.valueobject.ExecutorType; import ch.unisg.assignment.common.SelfValidating; import lombok.EqualsAndHashCode; import lombok.Value; @@ -14,7 +15,7 @@ public class TaskCompletedCommand extends SelfValidating{ private final String taskID; @NotNull - private final String taskType; + private final ExecutorType taskType; @NotNull private final String taskStatus; @@ -22,7 +23,7 @@ public class TaskCompletedCommand extends SelfValidating{ @NotNull private final String taskResult; - public TaskCompletedCommand(String taskID, String taskType, String taskStatus, String taskResult) { + public TaskCompletedCommand(String taskID, ExecutorType taskType, String taskStatus, String taskResult) { this.taskID = taskID; this.taskType = taskType; this.taskStatus = taskStatus; diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/out/NewTaskEventPort.java b/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/out/NewTaskEventPort.java index 521af1a..909a9ba 100644 --- a/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/out/NewTaskEventPort.java +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/out/NewTaskEventPort.java @@ -1,6 +1,6 @@ package ch.unisg.assignment.assignment.application.port.out; -import ch.unisg.assignment.assignment.domain.NewTaskEvent; +import ch.unisg.assignment.assignment.domain.event.NewTaskEvent; public interface NewTaskEventPort { void publishNewTaskEvent(NewTaskEvent event); diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/out/TaskAssignedEventPort.java b/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/out/TaskAssignedEventPort.java index 0cd1cae..fefd4a1 100644 --- a/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/out/TaskAssignedEventPort.java +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/out/TaskAssignedEventPort.java @@ -1,6 +1,6 @@ package ch.unisg.assignment.assignment.application.port.out; -import ch.unisg.assignment.assignment.domain.TaskAssignedEvent; +import ch.unisg.assignment.assignment.domain.event.TaskAssignedEvent; public interface TaskAssignedEventPort { void publishTaskAssignedEvent(TaskAssignedEvent taskAssignedEvent); diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/out/TaskCompletedEventPort.java b/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/out/TaskCompletedEventPort.java index 37b4ff3..43a8aa5 100644 --- a/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/out/TaskCompletedEventPort.java +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/application/port/out/TaskCompletedEventPort.java @@ -1,6 +1,6 @@ package ch.unisg.assignment.assignment.application.port.out; -import ch.unisg.assignment.assignment.domain.TaskCompletedEvent; +import ch.unisg.assignment.assignment.domain.event.TaskCompletedEvent; public interface TaskCompletedEventPort { void publishTaskCompleted(TaskCompletedEvent event); diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/application/service/ApplyForTaskService.java b/assignment/src/main/java/ch/unisg/assignment/assignment/application/service/ApplyForTaskService.java index dac9a70..0593a30 100644 --- a/assignment/src/main/java/ch/unisg/assignment/assignment/application/service/ApplyForTaskService.java +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/application/service/ApplyForTaskService.java @@ -9,7 +9,7 @@ import ch.unisg.assignment.assignment.application.port.in.ApplyForTaskUseCase; import ch.unisg.assignment.assignment.application.port.out.TaskAssignedEventPort; import ch.unisg.assignment.assignment.domain.Roster; import ch.unisg.assignment.assignment.domain.Task; -import ch.unisg.assignment.assignment.domain.TaskAssignedEvent; +import ch.unisg.assignment.assignment.domain.event.TaskAssignedEvent; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/application/service/NewTaskService.java b/assignment/src/main/java/ch/unisg/assignment/assignment/application/service/NewTaskService.java index b662cd2..069ee29 100644 --- a/assignment/src/main/java/ch/unisg/assignment/assignment/application/service/NewTaskService.java +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/application/service/NewTaskService.java @@ -10,9 +10,9 @@ import org.springframework.stereotype.Component; import ch.unisg.assignment.assignment.application.port.in.NewTaskCommand; import ch.unisg.assignment.assignment.application.port.in.NewTaskUseCase; import ch.unisg.assignment.assignment.application.port.out.NewTaskEventPort; -import ch.unisg.assignment.assignment.domain.NewTaskEvent; import ch.unisg.assignment.assignment.domain.Roster; import ch.unisg.assignment.assignment.domain.Task; +import ch.unisg.assignment.assignment.domain.event.NewTaskEvent; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor @@ -26,9 +26,9 @@ public class NewTaskService implements NewTaskUseCase { public boolean addNewTaskToQueue(NewTaskCommand command) { // TODO Get availableTaskTypes from executor pool - List availableTaskTypes = Arrays.asList("addition", "robot"); + List availableTaskTypes = Arrays.asList("ADDITION", "ROBOT"); - if (!availableTaskTypes.contains(command.getTaskType())) { + if (!availableTaskTypes.contains(command.getTaskType().getValue())) { return false; } diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/application/service/TaskCompletedService.java b/assignment/src/main/java/ch/unisg/assignment/assignment/application/service/TaskCompletedService.java index 1295336..c8273ff 100644 --- a/assignment/src/main/java/ch/unisg/assignment/assignment/application/service/TaskCompletedService.java +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/application/service/TaskCompletedService.java @@ -8,7 +8,7 @@ import ch.unisg.assignment.assignment.application.port.in.TaskCompletedCommand; import ch.unisg.assignment.assignment.application.port.in.TaskCompletedUseCase; import ch.unisg.assignment.assignment.application.port.out.TaskCompletedEventPort; import ch.unisg.assignment.assignment.domain.Roster; -import ch.unisg.assignment.assignment.domain.TaskCompletedEvent; +import ch.unisg.assignment.assignment.domain.event.TaskCompletedEvent; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/domain/ExecutorInfo.java b/assignment/src/main/java/ch/unisg/assignment/assignment/domain/ExecutorInfo.java index 3b7432c..6b19dcc 100644 --- a/assignment/src/main/java/ch/unisg/assignment/assignment/domain/ExecutorInfo.java +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/domain/ExecutorInfo.java @@ -1,18 +1,21 @@ package ch.unisg.assignment.assignment.domain; +import ch.unisg.assignment.assignment.domain.valueobject.ExecutorType; +import ch.unisg.assignment.assignment.domain.valueobject.IP4Adress; +import ch.unisg.assignment.assignment.domain.valueobject.Port; import lombok.Getter; import lombok.Setter; public class ExecutorInfo { @Getter @Setter - private String ip; + private IP4Adress ip; @Getter @Setter - private int port; + private Port port; @Getter @Setter - private String executorType; + private ExecutorType executorType; } diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/domain/NewTaskEvent.java b/assignment/src/main/java/ch/unisg/assignment/assignment/domain/NewTaskEvent.java deleted file mode 100644 index 57084ee..0000000 --- a/assignment/src/main/java/ch/unisg/assignment/assignment/domain/NewTaskEvent.java +++ /dev/null @@ -1,9 +0,0 @@ -package ch.unisg.assignment.assignment.domain; - -public class NewTaskEvent { - public String taskType; - - public NewTaskEvent(String taskType) { - this.taskType = taskType; - } -} diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/domain/Roster.java b/assignment/src/main/java/ch/unisg/assignment/assignment/domain/Roster.java index 054c094..521a748 100644 --- a/assignment/src/main/java/ch/unisg/assignment/assignment/domain/Roster.java +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/domain/Roster.java @@ -4,6 +4,10 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; +import ch.unisg.assignment.assignment.domain.valueobject.ExecutorType; +import ch.unisg.assignment.assignment.domain.valueobject.IP4Adress; +import ch.unisg.assignment.assignment.domain.valueobject.Port; + public class Roster { private static final Roster roster = new Roster(); @@ -19,25 +23,25 @@ public class Roster { private Roster() {} public void addTaskToQueue(Task task) { - if (queues.containsKey(task.getTaskType().toUpperCase())) { - queues.get(task.getTaskType().toUpperCase()).add(task); + if (queues.containsKey(task.getTaskType().getValue())) { + queues.get(task.getTaskType().getValue()).add(task); } else { - queues.put(task.getTaskType().toUpperCase(), new ArrayList<>(Arrays.asList(task))); + queues.put(task.getTaskType().getValue(), new ArrayList<>(Arrays.asList(task))); } } - public Task assignTaskToExecutor(String taskType, String executorIP, int executorPort) { - if (!queues.containsKey(taskType.toUpperCase())) { + public Task assignTaskToExecutor(ExecutorType taskType, IP4Adress executorIP, Port executorPort) { + if (!queues.containsKey(taskType.getValue())) { return null; } - if (queues.get(taskType.toUpperCase()).isEmpty()) { + if (queues.get(taskType.getValue()).isEmpty()) { return null; } - Task task = queues.get(taskType.toUpperCase()).remove(0); + Task task = queues.get(taskType.getValue()).remove(0); - rosterMap.put(task.getTaskID(), new RosterItem(task.getTaskID(), task.getTaskType(), - executorIP, executorPort)); + rosterMap.put(task.getTaskID(), new RosterItem(task.getTaskID(), + task.getTaskType().getValue(), executorIP, executorPort)); return task; } diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/domain/RosterItem.java b/assignment/src/main/java/ch/unisg/assignment/assignment/domain/RosterItem.java index 6e050d4..2c3bb52 100644 --- a/assignment/src/main/java/ch/unisg/assignment/assignment/domain/RosterItem.java +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/domain/RosterItem.java @@ -1,5 +1,7 @@ package ch.unisg.assignment.assignment.domain; +import ch.unisg.assignment.assignment.domain.valueobject.IP4Adress; +import ch.unisg.assignment.assignment.domain.valueobject.Port; import lombok.Getter; public class RosterItem { @@ -11,13 +13,13 @@ public class RosterItem { private String taskType; @Getter - private String executorIP; + private IP4Adress executorIP; @Getter - private int executorPort; + private Port executorPort; - public RosterItem(String taskID, String taskType, String executorIP, int executorPort) { + public RosterItem(String taskID, String taskType, IP4Adress executorIP, Port executorPort) { this.taskID = taskID; this.taskType = taskType; this.executorIP = executorIP; diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/domain/Task.java b/assignment/src/main/java/ch/unisg/assignment/assignment/domain/Task.java index 6db5111..55fb00d 100644 --- a/assignment/src/main/java/ch/unisg/assignment/assignment/domain/Task.java +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/domain/Task.java @@ -1,5 +1,6 @@ package ch.unisg.assignment.assignment.domain; +import ch.unisg.assignment.assignment.domain.valueobject.ExecutorType; import lombok.Getter; import lombok.Setter; @@ -9,7 +10,7 @@ public class Task { private String taskID; @Getter - private String taskType; + private ExecutorType taskType; @Getter @Setter @@ -20,8 +21,15 @@ public class Task { private String status; public Task(String taskID, String taskType) { + this.taskID = taskID; + this.taskType = new ExecutorType(taskType); + } + + public Task(String taskID, ExecutorType taskType) { this.taskID = taskID; this.taskType = taskType; } + public Task() {}; + } diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/domain/event/NewTaskEvent.java b/assignment/src/main/java/ch/unisg/assignment/assignment/domain/event/NewTaskEvent.java new file mode 100644 index 0000000..34e7f0b --- /dev/null +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/domain/event/NewTaskEvent.java @@ -0,0 +1,11 @@ +package ch.unisg.assignment.assignment.domain.event; + +import ch.unisg.assignment.assignment.domain.valueobject.ExecutorType; + +public class NewTaskEvent { + public final ExecutorType taskType; + + public NewTaskEvent(ExecutorType taskType) { + this.taskType = taskType; + } +} diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/domain/TaskAssignedEvent.java b/assignment/src/main/java/ch/unisg/assignment/assignment/domain/event/TaskAssignedEvent.java similarity index 73% rename from assignment/src/main/java/ch/unisg/assignment/assignment/domain/TaskAssignedEvent.java rename to assignment/src/main/java/ch/unisg/assignment/assignment/domain/event/TaskAssignedEvent.java index 8acd144..ef20f43 100644 --- a/assignment/src/main/java/ch/unisg/assignment/assignment/domain/TaskAssignedEvent.java +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/domain/event/TaskAssignedEvent.java @@ -1,4 +1,4 @@ -package ch.unisg.assignment.assignment.domain; +package ch.unisg.assignment.assignment.domain.event; public class TaskAssignedEvent { public String taskID; diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/domain/TaskCompletedEvent.java b/assignment/src/main/java/ch/unisg/assignment/assignment/domain/event/TaskCompletedEvent.java similarity index 58% rename from assignment/src/main/java/ch/unisg/assignment/assignment/domain/TaskCompletedEvent.java rename to assignment/src/main/java/ch/unisg/assignment/assignment/domain/event/TaskCompletedEvent.java index 89f26ae..432a8f0 100644 --- a/assignment/src/main/java/ch/unisg/assignment/assignment/domain/TaskCompletedEvent.java +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/domain/event/TaskCompletedEvent.java @@ -1,11 +1,11 @@ -package ch.unisg.assignment.assignment.domain; +package ch.unisg.assignment.assignment.domain.event; public class TaskCompletedEvent { - public String taskID; + public final String taskID; - public String status; + public final String status; - public String result; + public final String result; public TaskCompletedEvent(String taskID, String status, String result) { this.taskID = taskID; diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/domain/valueobject/ExecutorType.java b/assignment/src/main/java/ch/unisg/assignment/assignment/domain/valueobject/ExecutorType.java new file mode 100644 index 0000000..bc5f467 --- /dev/null +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/domain/valueobject/ExecutorType.java @@ -0,0 +1,12 @@ +package ch.unisg.assignment.assignment.domain.valueobject; + +import lombok.Value; + +@Value +public class ExecutorType { + private String value; + + public ExecutorType(String type) { + this.value = type.toUpperCase(); + } +} diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/domain/valueobject/IP4Adress.java b/assignment/src/main/java/ch/unisg/assignment/assignment/domain/valueobject/IP4Adress.java new file mode 100644 index 0000000..cd23b6b --- /dev/null +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/domain/valueobject/IP4Adress.java @@ -0,0 +1,23 @@ +package ch.unisg.assignment.assignment.domain.valueobject; + +import ch.unisg.assignment.common.exception.InvalidIP4Exception; +import lombok.Value; + +@Value +public class IP4Adress { + private String value; + + public IP4Adress(String ip4) throws InvalidIP4Exception { + if (ip4.equalsIgnoreCase("localhost") || + ip4.matches("^((25[0-5]|(2[0-4]|1\\d|[1-9]|)\\d)(\\.(?!$)|$)){4}$")) { + this.value = ip4; + } else { + throw new InvalidIP4Exception(); + } + } +} + + + + + diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/domain/valueobject/Port.java b/assignment/src/main/java/ch/unisg/assignment/assignment/domain/valueobject/Port.java new file mode 100644 index 0000000..a66dbbd --- /dev/null +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/domain/valueobject/Port.java @@ -0,0 +1,17 @@ +package ch.unisg.assignment.assignment.domain.valueobject; + +import ch.unisg.assignment.common.exception.PortOutOfRangeException; +import lombok.Value; + +@Value +public class Port { + private int value; + + public Port(int port) throws PortOutOfRangeException { + if (1024 <= port && port <= 65535) { + this.value = port; + } else { + throw new PortOutOfRangeException(); + } + } +} diff --git a/assignment/src/main/java/ch/unisg/assignment/common/exception/ErrorResponse.java b/assignment/src/main/java/ch/unisg/assignment/common/exception/ErrorResponse.java new file mode 100644 index 0000000..2fb834e --- /dev/null +++ b/assignment/src/main/java/ch/unisg/assignment/common/exception/ErrorResponse.java @@ -0,0 +1,13 @@ +package ch.unisg.assignment.common.exception; + +import org.springframework.http.HttpStatus; + +import lombok.Data; +import lombok.RequiredArgsConstructor; + +@Data +@RequiredArgsConstructor +public class ErrorResponse { + private final HttpStatus httpStatus; + private final String message; +} diff --git a/assignment/src/main/java/ch/unisg/assignment/common/exception/InvalidIP4Exception.java b/assignment/src/main/java/ch/unisg/assignment/common/exception/InvalidIP4Exception.java new file mode 100644 index 0000000..fecbfcb --- /dev/null +++ b/assignment/src/main/java/ch/unisg/assignment/common/exception/InvalidIP4Exception.java @@ -0,0 +1,7 @@ +package ch.unisg.assignment.common.exception; + +public class InvalidIP4Exception extends Exception { + public InvalidIP4Exception() { + super("IP4 is invalid"); + } +} diff --git a/assignment/src/main/java/ch/unisg/assignment/common/exception/PortOutOfRangeException.java b/assignment/src/main/java/ch/unisg/assignment/common/exception/PortOutOfRangeException.java new file mode 100644 index 0000000..2772256 --- /dev/null +++ b/assignment/src/main/java/ch/unisg/assignment/common/exception/PortOutOfRangeException.java @@ -0,0 +1,7 @@ +package ch.unisg.assignment.common.exception; + +public class PortOutOfRangeException extends Exception { + public PortOutOfRangeException() { + super("Port is out of available range (1024-65535)"); + } +} diff --git a/executor-base/src/main/java/ch/unisg/executorBase/executor/adapter/out/web/ExecutionFinishedEventAdapter.java b/executor-base/src/main/java/ch/unisg/executorBase/executor/adapter/out/web/ExecutionFinishedEventAdapter.java index e688868..7408740 100644 --- a/executor-base/src/main/java/ch/unisg/executorBase/executor/adapter/out/web/ExecutionFinishedEventAdapter.java +++ b/executor-base/src/main/java/ch/unisg/executorBase/executor/adapter/out/web/ExecutionFinishedEventAdapter.java @@ -5,14 +5,9 @@ import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; -import java.util.HashMap; - -import com.fasterxml.jackson.databind.ObjectMapper; import org.json.JSONObject; -import com.fasterxml.jackson.core.JsonProcessingException; - import ch.unisg.executorBase.executor.application.port.out.ExecutionFinishedEventPort; import ch.unisg.executorBase.executor.domain.ExecutionFinishedEvent; 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 feeca69..bf465f7 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 @@ -3,11 +3,8 @@ package ch.unisg.executorBase.executor.adapter.out.web; import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; -import java.util.HashMap; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; +import org.json.JSONObject; import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Component; @@ -17,31 +14,22 @@ import ch.unisg.executorBase.executor.domain.ExecutorType; @Component @Primary public class NotifyExecutorPoolAdapter implements NotifyExecutorPoolPort { - - //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:8083"; @Override public boolean notifyExecutorPool(String ip, int port, ExecutorType executorType) { - var values = new HashMap() {{ - put("ip", ip); - put("port", Integer.toString(port)); - put("executorType", executorType.toString()); - }}; - - var objectMapper = new ObjectMapper(); - String requestBody = null; - try { - requestBody = objectMapper.writeValueAsString(values); - } catch (JsonProcessingException e) { - e.printStackTrace(); - } + String body = new JSONObject() + .put("executorType", executorType) + .put("ip", ip) + .put("port", port) + .toString(); HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create(server+"/executor/new/")) - .POST(HttpRequest.BodyPublishers.ofString(requestBody)) + .POST(HttpRequest.BodyPublishers.ofString(body)) .build(); /** Needs the other service running diff --git a/executor2/pom.xml b/executor2/pom.xml index 95c67ff..86634c6 100644 --- a/executor2/pom.xml +++ b/executor2/pom.xml @@ -45,6 +45,12 @@ executorBase 0.0.1-SNAPSHOT + + + org.json + json + 20210307 + diff --git a/executor2/src/main/java/ch/unisg/executor2/executor/adapter/in/web/TaskAvailableController.java b/executor2/src/main/java/ch/unisg/executor2/executor/adapter/in/web/TaskAvailableController.java index db1b4b5..a14b58f 100644 --- a/executor2/src/main/java/ch/unisg/executor2/executor/adapter/in/web/TaskAvailableController.java +++ b/executor2/src/main/java/ch/unisg/executor2/executor/adapter/in/web/TaskAvailableController.java @@ -1,5 +1,7 @@ package ch.unisg.executor2.executor.adapter.in.web; +import java.util.concurrent.CompletableFuture; + import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -25,12 +27,9 @@ public class TaskAvailableController { if (ExecutorType.contains(taskType.toUpperCase())) { TaskAvailableCommand command = new TaskAvailableCommand( ExecutorType.valueOf(taskType.toUpperCase())); - taskAvailableUseCase.newTaskAvailable(command); + CompletableFuture.runAsync(() -> taskAvailableUseCase.newTaskAvailable(command)); } - // Add the content type as a response header - HttpHeaders responseHeaders = new HttpHeaders(); - - return new ResponseEntity<>("OK", responseHeaders, HttpStatus.OK); + return new ResponseEntity<>("OK", new HttpHeaders(), HttpStatus.OK); } } diff --git a/executor2/src/main/java/ch/unisg/executor2/executor/application/service/TaskAvailableService.java b/executor2/src/main/java/ch/unisg/executor2/executor/application/service/TaskAvailableService.java index 6fa918d..39db6ab 100644 --- a/executor2/src/main/java/ch/unisg/executor2/executor/application/service/TaskAvailableService.java +++ b/executor2/src/main/java/ch/unisg/executor2/executor/application/service/TaskAvailableService.java @@ -1,5 +1,6 @@ package ch.unisg.executor2.executor.application.service; +import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Component; import ch.unisg.executor2.executor.domain.Executor; @@ -16,6 +17,7 @@ import javax.transaction.Transactional; public class TaskAvailableService implements TaskAvailableUseCase { @Override + @Async public void newTaskAvailable(TaskAvailableCommand command) { Executor executor = Executor.getExecutor(); From 39191afc2c5fc0d2692f31a5e7ba87c2ec765b56 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 17 Oct 2021 10:44:47 +0200 Subject: [PATCH 11/17] fixed security hotspots & code smells --- .../adapter/out/web/PublishTaskAssignedEventAdapter.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/out/web/PublishTaskAssignedEventAdapter.java b/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/out/web/PublishTaskAssignedEventAdapter.java index 99879f7..85bb9ab 100644 --- a/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/out/web/PublishTaskAssignedEventAdapter.java +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/out/web/PublishTaskAssignedEventAdapter.java @@ -5,6 +5,8 @@ import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; +import java.util.logging.Level; +import java.util.logging.Logger; import org.json.JSONObject; import org.springframework.context.annotation.Primary; @@ -19,6 +21,8 @@ public class PublishTaskAssignedEventAdapter implements TaskAssignedEventPort { String server = "http://127.0.0.1:8085"; + Logger logger = Logger.getLogger(PublishTaskAssignedEventAdapter.class.getName()); + @Override public void publishTaskAssignedEvent(TaskAssignedEvent event) { @@ -37,7 +41,7 @@ public class PublishTaskAssignedEventAdapter implements TaskAssignedEventPort { try { client.send(request, HttpResponse.BodyHandlers.ofString()); } catch (IOException | InterruptedException e) { - e.printStackTrace(); + logger.log(Level.SEVERE, e.getLocalizedMessage(), e); // Restore interrupted state... Thread.currentThread().interrupt(); } From b072cfc7ce5758f2009c8bbe791af7519dd9aa61 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 17 Oct 2021 10:45:24 +0200 Subject: [PATCH 12/17] fixed security hotspots & code smells --- .../adapter/out/web/PublishNewTaskEventAdapter.java | 6 +++++- .../adapter/out/web/PublishTaskCompletedEventAdapter.java | 6 +++++- .../java/ch/unisg/assignment/assignment/domain/Task.java | 2 +- .../assignment/domain/event/TaskAssignedEvent.java | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/out/web/PublishNewTaskEventAdapter.java b/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/out/web/PublishNewTaskEventAdapter.java index b764faa..1db2b84 100644 --- a/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/out/web/PublishNewTaskEventAdapter.java +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/out/web/PublishNewTaskEventAdapter.java @@ -5,6 +5,8 @@ import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; +import java.util.logging.Level; +import java.util.logging.Logger; import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Component; @@ -18,6 +20,8 @@ public class PublishNewTaskEventAdapter implements NewTaskEventPort { String server = "http://127.0.0.1:8085"; + Logger logger = Logger.getLogger(PublishNewTaskEventAdapter.class.getName()); + @Override public void publishNewTaskEvent(NewTaskEvent event) { @@ -31,7 +35,7 @@ public class PublishNewTaskEventAdapter implements NewTaskEventPort { try { client.send(request, HttpResponse.BodyHandlers.ofString()); } catch (IOException | InterruptedException e) { - e.printStackTrace(); + logger.log(Level.SEVERE, e.getLocalizedMessage(), e); // Restore interrupted state... Thread.currentThread().interrupt(); } diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/out/web/PublishTaskCompletedEventAdapter.java b/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/out/web/PublishTaskCompletedEventAdapter.java index 59a27ce..f9f2833 100644 --- a/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/out/web/PublishTaskCompletedEventAdapter.java +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/adapter/out/web/PublishTaskCompletedEventAdapter.java @@ -5,6 +5,8 @@ import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; +import java.util.logging.Level; +import java.util.logging.Logger; import org.json.JSONObject; import org.springframework.context.annotation.Primary; @@ -19,6 +21,8 @@ public class PublishTaskCompletedEventAdapter implements TaskCompletedEventPort String server = "http://127.0.0.1:8081"; + Logger logger = Logger.getLogger(PublishTaskCompletedEventAdapter.class.getName()); + @Override public void publishTaskCompleted(TaskCompletedEvent event) { @@ -39,7 +43,7 @@ public class PublishTaskCompletedEventAdapter implements TaskCompletedEventPort try { client.send(request, HttpResponse.BodyHandlers.ofString()); } catch (IOException | InterruptedException e) { - e.printStackTrace(); + logger.log(Level.SEVERE, e.getLocalizedMessage(), e); // Restore interrupted state... Thread.currentThread().interrupt(); } diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/domain/Task.java b/assignment/src/main/java/ch/unisg/assignment/assignment/domain/Task.java index 55fb00d..7daa738 100644 --- a/assignment/src/main/java/ch/unisg/assignment/assignment/domain/Task.java +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/domain/Task.java @@ -30,6 +30,6 @@ public class Task { this.taskType = taskType; } - public Task() {}; + public Task() {} } diff --git a/assignment/src/main/java/ch/unisg/assignment/assignment/domain/event/TaskAssignedEvent.java b/assignment/src/main/java/ch/unisg/assignment/assignment/domain/event/TaskAssignedEvent.java index ef20f43..d0178d4 100644 --- a/assignment/src/main/java/ch/unisg/assignment/assignment/domain/event/TaskAssignedEvent.java +++ b/assignment/src/main/java/ch/unisg/assignment/assignment/domain/event/TaskAssignedEvent.java @@ -1,7 +1,7 @@ package ch.unisg.assignment.assignment.domain.event; public class TaskAssignedEvent { - public String taskID; + public final String taskID; public TaskAssignedEvent(String taskID) { this.taskID = taskID; From 812f763620002a3c320ffffde203eca2de659baf Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 17 Oct 2021 11:01:38 +0200 Subject: [PATCH 13/17] removed sonar config from executor base pom --- executor-base/pom.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/executor-base/pom.xml b/executor-base/pom.xml index 32ec88a..96dec99 100644 --- a/executor-base/pom.xml +++ b/executor-base/pom.xml @@ -15,8 +15,6 @@ Demo project for Spring Boot 11 - scs-asse-fs21-group1 - https://sonarcloud.io From 6cb52ba0c65ed1009a60cdc87ee4332236991b54 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 17 Oct 2021 11:07:34 +0200 Subject: [PATCH 14/17] Added placeholder bean --- .../service/TaskAvailableService.java | 20 +++++++++++++++++++ .../service/TaskAvailableService.java | 2 -- 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 executor-base/src/main/java/ch/unisg/executorBase/executor/application/service/TaskAvailableService.java diff --git a/executor-base/src/main/java/ch/unisg/executorBase/executor/application/service/TaskAvailableService.java b/executor-base/src/main/java/ch/unisg/executorBase/executor/application/service/TaskAvailableService.java new file mode 100644 index 0000000..a4f5e6e --- /dev/null +++ b/executor-base/src/main/java/ch/unisg/executorBase/executor/application/service/TaskAvailableService.java @@ -0,0 +1,20 @@ +package ch.unisg.executorBase.executor.application.service; + +import org.springframework.stereotype.Component; + +import ch.unisg.executorBase.executor.application.port.in.TaskAvailableCommand; +import ch.unisg.executorBase.executor.application.port.in.TaskAvailableUseCase; +import lombok.RequiredArgsConstructor; + +import javax.transaction.Transactional; + +@RequiredArgsConstructor +@Component +@Transactional +public class TaskAvailableService implements TaskAvailableUseCase { + + @Override + public void newTaskAvailable(TaskAvailableCommand command) { + // Placeholder so spring can create a bean + } +} diff --git a/executor2/src/main/java/ch/unisg/executor2/executor/application/service/TaskAvailableService.java b/executor2/src/main/java/ch/unisg/executor2/executor/application/service/TaskAvailableService.java index 39db6ab..6fa918d 100644 --- a/executor2/src/main/java/ch/unisg/executor2/executor/application/service/TaskAvailableService.java +++ b/executor2/src/main/java/ch/unisg/executor2/executor/application/service/TaskAvailableService.java @@ -1,6 +1,5 @@ package ch.unisg.executor2.executor.application.service; -import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Component; import ch.unisg.executor2.executor.domain.Executor; @@ -17,7 +16,6 @@ import javax.transaction.Transactional; public class TaskAvailableService implements TaskAvailableUseCase { @Override - @Async public void newTaskAvailable(TaskAvailableCommand command) { Executor executor = Executor.getExecutor(); From d1d584bf6c5b1e56adcd83591fd119b36c66bf9d Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 17 Oct 2021 12:12:29 +0200 Subject: [PATCH 15/17] build error fixes --- executor-base/pom.xml | 17 ----------------- .../out/web/ExecutionFinishedEventAdapter.java | 7 +++++-- .../adapter/out/web/GetAssignmentAdapter.java | 7 +++++-- executor2/pom.xml | 1 + 4 files changed, 11 insertions(+), 21 deletions(-) diff --git a/executor-base/pom.xml b/executor-base/pom.xml index 96dec99..2acba18 100644 --- a/executor-base/pom.xml +++ b/executor-base/pom.xml @@ -62,21 +62,4 @@ - - - - org.springframework.boot - spring-boot-maven-plugin - - - - org.projectlombok - lombok - - - - - - - diff --git a/executor-base/src/main/java/ch/unisg/executorBase/executor/adapter/out/web/ExecutionFinishedEventAdapter.java b/executor-base/src/main/java/ch/unisg/executorBase/executor/adapter/out/web/ExecutionFinishedEventAdapter.java index 7408740..fd26d47 100644 --- a/executor-base/src/main/java/ch/unisg/executorBase/executor/adapter/out/web/ExecutionFinishedEventAdapter.java +++ b/executor-base/src/main/java/ch/unisg/executorBase/executor/adapter/out/web/ExecutionFinishedEventAdapter.java @@ -5,6 +5,8 @@ import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; +import java.util.logging.Level; +import java.util.logging.Logger; import org.json.JSONObject; @@ -13,9 +15,10 @@ import ch.unisg.executorBase.executor.domain.ExecutionFinishedEvent; public class ExecutionFinishedEventAdapter implements ExecutionFinishedEventPort { - //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"; + Logger logger = Logger.getLogger(ExecutionFinishedEventAdapter.class.getName()); + @Override public void publishExecutionFinishedEvent(ExecutionFinishedEvent event) { @@ -35,7 +38,7 @@ public class ExecutionFinishedEventAdapter implements ExecutionFinishedEventPort try { client.send(request, HttpResponse.BodyHandlers.ofString()); } catch (IOException | InterruptedException e) { - e.printStackTrace(); + logger.log(Level.SEVERE, e.getLocalizedMessage(), e); // Restore interrupted state... Thread.currentThread().interrupt(); } diff --git a/executor-base/src/main/java/ch/unisg/executorBase/executor/adapter/out/web/GetAssignmentAdapter.java b/executor-base/src/main/java/ch/unisg/executorBase/executor/adapter/out/web/GetAssignmentAdapter.java index b558075..05852fa 100644 --- a/executor-base/src/main/java/ch/unisg/executorBase/executor/adapter/out/web/GetAssignmentAdapter.java +++ b/executor-base/src/main/java/ch/unisg/executorBase/executor/adapter/out/web/GetAssignmentAdapter.java @@ -5,6 +5,8 @@ import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; +import java.util.logging.Level; +import java.util.logging.Logger; import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Component; @@ -19,9 +21,10 @@ import org.json.JSONObject; @Primary public class GetAssignmentAdapter implements GetAssignmentPort { - //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"; + Logger logger = Logger.getLogger(GetAssignmentAdapter.class.getName()); + @Override public Task getAssignment(ExecutorType executorType, String ip, int port) { @@ -47,7 +50,7 @@ public class GetAssignmentAdapter implements GetAssignmentPort { return new Task(new JSONObject(response.body()).getString("taskID")); } catch (IOException | InterruptedException e) { - e.printStackTrace(); + logger.log(Level.SEVERE, e.getLocalizedMessage(), e); // Restore interrupted state... Thread.currentThread().interrupt(); } diff --git a/executor2/pom.xml b/executor2/pom.xml index 86634c6..1f970e0 100644 --- a/executor2/pom.xml +++ b/executor2/pom.xml @@ -44,6 +44,7 @@ ch.unisg executorBase 0.0.1-SNAPSHOT + compile From 35f7ad67f776bd0d981687278222d6cee213a68a Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 17 Oct 2021 12:14:01 +0200 Subject: [PATCH 16/17] ci build fixes --- .github/workflows/ci.executor1.yml | 2 +- .github/workflows/ci.executor2.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.executor1.yml b/.github/workflows/ci.executor1.yml index 5d48580..708d7d4 100644 --- a/.github/workflows/ci.executor1.yml +++ b/.github/workflows/ci.executor1.yml @@ -37,7 +37,7 @@ jobs: key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} restore-keys: ${{ runner.os }}-m2 - name: Build executorBase - run: mvn -f executor-base/pom.xml -B verify + run: mvn -f executor-base/pom.xml -B install - name: Build and analyze env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/ci.executor2.yml b/.github/workflows/ci.executor2.yml index 32a59a8..5ae38f0 100644 --- a/.github/workflows/ci.executor2.yml +++ b/.github/workflows/ci.executor2.yml @@ -37,7 +37,7 @@ jobs: key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} restore-keys: ${{ runner.os }}-m2 - name: Build executorBase - run: mvn -f executor-base/pom.xml -B verify + run: mvn -f executor-base/pom.xml -B install - name: Build and analyze env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 4ee640e6888796cefa8b0a640ef2648aa598f771 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 17 Oct 2021 12:29:18 +0200 Subject: [PATCH 17/17] Added missing class and chaged port --- .../in/web/TaskAvailableController.java | 36 +++++++++++++++++++ .../src/main/resources/application.properties | 2 +- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 executor1/src/main/java/ch/unisg/executor1/executor/adapter/in/web/TaskAvailableController.java diff --git a/executor1/src/main/java/ch/unisg/executor1/executor/adapter/in/web/TaskAvailableController.java b/executor1/src/main/java/ch/unisg/executor1/executor/adapter/in/web/TaskAvailableController.java new file mode 100644 index 0000000..5501885 --- /dev/null +++ b/executor1/src/main/java/ch/unisg/executor1/executor/adapter/in/web/TaskAvailableController.java @@ -0,0 +1,36 @@ +package ch.unisg.executor1.executor.adapter.in.web; + +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +import ch.unisg.executorBase.executor.application.port.in.TaskAvailableCommand; +import ch.unisg.executorBase.executor.application.port.in.TaskAvailableUseCase; +import ch.unisg.executorBase.executor.domain.ExecutorType; + +@RestController +public class TaskAvailableController { + private final TaskAvailableUseCase taskAvailableUseCase; + + public TaskAvailableController(TaskAvailableUseCase taskAvailableUseCase) { + this.taskAvailableUseCase = taskAvailableUseCase; + } + + @GetMapping(path = "/newtask/{taskType}") + public ResponseEntity retrieveTaskFromTaskList(@PathVariable("taskType") String taskType) { + + if (ExecutorType.contains(taskType.toUpperCase())) { + TaskAvailableCommand command = new TaskAvailableCommand( + ExecutorType.valueOf(taskType.toUpperCase())); + taskAvailableUseCase.newTaskAvailable(command); + } + + // Add the content type as a response header + HttpHeaders responseHeaders = new HttpHeaders(); + + return new ResponseEntity<>("OK", responseHeaders, HttpStatus.OK); + } +} diff --git a/executor1/src/main/resources/application.properties b/executor1/src/main/resources/application.properties index 4d360de..5e3bb81 100644 --- a/executor1/src/main/resources/application.properties +++ b/executor1/src/main/resources/application.properties @@ -1 +1 @@ -server.port=8081 +server.port=8084