diff --git a/executor-pool/pom.xml b/executor-pool/pom.xml
index dea007e..59d5b2a 100644
--- a/executor-pool/pom.xml
+++ b/executor-pool/pom.xml
@@ -45,7 +45,27 @@
json
20210307
-
+
+ javax.validation
+ validation-api
+ compile
+
+
+ jakarta.validation
+ jakarta.validation-api
+
+
+ ch.unisg
+ tapas-tasks
+ 0.0.1-SNAPSHOT
+ compile
+
+
+ javax.transaction
+ javax.transaction-api
+ compile
+
+
diff --git a/executor-pool/src/main/java/ch/unisg/executorpool/adapter/in/web/AddNewExecutorToExecutorPoolWebController.java b/executor-pool/src/main/java/ch/unisg/executorpool/adapter/in/web/AddNewExecutorToExecutorPoolWebController.java
new file mode 100644
index 0000000..7967b6b
--- /dev/null
+++ b/executor-pool/src/main/java/ch/unisg/executorpool/adapter/in/web/AddNewExecutorToExecutorPoolWebController.java
@@ -0,0 +1,40 @@
+package ch.unisg.executorpool.adapter.in.web;
+
+import ch.unisg.executorpool.application.port.in.AddNewExecutorToExecutorPoolUseCase;
+import ch.unisg.executorpool.application.port.in.AddNewExecutorToExecutorPoolCommand;
+import ch.unisg.executorpool.domain.ExecutorClass;
+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 AddNewExecutorToExecutorPoolWebController {
+ private final AddNewExecutorToExecutorPoolUseCase addNewExecutorToExecutorPoolUseCase;
+
+ public AddNewExecutorToExecutorPoolWebController(AddNewExecutorToExecutorPoolUseCase addNewExecutorToExecutorPoolUseCase){
+ this.addNewExecutorToExecutorPoolUseCase = addNewExecutorToExecutorPoolUseCase;
+ }
+
+ @PostMapping(path = "/executor-pool/AddExecutor", consumes = {ExecutorMediaType.EXECUTOR_MEDIA_TYPE})
+ public ResponseEntity addNewExecutorToExecutorPool(@RequestBody ExecutorClass executorClass){
+ try{
+ AddNewExecutorToExecutorPoolCommand command = new AddNewExecutorToExecutorPoolCommand(
+ executorClass.getExecutorIp(), executorClass.getExecutorPort(), executorClass.getExecutorTaskType()
+ );
+
+ ExecutorClass newExecutor = addNewExecutorToExecutorPoolUseCase.addNewExecutorToExecutorPool(command);
+
+ HttpHeaders responseHeaders = new HttpHeaders();
+ responseHeaders.add(HttpHeaders.CONTENT_TYPE, ExecutorMediaType.EXECUTOR_MEDIA_TYPE);
+
+ return new ResponseEntity<>(ExecutorMediaType.serialize(newExecutor), responseHeaders, HttpStatus.CREATED);
+ } catch (ConstraintViolationException e){
+ throw new ResponseStatusException(HttpStatus.BAD_REQUEST, e.getMessage());
+ }
+ }
+}
diff --git a/executor-pool/src/main/java/ch/unisg/executorpool/adapter/in/web/ExecutorMediaType.java b/executor-pool/src/main/java/ch/unisg/executorpool/adapter/in/web/ExecutorMediaType.java
new file mode 100644
index 0000000..cbbc33b
--- /dev/null
+++ b/executor-pool/src/main/java/ch/unisg/executorpool/adapter/in/web/ExecutorMediaType.java
@@ -0,0 +1,33 @@
+package ch.unisg.executorpool.adapter.in.web;
+
+import ch.unisg.executorpool.domain.ExecutorClass;
+import org.json.JSONArray;
+import org.json.JSONObject;
+
+import java.util.List;
+
+final public class ExecutorMediaType {
+ public static final String EXECUTOR_MEDIA_TYPE = "application/json";
+
+ public static String serialize(ExecutorClass executorClass) {
+ JSONObject payload = new JSONObject();
+
+ payload.put("executorIp", executorClass.getExecutorIp().getValue());
+ payload.put("executorPort", executorClass.getExecutorPort().getValue());
+ payload.put("executorTaskType", executorClass.getExecutorTaskType().getValue());
+
+ return payload.toString();
+ }
+
+ public static String serialize(List listOfExecutors) {
+ String serializedList = "[ \n";
+
+ for (ExecutorClass executor: listOfExecutors) {
+ serializedList += serialize(executor) + ",\n";
+ }
+
+ return serializedList + "\n ]";
+ }
+
+ private ExecutorMediaType() { }
+}
diff --git a/executor-pool/src/main/java/ch/unisg/executorpool/adapter/in/web/GetAllExecutorInExecutorPoolByTypeWebController.java b/executor-pool/src/main/java/ch/unisg/executorpool/adapter/in/web/GetAllExecutorInExecutorPoolByTypeWebController.java
new file mode 100644
index 0000000..2595781
--- /dev/null
+++ b/executor-pool/src/main/java/ch/unisg/executorpool/adapter/in/web/GetAllExecutorInExecutorPoolByTypeWebController.java
@@ -0,0 +1,35 @@
+package ch.unisg.executorpool.adapter.in.web;
+
+import ch.unisg.executorpool.application.port.in.GetAllExecutorInExecutorPoolByTypeQuery;
+import ch.unisg.executorpool.application.port.in.GetAllExecutorInExecutorPoolByTypeUseCase;
+import ch.unisg.executorpool.domain.ExecutorClass;
+import ch.unisg.executorpool.domain.ExecutorClass.ExecutorTaskType;
+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 java.util.List;
+
+@RestController
+public class GetAllExecutorInExecutorPoolByTypeWebController {
+ private final GetAllExecutorInExecutorPoolByTypeUseCase getAllExecutorInExecutorPoolByTypeUseCase;
+
+ public GetAllExecutorInExecutorPoolByTypeWebController(GetAllExecutorInExecutorPoolByTypeUseCase getAllExecutorInExecutorPoolByTypeUseCase){
+ this.getAllExecutorInExecutorPoolByTypeUseCase = getAllExecutorInExecutorPoolByTypeUseCase;
+ }
+
+ @GetMapping(path = "/executor-pool/GetAllExecutorInExecutorPoolByType/{taskType}")
+ public ResponseEntity getAllExecutorInExecutorPoolByType(@PathVariable("taskType") String taskType){
+ GetAllExecutorInExecutorPoolByTypeQuery query = new GetAllExecutorInExecutorPoolByTypeQuery(new ExecutorTaskType(taskType));
+ List matchedExecutors = getAllExecutorInExecutorPoolByTypeUseCase.getAllExecutorInExecutorPoolByType(query);
+
+ // Add the content type as a response header
+ HttpHeaders responseHeaders = new HttpHeaders();
+ responseHeaders.add(HttpHeaders.CONTENT_TYPE, ExecutorMediaType.EXECUTOR_MEDIA_TYPE);
+
+ return new ResponseEntity<>(ExecutorMediaType.serialize(matchedExecutors), responseHeaders, HttpStatus.OK);
+ }
+}
diff --git a/executor-pool/src/main/java/ch/unisg/executorpool/adapter/in/web/GetAllExecutorsInExecutorPoolWebController.java b/executor-pool/src/main/java/ch/unisg/executorpool/adapter/in/web/GetAllExecutorsInExecutorPoolWebController.java
new file mode 100644
index 0000000..ada219c
--- /dev/null
+++ b/executor-pool/src/main/java/ch/unisg/executorpool/adapter/in/web/GetAllExecutorsInExecutorPoolWebController.java
@@ -0,0 +1,32 @@
+package ch.unisg.executorpool.adapter.in.web;
+
+import ch.unisg.executorpool.application.port.in.GetAllExecutorsInExecutorPoolUseCase;
+import ch.unisg.executorpool.domain.ExecutorClass;
+import ch.unisg.tapastasks.tasks.adapter.in.web.TaskMediaType;
+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.RestController;
+
+import java.util.List;
+
+@RestController
+public class GetAllExecutorsInExecutorPoolWebController {
+ private final GetAllExecutorsInExecutorPoolUseCase getAllExecutorsInExecutorPoolUseCase;
+
+ public GetAllExecutorsInExecutorPoolWebController(GetAllExecutorsInExecutorPoolUseCase getAllExecutorsInExecutorPoolUseCase){
+ this.getAllExecutorsInExecutorPoolUseCase = getAllExecutorsInExecutorPoolUseCase;
+ }
+
+ @GetMapping(path = "executor-pool/GetAllExecutorsinExecutorPool")
+ public ResponseEntity getAllExecutorsInExecutorPool(){
+ List executorClassList = getAllExecutorsInExecutorPoolUseCase.getAllExecutorsInExecutorPool();
+
+ // Add the content type as a response header
+ HttpHeaders responseHeaders = new HttpHeaders();
+ responseHeaders.add(HttpHeaders.CONTENT_TYPE, ExecutorMediaType.EXECUTOR_MEDIA_TYPE);
+
+ return new ResponseEntity<>(ExecutorMediaType.serialize(executorClassList), responseHeaders, HttpStatus.OK);
+ }
+}
diff --git a/executor-pool/src/main/java/ch/unisg/executorpool/adapter/in/web/RemoveExecutorFromExecutorPoolWebController.java b/executor-pool/src/main/java/ch/unisg/executorpool/adapter/in/web/RemoveExecutorFromExecutorPoolWebController.java
new file mode 100644
index 0000000..69bbde3
--- /dev/null
+++ b/executor-pool/src/main/java/ch/unisg/executorpool/adapter/in/web/RemoveExecutorFromExecutorPoolWebController.java
@@ -0,0 +1,39 @@
+package ch.unisg.executorpool.adapter.in.web;
+
+import ch.unisg.executorpool.application.port.in.RemoveExecutorFromExecutorPoolCommand;
+import ch.unisg.executorpool.application.port.in.RemoveExecutorFromExecutorPoolUseCase;
+import ch.unisg.executorpool.domain.ExecutorClass;
+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 java.util.Optional;
+
+@RestController
+public class RemoveExecutorFromExecutorPoolWebController {
+ private final RemoveExecutorFromExecutorPoolUseCase removeExecutorFromExecutorPoolUseCase;
+
+ public RemoveExecutorFromExecutorPoolWebController(RemoveExecutorFromExecutorPoolUseCase removeExecutorFromExecutorPoolUseCase){
+ this.removeExecutorFromExecutorPoolUseCase = removeExecutorFromExecutorPoolUseCase;
+ }
+
+ @PostMapping(path = "/executor-pool/RemoveExecutor", consumes = {ExecutorMediaType.EXECUTOR_MEDIA_TYPE})
+ public ResponseEntity removeExecutorFromExecutorPool(@RequestBody ExecutorClass executorClass){
+ RemoveExecutorFromExecutorPoolCommand command = new RemoveExecutorFromExecutorPoolCommand(executorClass.getExecutorIp(), executorClass.getExecutorPort());
+ Optional removedExecutor = removeExecutorFromExecutorPoolUseCase.removeExecutorFromExecutorPool(command);
+
+ if(removedExecutor.isEmpty()){
+ throw new ResponseStatusException(HttpStatus.NOT_FOUND);
+ }
+
+ HttpHeaders responseHeaders = new HttpHeaders();
+ responseHeaders.add(HttpHeaders.CONTENT_TYPE, ExecutorMediaType.EXECUTOR_MEDIA_TYPE);
+
+ return new ResponseEntity<>(ExecutorMediaType.serialize(removedExecutor.get()), responseHeaders,
+ HttpStatus.OK);
+ }
+}
diff --git a/executor-pool/src/main/java/ch/unisg/executorpool/application/port/in/AddNewExecutorToExecutorPoolCommand.java b/executor-pool/src/main/java/ch/unisg/executorpool/application/port/in/AddNewExecutorToExecutorPoolCommand.java
new file mode 100644
index 0000000..26b495e
--- /dev/null
+++ b/executor-pool/src/main/java/ch/unisg/executorpool/application/port/in/AddNewExecutorToExecutorPoolCommand.java
@@ -0,0 +1,28 @@
+package ch.unisg.executorpool.application.port.in;
+
+import ch.unisg.executorpool.domain.ExecutorPool;
+import ch.unisg.tapastasks.common.SelfValidating;
+import ch.unisg.executorpool.domain.ExecutorClass.ExecutorIp;
+import ch.unisg.executorpool.domain.ExecutorClass.ExecutorPort;
+import ch.unisg.executorpool.domain.ExecutorClass.ExecutorTaskType;
+import lombok.Value;
+import javax.validation.constraints.NotNull;
+
+@Value
+public class AddNewExecutorToExecutorPoolCommand extends SelfValidating {
+ @NotNull
+ private final ExecutorIp executorIp;
+
+ @NotNull
+ private final ExecutorPort executorPort;
+
+ @NotNull
+ private final ExecutorTaskType executorTaskType;
+
+ public AddNewExecutorToExecutorPoolCommand(ExecutorIp executorIp, ExecutorPort executorPort, ExecutorTaskType executorTaskType){
+ this.executorIp = executorIp;
+ this.executorPort = executorPort;
+ this.executorTaskType = executorTaskType;
+ this.validateSelf();
+ }
+}
diff --git a/executor-pool/src/main/java/ch/unisg/executorpool/application/port/in/AddNewExecutorToExecutorPoolUseCase.java b/executor-pool/src/main/java/ch/unisg/executorpool/application/port/in/AddNewExecutorToExecutorPoolUseCase.java
new file mode 100644
index 0000000..51b28ba
--- /dev/null
+++ b/executor-pool/src/main/java/ch/unisg/executorpool/application/port/in/AddNewExecutorToExecutorPoolUseCase.java
@@ -0,0 +1,7 @@
+package ch.unisg.executorpool.application.port.in;
+
+import ch.unisg.executorpool.domain.ExecutorClass;
+
+public interface AddNewExecutorToExecutorPoolUseCase {
+ ExecutorClass addNewExecutorToExecutorPool(AddNewExecutorToExecutorPoolCommand command);
+}
diff --git a/executor-pool/src/main/java/ch/unisg/executorpool/application/port/in/GetAllExecutorInExecutorPoolByTypeQuery.java b/executor-pool/src/main/java/ch/unisg/executorpool/application/port/in/GetAllExecutorInExecutorPoolByTypeQuery.java
new file mode 100644
index 0000000..509dba5
--- /dev/null
+++ b/executor-pool/src/main/java/ch/unisg/executorpool/application/port/in/GetAllExecutorInExecutorPoolByTypeQuery.java
@@ -0,0 +1,18 @@
+package ch.unisg.executorpool.application.port.in;
+
+import ch.unisg.executorpool.domain.ExecutorClass.ExecutorTaskType;
+import ch.unisg.tapastasks.common.SelfValidating;
+import lombok.Value;
+
+import javax.validation.constraints.NotNull;
+
+@Value
+public class GetAllExecutorInExecutorPoolByTypeQuery extends SelfValidating {
+ @NotNull
+ private final ExecutorTaskType executorTaskType;
+
+ public GetAllExecutorInExecutorPoolByTypeQuery(ExecutorTaskType executorTaskType){
+ this.executorTaskType = executorTaskType;
+ this.validateSelf();
+ }
+}
diff --git a/executor-pool/src/main/java/ch/unisg/executorpool/application/port/in/GetAllExecutorInExecutorPoolByTypeUseCase.java b/executor-pool/src/main/java/ch/unisg/executorpool/application/port/in/GetAllExecutorInExecutorPoolByTypeUseCase.java
new file mode 100644
index 0000000..9f612bf
--- /dev/null
+++ b/executor-pool/src/main/java/ch/unisg/executorpool/application/port/in/GetAllExecutorInExecutorPoolByTypeUseCase.java
@@ -0,0 +1,9 @@
+package ch.unisg.executorpool.application.port.in;
+
+import ch.unisg.executorpool.domain.ExecutorClass;
+
+import java.util.List;
+
+public interface GetAllExecutorInExecutorPoolByTypeUseCase {
+ List getAllExecutorInExecutorPoolByType(GetAllExecutorInExecutorPoolByTypeQuery query);
+}
diff --git a/executor-pool/src/main/java/ch/unisg/executorpool/application/port/in/GetAllExecutorsInExecutorPoolUseCase.java b/executor-pool/src/main/java/ch/unisg/executorpool/application/port/in/GetAllExecutorsInExecutorPoolUseCase.java
new file mode 100644
index 0000000..b7f2eb7
--- /dev/null
+++ b/executor-pool/src/main/java/ch/unisg/executorpool/application/port/in/GetAllExecutorsInExecutorPoolUseCase.java
@@ -0,0 +1,10 @@
+package ch.unisg.executorpool.application.port.in;
+
+import ch.unisg.executorpool.domain.ExecutorClass;
+import ch.unisg.executorpool.domain.ExecutorPool;
+
+import java.util.List;
+
+public interface GetAllExecutorsInExecutorPoolUseCase {
+ List getAllExecutorsInExecutorPool();
+}
diff --git a/executor-pool/src/main/java/ch/unisg/executorpool/application/port/in/RemoveExecutorFromExecutorPoolCommand.java b/executor-pool/src/main/java/ch/unisg/executorpool/application/port/in/RemoveExecutorFromExecutorPoolCommand.java
new file mode 100644
index 0000000..a35b9ed
--- /dev/null
+++ b/executor-pool/src/main/java/ch/unisg/executorpool/application/port/in/RemoveExecutorFromExecutorPoolCommand.java
@@ -0,0 +1,24 @@
+package ch.unisg.executorpool.application.port.in;
+
+import ch.unisg.executorpool.domain.ExecutorClass;
+import ch.unisg.tapastasks.common.SelfValidating;
+import ch.unisg.executorpool.domain.ExecutorClass.ExecutorIp;
+import ch.unisg.executorpool.domain.ExecutorClass.ExecutorPort;
+import lombok.Value;
+
+import javax.validation.constraints.NotNull;
+
+@Value
+public class RemoveExecutorFromExecutorPoolCommand extends SelfValidating {
+ @NotNull
+ private final ExecutorIp executorIp;
+
+ @NotNull
+ private final ExecutorPort executorPort;
+
+ public RemoveExecutorFromExecutorPoolCommand(ExecutorIp executorIp, ExecutorPort executorPort){
+ this.executorIp = executorIp;
+ this.executorPort = executorPort;
+ this.validateSelf();
+ }
+}
diff --git a/executor-pool/src/main/java/ch/unisg/executorpool/application/port/in/RemoveExecutorFromExecutorPoolUseCase.java b/executor-pool/src/main/java/ch/unisg/executorpool/application/port/in/RemoveExecutorFromExecutorPoolUseCase.java
new file mode 100644
index 0000000..8b899e7
--- /dev/null
+++ b/executor-pool/src/main/java/ch/unisg/executorpool/application/port/in/RemoveExecutorFromExecutorPoolUseCase.java
@@ -0,0 +1,9 @@
+package ch.unisg.executorpool.application.port.in;
+
+import ch.unisg.executorpool.domain.ExecutorClass;
+
+import java.util.Optional;
+
+public interface RemoveExecutorFromExecutorPoolUseCase {
+ Optional removeExecutorFromExecutorPool(RemoveExecutorFromExecutorPoolCommand command);
+}
diff --git a/executor-pool/src/main/java/ch/unisg/executorpool/application/service/AddNewExecutorToExecutorPoolService.java b/executor-pool/src/main/java/ch/unisg/executorpool/application/service/AddNewExecutorToExecutorPoolService.java
new file mode 100644
index 0000000..e1ef237
--- /dev/null
+++ b/executor-pool/src/main/java/ch/unisg/executorpool/application/service/AddNewExecutorToExecutorPoolService.java
@@ -0,0 +1,25 @@
+package ch.unisg.executorpool.application.service;
+
+import ch.unisg.executorpool.application.port.in.AddNewExecutorToExecutorPoolUseCase;
+import ch.unisg.executorpool.application.port.in.AddNewExecutorToExecutorPoolCommand;
+import ch.unisg.executorpool.domain.ExecutorClass;
+import ch.unisg.executorpool.domain.ExecutorPool;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Component;
+import org.yaml.snakeyaml.constructor.DuplicateKeyException;
+
+import javax.transaction.Transactional;
+import javax.validation.ConstraintViolationException;
+
+@RequiredArgsConstructor
+@Component
+@Transactional
+public class AddNewExecutorToExecutorPoolService implements AddNewExecutorToExecutorPoolUseCase {
+
+ @Override
+ public ExecutorClass addNewExecutorToExecutorPool(AddNewExecutorToExecutorPoolCommand command){
+ ExecutorPool executorPool = ExecutorPool.getExecutorPool();
+
+ return executorPool.addNewExecutor(command.getExecutorIp(), command.getExecutorPort(), command.getExecutorTaskType());
+ }
+}
diff --git a/executor-pool/src/main/java/ch/unisg/executorpool/application/service/GetAllExecutorInExecutorPoolByTypeService.java b/executor-pool/src/main/java/ch/unisg/executorpool/application/service/GetAllExecutorInExecutorPoolByTypeService.java
new file mode 100644
index 0000000..74988b2
--- /dev/null
+++ b/executor-pool/src/main/java/ch/unisg/executorpool/application/service/GetAllExecutorInExecutorPoolByTypeService.java
@@ -0,0 +1,24 @@
+package ch.unisg.executorpool.application.service;
+
+import ch.unisg.executorpool.application.port.in.GetAllExecutorInExecutorPoolByTypeQuery;
+import ch.unisg.executorpool.application.port.in.GetAllExecutorInExecutorPoolByTypeUseCase;
+import ch.unisg.executorpool.domain.ExecutorClass;
+import ch.unisg.executorpool.domain.ExecutorPool;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Component;
+
+import javax.transaction.Transactional;
+import java.util.List;
+
+@RequiredArgsConstructor
+@Component
+@Transactional
+public class GetAllExecutorInExecutorPoolByTypeService implements GetAllExecutorInExecutorPoolByTypeUseCase {
+
+ @Override
+ public List getAllExecutorInExecutorPoolByType(GetAllExecutorInExecutorPoolByTypeQuery query){
+ ExecutorPool executorPool = ExecutorPool.getExecutorPool();
+ return executorPool.getAllExecutorsByType(query.getExecutorTaskType());
+ }
+
+}
diff --git a/executor-pool/src/main/java/ch/unisg/executorpool/application/service/GetAllExecutorsInExecutorPoolService.java b/executor-pool/src/main/java/ch/unisg/executorpool/application/service/GetAllExecutorsInExecutorPoolService.java
new file mode 100644
index 0000000..589cf46
--- /dev/null
+++ b/executor-pool/src/main/java/ch/unisg/executorpool/application/service/GetAllExecutorsInExecutorPoolService.java
@@ -0,0 +1,22 @@
+package ch.unisg.executorpool.application.service;
+
+import ch.unisg.executorpool.application.port.in.GetAllExecutorsInExecutorPoolUseCase;
+import ch.unisg.executorpool.domain.ExecutorClass;
+import ch.unisg.executorpool.domain.ExecutorPool;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Component;
+
+import javax.transaction.Transactional;
+import java.util.List;
+
+@RequiredArgsConstructor
+@Component
+@Transactional
+public class GetAllExecutorsInExecutorPoolService implements GetAllExecutorsInExecutorPoolUseCase {
+
+ @Override
+ public List getAllExecutorsInExecutorPool(){
+ ExecutorPool executorPool = ExecutorPool.getExecutorPool();
+ return executorPool.getListOfExecutors().getValue();
+ }
+}
diff --git a/executor-pool/src/main/java/ch/unisg/executorpool/application/service/RemoveExecutorFromExecutorPoolService.java b/executor-pool/src/main/java/ch/unisg/executorpool/application/service/RemoveExecutorFromExecutorPoolService.java
new file mode 100644
index 0000000..639ba7f
--- /dev/null
+++ b/executor-pool/src/main/java/ch/unisg/executorpool/application/service/RemoveExecutorFromExecutorPoolService.java
@@ -0,0 +1,22 @@
+package ch.unisg.executorpool.application.service;
+
+import ch.unisg.executorpool.application.port.in.RemoveExecutorFromExecutorPoolCommand;
+import ch.unisg.executorpool.application.port.in.RemoveExecutorFromExecutorPoolUseCase;
+import ch.unisg.executorpool.domain.ExecutorClass;
+import ch.unisg.executorpool.domain.ExecutorPool;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Component;
+
+import javax.transaction.Transactional;
+import java.util.Optional;
+
+@RequiredArgsConstructor
+@Component
+@Transactional
+public class RemoveExecutorFromExecutorPoolService implements RemoveExecutorFromExecutorPoolUseCase {
+ @Override
+ public Optional removeExecutorFromExecutorPool(RemoveExecutorFromExecutorPoolCommand command){
+ ExecutorPool executorPool = ExecutorPool.getExecutorPool();
+ return executorPool.removeExecutorByIpAndPort(command.getExecutorIp(), command.getExecutorPort());
+ }
+}
diff --git a/executor-pool/src/main/java/ch/unisg/executorpool/domain/ExecutorClass.java b/executor-pool/src/main/java/ch/unisg/executorpool/domain/ExecutorClass.java
new file mode 100644
index 0000000..d1fca00
--- /dev/null
+++ b/executor-pool/src/main/java/ch/unisg/executorpool/domain/ExecutorClass.java
@@ -0,0 +1,42 @@
+package ch.unisg.executorpool.domain;
+
+import lombok.Getter;
+import lombok.Value;
+
+public class ExecutorClass {
+
+ @Getter
+ private final ExecutorIp executorIp;
+
+ @Getter
+ private final ExecutorPort executorPort;
+
+ @Getter
+ private final ExecutorTaskType executorTaskType;
+
+ public ExecutorClass(ExecutorIp executorIp, ExecutorPort executorPort, ExecutorTaskType executorTaskType){
+ this.executorIp = executorIp;
+ this.executorPort = executorPort;
+ this.executorTaskType = executorTaskType;
+ }
+
+ protected static ExecutorClass createExecutorClass(ExecutorIp executorIp, ExecutorPort executorPort, ExecutorTaskType executorTaskType){
+ System.out.println("New Task: " + executorIp.getValue() + " " + executorPort.getValue() + " " + executorTaskType.getValue());
+ return new ExecutorClass(executorIp, executorPort, executorTaskType);
+ }
+
+ @Value
+ public static class ExecutorIp {
+ private String value;
+ }
+
+ @Value
+ public static class ExecutorPort {
+ private String value;
+ }
+
+ @Value
+ public static class ExecutorTaskType {
+ private String value;
+ }
+}
diff --git a/executor-pool/src/main/java/ch/unisg/executorpool/domain/ExecutorPool.java b/executor-pool/src/main/java/ch/unisg/executorpool/domain/ExecutorPool.java
new file mode 100644
index 0000000..dd5375b
--- /dev/null
+++ b/executor-pool/src/main/java/ch/unisg/executorpool/domain/ExecutorPool.java
@@ -0,0 +1,74 @@
+package ch.unisg.executorpool.domain;
+
+import lombok.Getter;
+import lombok.Value;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Optional;
+
+public class ExecutorPool {
+
+ @Getter
+ private final ListOfExecutors listOfExecutors;
+
+ private static final ExecutorPool executorPool = new ExecutorPool();
+
+ private ExecutorPool(){
+ this.listOfExecutors = new ListOfExecutors(new LinkedList());
+ }
+
+ public static ExecutorPool getExecutorPool() { return executorPool; }
+
+ public ExecutorClass addNewExecutor(ExecutorClass.ExecutorIp executorIp, ExecutorClass.ExecutorPort executorPort, ExecutorClass.ExecutorTaskType executorTaskType){
+ ExecutorClass newExecutor = ExecutorClass.createExecutorClass(executorIp, executorPort, executorTaskType);
+ listOfExecutors.value.add(newExecutor);
+ System.out.println("Number of executors: " + listOfExecutors.value.size());
+ return newExecutor;
+ }
+
+ public Optional getExecutorByIpAndPort(ExecutorClass.ExecutorIp executorIp, ExecutorClass.ExecutorPort executorPort){
+
+ for (ExecutorClass executor : listOfExecutors.value ) {
+ // TODO can this be simplified by overwriting equals()?
+ if(executor.getExecutorIp().getValue().equalsIgnoreCase(executorIp.getValue()) &&
+ executor.getExecutorPort().getValue().equalsIgnoreCase(executorPort.getValue())){
+ return Optional.of(executor);
+ }
+ }
+
+ return Optional.empty();
+ }
+
+ public List getAllExecutorsByType(ExecutorClass.ExecutorTaskType executorTaskType){
+
+ List matchedExecutors = new LinkedList();
+
+ for (ExecutorClass executor : listOfExecutors.value ) {
+ // TODO can this be simplified by overwriting equals()?
+ if(executor.getExecutorTaskType().getValue().equalsIgnoreCase(executorTaskType.getValue())){
+ matchedExecutors.add(executor);
+ }
+ }
+
+ return matchedExecutors;
+ }
+
+ public Optional removeExecutorByIpAndPort(ExecutorClass.ExecutorIp executorIp, ExecutorClass.ExecutorPort executorPort){
+ for (ExecutorClass executor : listOfExecutors.value ) {
+ // TODO can this be simplified by overwriting equals()?
+ if(executor.getExecutorIp().getValue().equalsIgnoreCase(executorIp.getValue()) &&
+ executor.getExecutorPort().getValue().equalsIgnoreCase(executorPort.getValue())){
+ listOfExecutors.value.remove(executor);
+ return Optional.of(executor);
+ }
+ }
+
+ return Optional.empty();
+ }
+
+ @Value
+ public static class ListOfExecutors {
+ private List value;
+ }
+}
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 f1a6a8c..2aa360c 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,6 @@ 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(), newTask.getTaskId().getValue(), newTask.getTaskType().getValue());
newTaskAddedEventPort.publishNewTaskAddedEvent(newTaskAdded);
}