Merge pull request #65 from SCS-ASSE-FS21-Group1/dev

Dev
This commit is contained in:
Marcel 2021-11-16 19:13:59 +01:00 committed by GitHub
commit 98c38b4fcf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
295 changed files with 7924 additions and 1793 deletions

View File

@ -41,20 +41,35 @@ services:
- "traefik.http.routers.tapas-tasks.entryPoints=web,websecure"
- "traefik.http.routers.tapas-tasks.tls.certresolver=le"
assignment:
tapas-auction-house:
image: openjdk
command: "java -jar /data/assignment-0.0.1-SNAPSHOT.jar"
command: "java -jar /data/tapas-auction-house-0.0.1-SNAPSHOT.jar"
restart: unless-stopped
volumes:
- ./:/data/
labels:
- "traefik.enable=true"
- "traefik.http.routers.assignment.rule=Host(`assignment.${PUB_IP}.nip.io`)"
- "traefik.http.routers.assignment.service=assignment"
- "traefik.http.services.assignment.loadbalancer.server.port=8082"
- "traefik.http.routers.assignment.tls=true"
- "traefik.http.routers.assignment.entryPoints=web,websecure"
- "traefik.http.routers.assignment.tls.certresolver=le"
- "traefik.http.routers.tapas-auction-house.rule=Host(`tapas-auction-house.${PUB_IP}.nip.io`)"
- "traefik.http.routers.tapas-auction-house.service=tapas-auction-house"
- "traefik.http.services.tapas-auction-house.loadbalancer.server.port=8086"
- "traefik.http.routers.tapas-auction-house.tls=true"
- "traefik.http.routers.tapas-auction-house.entryPoints=web,websecure"
- "traefik.http.routers.tapas-auction-house.tls.certresolver=le"
roster:
image: openjdk
command: "java -jar /data/roster-0.0.1-SNAPSHOT.jar"
restart: unless-stopped
volumes:
- ./:/data/
labels:
- "traefik.enable=true"
- "traefik.http.routers.roster.rule=Host(`roster.${PUB_IP}.nip.io`)"
- "traefik.http.routers.roster.service=roster"
- "traefik.http.services.roster.loadbalancer.server.port=8082"
- "traefik.http.routers.roster.tls=true"
- "traefik.http.routers.roster.entryPoints=web,websecure"
- "traefik.http.routers.roster.tls.certresolver=le"
executor-pool:
image: openjdk
@ -71,38 +86,38 @@ services:
- "traefik.http.routers.executor-pool.entryPoints=web,websecure"
- "traefik.http.routers.executor-pool.tls.certresolver=le"
executor1:
executor-computation:
image: openjdk
command: "java -jar /data/executor1-0.0.1-SNAPSHOT.jar"
command: "java -jar /data/executor-computation-0.0.1-SNAPSHOT.jar"
restart: unless-stopped
depends_on:
- executor-pool
- assignment
- roster
volumes:
- ./:/data/
labels:
- "traefik.enable=true"
- "traefik.http.routers.executor1.rule=Host(`executor1.${PUB_IP}.nip.io`)"
- "traefik.http.routers.executor1.service=executor1"
- "traefik.http.services.executor1.loadbalancer.server.port=8084"
- "traefik.http.routers.executor1.tls=true"
- "traefik.http.routers.executor1.entryPoints=web,websecure"
- "traefik.http.routers.executor1.tls.certresolver=le"
- "traefik.http.routers.executor-computation.rule=Host(`executor-computation.${PUB_IP}.nip.io`)"
- "traefik.http.routers.executor-computation.service=executor-computation"
- "traefik.http.services.executor-computation.loadbalancer.server.port=8084"
- "traefik.http.routers.executor-computation.tls=true"
- "traefik.http.routers.executor-computation.entryPoints=web,websecure"
- "traefik.http.routers.executor-computation.tls.certresolver=le"
executor2:
executor-robot:
image: openjdk
command: "java -jar /data/executor2-0.0.1-SNAPSHOT.jar"
command: "java -jar /data/executor-robot-0.0.1-SNAPSHOT.jar"
restart: unless-stopped
depends_on:
- executor-pool
- assignment
- roster
volumes:
- ./:/data/
labels:
- "traefik.enable=true"
- "traefik.http.routers.executor2.rule=Host(`executor2.${PUB_IP}.nip.io`)"
- "traefik.http.routers.executor2.service=executor2"
- "traefik.http.services.executor2.loadbalancer.server.port=8085"
- "traefik.http.routers.executor2.tls=true"
- "traefik.http.routers.executor2.entryPoints=web,websecure"
- "traefik.http.routers.executor2.tls.certresolver=le"
- "traefik.http.routers.executor-robot.rule=Host(`executor-robot.${PUB_IP}.nip.io`)"
- "traefik.http.routers.executor-robot.service=executor-robot"
- "traefik.http.services.executor-robot.loadbalancer.server.port=8085"
- "traefik.http.routers.executor-robot.tls=true"
- "traefik.http.routers.executor-robot.entryPoints=web,websecure"
- "traefik.http.routers.executor-robot.tls.certresolver=le"

View File

@ -33,29 +33,36 @@ jobs:
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- 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
- name: Build common library
run: mvn -f common/pom.xml --batch-mode --update-snapshots install
- name: Build with Maven
- name: Build roster service
run: mvn -f roster/pom.xml --batch-mode --update-snapshots verify
- run: cp ./roster/target/roster-0.0.1-SNAPSHOT.jar ./target
- name: Build executor-pool service
run: mvn -f executor-pool/pom.xml --batch-mode --update-snapshots verify
- run: cp ./executor-pool/target/executor-pool-0.0.1-SNAPSHOT.jar ./target
- name: Build with Maven
- name: Build executor-base library
run: mvn -f executor-base/pom.xml --batch-mode --update-snapshots install
- name: Build with Maven
run: mvn -f executor1/pom.xml --batch-mode --update-snapshots verify
- run: cp ./executor1/target/executor1-0.0.1-SNAPSHOT.jar ./target
- name: Build executor-computation service
run: mvn -f executor-computation/pom.xml --batch-mode --update-snapshots verify
- run: cp ./executor-computation/target/executor-computation-0.0.1-SNAPSHOT.jar ./target
- name: Build with Maven
run: mvn -f executor2/pom.xml --batch-mode --update-snapshots verify
- run: cp ./executor2/target/executor2-0.0.1-SNAPSHOT.jar ./target
- name: Build executor-robot service
run: mvn -f executor-robot/pom.xml --batch-mode --update-snapshots verify
- run: cp ./executor-robot/target/executor-robot-0.0.1-SNAPSHOT.jar ./target
- name: Build with Maven
- name: Build tapas-task service
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: Build tapas-auction-house service
run: mvn -f tapas-auction-house/pom.xml --batch-mode --update-snapshots verify
- run: cp ./tapas-auction-house/target/tapas-auction-house-0.0.1-SNAPSHOT.jar ./target
- run: cp ./.deployment/docker-compose.yml ./target
- name: Archive artifacts
uses: actions/upload-artifact@v1

View File

@ -1,41 +0,0 @@
name: CI Assignment
on:
push:
branches: [main, dev]
paths:
- "assignment/**"
pull_request:
branches: [main, dev]
paths:
- "assignment/**"
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 assignment/pom.xml -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=scs-asse-fs21-group1_tapas-assignment

View File

@ -1,15 +1,17 @@
name: CI Executor 2
name: CI executor-computation
on:
push:
branches: [main, dev]
paths:
- "executor-base/**"
- "executor2/**"
- "executor-computation/**"
- "common/**"
pull_request:
branches: [main, dev]
paths:
- "executor-base/**"
- "executor2/**"
- "executor-computation/**"
- "common/**"
workflow_dispatch:
jobs:
@ -36,10 +38,12 @@ jobs:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build common
run: mvn -f common/pom.xml -B install
- name: Build executorBase
run: mvn -f executor-base/pom.xml -B install
- 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
run: mvn -f executor-computation/pom.xml -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=scs-asse-fs21-group1_tapas-executor2

View File

@ -1,15 +1,17 @@
name: CI Executor 1
name: CI executor-robot
on:
push:
branches: [main, dev]
paths:
- "executor-base/**"
- "executor1/**"
- "executor-robot/**"
- "common/**"
pull_request:
branches: [main, dev]
paths:
- "executor-base/**"
- "executor1/**"
- "executor-robot/**"
- "common/**"
workflow_dispatch:
jobs:
@ -36,10 +38,12 @@ jobs:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build executorBase
run: mvn -f common/pom.xml -B install
- name: Build executorBase
run: mvn -f executor-base/pom.xml -B install
- 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
run: mvn -f executor-robot/pom.xml -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=scs-asse-fs21-group1_tapas-executor1

45
.github/workflows/ci.roster.yml vendored Normal file
View File

@ -0,0 +1,45 @@
name: CI Roster
on:
push:
branches: [main, dev]
paths:
- "roster/**"
- "common/**"
pull_request:
branches: [main, dev]
paths:
- "roster/**"
- "common/**"
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 common package
run: mvn -f common/pom.xml -B install
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -f roster/pom.xml -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=scs-asse-fs21-group1_tapas-assignment

View File

@ -1,13 +0,0 @@
package ch.unisg.assignment;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class AssignmentApplication {
public static void main(String[] args) {
SpringApplication.run(AssignmentApplication.class, args);
}
}

View File

@ -1,31 +0,0 @@
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<ErrorResponse> handleException(PortOutOfRangeException e){
ErrorResponse error = new ErrorResponse(HttpStatus.BAD_REQUEST, e.getLocalizedMessage());
return new ResponseEntity<>(error, error.getHttpStatus());
}
@ExceptionHandler(InvalidIP4Exception.class)
public ResponseEntity<ErrorResponse> handleException(InvalidIP4Exception e){
ErrorResponse error = new ErrorResponse(HttpStatus.BAD_REQUEST, e.getLocalizedMessage());
return new ResponseEntity<>(error, error.getHttpStatus());
}
}

View File

@ -1,60 +0,0 @@
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 java.util.logging.Level;
import java.util.logging.Logger;
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.event.NewTaskEvent;
@Component
@Primary
public class PublishNewTaskEventAdapter implements NewTaskEventPort {
String server = "http://127.0.0.1:8084";
String server2 = "http://127.0.0.1:8085";
Logger logger = Logger.getLogger(PublishNewTaskEventAdapter.class.getName());
@Override
public void publishNewTaskEvent(NewTaskEvent event) {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(server + "/newtask/" + event.taskType.getValue()))
.GET()
.build();
try {
client.send(request, HttpResponse.BodyHandlers.ofString());
} catch (IOException | InterruptedException e) {
logger.log(Level.SEVERE, e.getLocalizedMessage(), e);
// Restore interrupted state...
Thread.currentThread().interrupt();
}
HttpClient client2 = HttpClient.newHttpClient();
HttpRequest request2 = HttpRequest.newBuilder()
.uri(URI.create(server2 + "/newtask/" + event.taskType.getValue()))
.GET()
.build();
try {
client.send(request, HttpResponse.BodyHandlers.ofString());
} catch (IOException | InterruptedException e) {
logger.log(Level.SEVERE, e.getLocalizedMessage(), e);
// Restore interrupted state...
Thread.currentThread().interrupt();
}
}
}

View File

@ -1,50 +0,0 @@
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 java.util.logging.Level;
import java.util.logging.Logger;
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.event.TaskAssignedEvent;
@Component
@Primary
public class PublishTaskAssignedEventAdapter implements TaskAssignedEventPort {
String server = "http://127.0.0.1:8081";
Logger logger = Logger.getLogger(PublishTaskAssignedEventAdapter.class.getName());
@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/assignTask"))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
try {
client.send(request, HttpResponse.BodyHandlers.ofString());
} catch (IOException | InterruptedException e) {
logger.log(Level.SEVERE, e.getLocalizedMessage(), e);
// Restore interrupted state...
Thread.currentThread().interrupt();
}
}
}

View File

@ -1,32 +0,0 @@
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;
@Value
@EqualsAndHashCode(callSuper=false)
public class ApplyForTaskCommand extends SelfValidating<ApplyForTaskCommand>{
@NotNull
private final ExecutorType taskType;
@NotNull
private final IP4Adress executorIP;
@NotNull
private final Port executorPort;
public ApplyForTaskCommand(ExecutorType taskType, IP4Adress executorIP, Port executorPort) {
this.taskType = taskType;
this.executorIP = executorIP;
this.executorPort = executorPort;
this.validateSelf();
}
}

View File

@ -1,7 +0,0 @@
package ch.unisg.assignment.assignment.application.port.in;
import ch.unisg.assignment.assignment.domain.Task;
public interface ApplyForTaskUseCase {
Task applyForTask(ApplyForTaskCommand applyForTaskCommand);
}

View File

@ -1,9 +0,0 @@
package ch.unisg.assignment.assignment.application.port.out;
import ch.unisg.assignment.assignment.domain.valueobject.ExecutorType;
public interface GetAllExecutorInExecutorPoolByTypePort {
boolean doesExecutorTypeExist(ExecutorType type);
}

View File

@ -1,7 +0,0 @@
package ch.unisg.assignment.assignment.application.port.out;
import ch.unisg.assignment.assignment.domain.event.NewTaskEvent;
public interface NewTaskEventPort {
void publishNewTaskEvent(NewTaskEvent event);
}

View File

@ -1,7 +0,0 @@
package ch.unisg.assignment.assignment.application.port.out;
import ch.unisg.assignment.assignment.domain.event.TaskAssignedEvent;
public interface TaskAssignedEventPort {
void publishTaskAssignedEvent(TaskAssignedEvent taskAssignedEvent);
}

View File

@ -1,7 +0,0 @@
package ch.unisg.assignment.assignment.application.port.out;
import ch.unisg.assignment.assignment.domain.event.TaskCompletedEvent;
public interface TaskCompletedEventPort {
void publishTaskCompleted(TaskCompletedEvent event);
}

View File

@ -1,34 +0,0 @@
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.event.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;
}
}

View File

@ -1,46 +0,0 @@
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.GetAllExecutorInExecutorPoolByTypePort;
import ch.unisg.assignment.assignment.application.port.out.NewTaskEventPort;
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
@Component
@Transactional
public class NewTaskService implements NewTaskUseCase {
private final NewTaskEventPort newTaskEventPort;
private final GetAllExecutorInExecutorPoolByTypePort getAllExecutorInExecutorPoolByTypePort;
@Override
public boolean addNewTaskToQueue(NewTaskCommand command) {
// TODO Get availableTaskTypes from executor pool
if (!getAllExecutorInExecutorPoolByTypePort.doesExecutorTypeExist(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;
}
}

View File

@ -1,21 +0,0 @@
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 IP4Adress ip;
@Getter
@Setter
private Port port;
@Getter
@Setter
private ExecutorType executorType;
}

View File

@ -1,53 +0,0 @@
package ch.unisg.assignment.assignment.domain;
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();
private HashMap<String, ArrayList<Task>> queues = new HashMap<>();
private HashMap<String, RosterItem> rosterMap = new HashMap<>();
public static Roster getInstance() {
return roster;
}
private Roster() {}
public void addTaskToQueue(Task task) {
if (queues.containsKey(task.getTaskType().getValue())) {
queues.get(task.getTaskType().getValue()).add(task);
} else {
queues.put(task.getTaskType().getValue(), new ArrayList<>(Arrays.asList(task)));
}
}
public Task assignTaskToExecutor(ExecutorType taskType, IP4Adress executorIP, Port executorPort) {
if (!queues.containsKey(taskType.getValue())) {
return null;
}
if (queues.get(taskType.getValue()).isEmpty()) {
return null;
}
Task task = queues.get(taskType.getValue()).remove(0);
rosterMap.put(task.getTaskID(), new RosterItem(task.getTaskID(),
task.getTaskType().getValue(), executorIP, executorPort));
return task;
}
public void taskCompleted(String taskID) {
rosterMap.remove(taskID);
}
}

View File

@ -1,29 +0,0 @@
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 {
@Getter
private String taskID;
@Getter
private String taskType;
@Getter
private IP4Adress executorIP;
@Getter
private Port executorPort;
public RosterItem(String taskID, String taskType, IP4Adress executorIP, Port executorPort) {
this.taskID = taskID;
this.taskType = taskType;
this.executorIP = executorIP;
this.executorPort = executorPort;
}
}

View File

@ -1,23 +0,0 @@
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();
}
}
}

View File

@ -1,17 +0,0 @@
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();
}
}
}

View File

@ -1,7 +0,0 @@
package ch.unisg.assignment.common.exception;
public class InvalidIP4Exception extends Exception {
public InvalidIP4Exception() {
super("IP4 is invalid");
}
}

View File

@ -1,7 +0,0 @@
package ch.unisg.assignment.common.exception;
public class PortOutOfRangeException extends Exception {
public PortOutOfRangeException() {
super("Port is out of available range (1024-65535)");
}
}

View File

@ -1 +0,0 @@
server.port=8082

View File

72
common/pom.xml Normal file
View File

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.5</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>ch.unisg</groupId>
<artifactId>common</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>common</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>javax.transaction-api</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20210307</version>
</dependency>
</dependencies>
</project>

View File

@ -1,4 +1,4 @@
package ch.unisg.assignment.common.exception;
package ch.unisg.common.exception;
import org.springframework.http.HttpStatus;

View File

@ -0,0 +1,7 @@
package ch.unisg.common.exception;
public class InvalidExecutorURIException extends Exception {
public InvalidExecutorURIException() {
super("URI is invalid");
}
}

View File

@ -1,4 +1,4 @@
package ch.unisg.assignment.common;
package ch.unisg.common.validation;
import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;

View File

@ -0,0 +1,13 @@
package ch.unisg.common.valueobject;
import java.net.URI;
import lombok.Value;
@Value
public class ExecutorURI {
private URI value;
public ExecutorURI(String uri) {
this.value = URI.create(uri);
}
}

View File

@ -1,653 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_0qxgodh" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.8.1" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.15.0">
<bpmn:collaboration id="Collaboration_0anvhsf">
<bpmn:participant id="Participant_0q8hukc" name="Create Task" processRef="Process_0g1u0dm" />
<bpmn:participant id="Participant_143daut" name="Executor Ideling" processRef="Process_0s8woey" />
<bpmn:participant id="Participant_1q0bjfl" name="Request more executors" processRef="Process_0p5wk5x" />
<bpmn:participant id="Participant_062djli" name="Executor Requests for work" processRef="Process_1iep78l" />
<bpmn:participant id="Participant_1ova0gb" name="Executor finish task" processRef="Process_102ufh8" />
<bpmn:messageFlow id="Flow_1xo6v1g" sourceRef="Activity_0u3tts0" targetRef="Activity_1q87dyp" />
</bpmn:collaboration>
<bpmn:process id="Process_0g1u0dm" isExecutable="false">
<bpmn:laneSet id="LaneSet_1lcmyw6">
<bpmn:lane id="Lane_1qeq039" name="Assignment Service">
<bpmn:flowNodeRef>Gateway_1vd3as7</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Activity_1jd11bs</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Gateway_1e4ckdq</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Activity_1dl4fvt</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Gateway_1e3rabp</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Event_1lm6x5y</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Event_1ysgenb</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Event_00rvb9o</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Activity_0u3tts0</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Activity_0vs4eam</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Activity_0mwpp9o</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Event_0v7hm2z</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Activity_0paecdb</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Activity_0srcl99</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Activity_0assw9c</bpmn:flowNodeRef>
</bpmn:lane>
<bpmn:lane id="Lane_12khd4k" name="Task Service">
<bpmn:flowNodeRef>Activity_0jai885</bpmn:flowNodeRef>
<bpmn:flowNodeRef>StartEvent_1</bpmn:flowNodeRef>
</bpmn:lane>
</bpmn:laneSet>
<bpmn:exclusiveGateway id="Gateway_1vd3as7">
<bpmn:incoming>Flow_1hc51tx</bpmn:incoming>
<bpmn:outgoing>Flow_1sajzlx</bpmn:outgoing>
<bpmn:outgoing>Flow_1ijfkpz</bpmn:outgoing>
</bpmn:exclusiveGateway>
<bpmn:task id="Activity_1jd11bs" name="Check if more tasks of the same are in a queue">
<bpmn:incoming>Flow_1sajzlx</bpmn:incoming>
<bpmn:outgoing>Flow_0cpd5ad</bpmn:outgoing>
</bpmn:task>
<bpmn:exclusiveGateway id="Gateway_1e4ckdq">
<bpmn:incoming>Flow_0cpd5ad</bpmn:incoming>
<bpmn:outgoing>Flow_0kwvrmc</bpmn:outgoing>
<bpmn:outgoing>Flow_1w3uh2m</bpmn:outgoing>
</bpmn:exclusiveGateway>
<bpmn:task id="Activity_1dl4fvt" name="Add task to queue">
<bpmn:incoming>Flow_0kwvrmc</bpmn:incoming>
<bpmn:outgoing>Flow_0vpcut0</bpmn:outgoing>
</bpmn:task>
<bpmn:exclusiveGateway id="Gateway_1e3rabp">
<bpmn:incoming>Flow_0vpcut0</bpmn:incoming>
<bpmn:outgoing>Flow_179e0hl</bpmn:outgoing>
<bpmn:outgoing>Flow_12nh0g5</bpmn:outgoing>
</bpmn:exclusiveGateway>
<bpmn:endEvent id="Event_1lm6x5y">
<bpmn:incoming>Flow_179e0hl</bpmn:incoming>
</bpmn:endEvent>
<bpmn:endEvent id="Event_1ysgenb">
<bpmn:incoming>Flow_0366zqm</bpmn:incoming>
</bpmn:endEvent>
<bpmn:endEvent id="Event_00rvb9o">
<bpmn:incoming>Flow_1n8jm89</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sendTask id="Activity_0u3tts0" name="Let executors know that there is work">
<bpmn:incoming>Flow_1w3uh2m</bpmn:incoming>
<bpmn:outgoing>Flow_1n8jm89</bpmn:outgoing>
</bpmn:sendTask>
<bpmn:task id="Activity_0jai885" name="Create Task">
<bpmn:incoming>Flow_19dbo28</bpmn:incoming>
<bpmn:outgoing>Flow_1rwgf2n</bpmn:outgoing>
</bpmn:task>
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>Flow_19dbo28</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:task id="Activity_0vs4eam" name="Request auctionshouse completion">
<bpmn:incoming>Flow_1ijfkpz</bpmn:incoming>
<bpmn:outgoing>Flow_1gvdy5x</bpmn:outgoing>
</bpmn:task>
<bpmn:task id="Activity_0mwpp9o" name="Some currently unknown Auctionhouse logic">
<bpmn:incoming>Flow_1gvdy5x</bpmn:incoming>
<bpmn:outgoing>Flow_1yxp4e8</bpmn:outgoing>
</bpmn:task>
<bpmn:endEvent id="Event_0v7hm2z">
<bpmn:incoming>Flow_1yxp4e8</bpmn:incoming>
</bpmn:endEvent>
<bpmn:task id="Activity_0paecdb" name="Checks if task can be handled internaly">
<bpmn:incoming>Flow_1rwgf2n</bpmn:incoming>
<bpmn:outgoing>Flow_1hc51tx</bpmn:outgoing>
</bpmn:task>
<bpmn:task id="Activity_0srcl99" name="(This can be checked here bc we are caching infos from the executor pool)" />
<bpmn:subProcess id="Activity_0assw9c" name="Request more executors">
<bpmn:incoming>Flow_12nh0g5</bpmn:incoming>
<bpmn:outgoing>Flow_0366zqm</bpmn:outgoing>
</bpmn:subProcess>
<bpmn:sequenceFlow id="Flow_1hc51tx" sourceRef="Activity_0paecdb" targetRef="Gateway_1vd3as7" />
<bpmn:sequenceFlow id="Flow_1sajzlx" name="Yes" sourceRef="Gateway_1vd3as7" targetRef="Activity_1jd11bs" />
<bpmn:sequenceFlow id="Flow_0cpd5ad" sourceRef="Activity_1jd11bs" targetRef="Gateway_1e4ckdq" />
<bpmn:sequenceFlow id="Flow_0kwvrmc" name="Yes" sourceRef="Gateway_1e4ckdq" targetRef="Activity_1dl4fvt" />
<bpmn:sequenceFlow id="Flow_0vpcut0" name="Are more than X tasks in queue?" sourceRef="Activity_1dl4fvt" targetRef="Gateway_1e3rabp" />
<bpmn:sequenceFlow id="Flow_179e0hl" name="No" sourceRef="Gateway_1e3rabp" targetRef="Event_1lm6x5y" />
<bpmn:sequenceFlow id="Flow_12nh0g5" name="Yes" sourceRef="Gateway_1e3rabp" targetRef="Activity_0assw9c" />
<bpmn:sequenceFlow id="Flow_0366zqm" sourceRef="Activity_0assw9c" targetRef="Event_1ysgenb" />
<bpmn:sequenceFlow id="Flow_1w3uh2m" name="No" sourceRef="Gateway_1e4ckdq" targetRef="Activity_0u3tts0" />
<bpmn:sequenceFlow id="Flow_1n8jm89" sourceRef="Activity_0u3tts0" targetRef="Event_00rvb9o" />
<bpmn:sequenceFlow id="Flow_1rwgf2n" sourceRef="Activity_0jai885" targetRef="Activity_0paecdb" />
<bpmn:sequenceFlow id="Flow_19dbo28" sourceRef="StartEvent_1" targetRef="Activity_0jai885" />
<bpmn:sequenceFlow id="Flow_1gvdy5x" sourceRef="Activity_0vs4eam" targetRef="Activity_0mwpp9o" />
<bpmn:sequenceFlow id="Flow_1ijfkpz" name="No" sourceRef="Gateway_1vd3as7" targetRef="Activity_0vs4eam" />
<bpmn:sequenceFlow id="Flow_1yxp4e8" sourceRef="Activity_0mwpp9o" targetRef="Event_0v7hm2z" />
</bpmn:process>
<bpmn:process id="Process_0s8woey" isExecutable="false">
<bpmn:receiveTask id="Activity_1q87dyp" name="Gets information about work">
<bpmn:outgoing>Flow_119ldsr</bpmn:outgoing>
</bpmn:receiveTask>
<bpmn:endEvent id="Event_170rm9y">
<bpmn:incoming>Flow_1mm9swr</bpmn:incoming>
</bpmn:endEvent>
<bpmn:subProcess id="Activity_0h1d3g9" name="Executor Requests for work">
<bpmn:incoming>Flow_119ldsr</bpmn:incoming>
<bpmn:outgoing>Flow_1mm9swr</bpmn:outgoing>
</bpmn:subProcess>
<bpmn:sequenceFlow id="Flow_119ldsr" sourceRef="Activity_1q87dyp" targetRef="Activity_0h1d3g9" />
<bpmn:sequenceFlow id="Flow_1mm9swr" sourceRef="Activity_0h1d3g9" targetRef="Event_170rm9y" />
</bpmn:process>
<bpmn:process id="Process_0p5wk5x" isExecutable="false">
<bpmn:laneSet id="LaneSet_1r5f5iw">
<bpmn:lane id="Lane_06e7su5" name="Assignment Service">
<bpmn:flowNodeRef>Event_0v73rhy</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Activity_0n8uuvk</bpmn:flowNodeRef>
</bpmn:lane>
<bpmn:lane id="Lane_1lg2d2q" name="Execturo Pool">
<bpmn:flowNodeRef>Activity_06xjrrk</bpmn:flowNodeRef>
</bpmn:lane>
<bpmn:lane id="Lane_19i1lbs" name="Executor">
<bpmn:flowNodeRef>Activity_0uxkytf</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Event_01nh9j2</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Activity_1qgjnyh</bpmn:flowNodeRef>
</bpmn:lane>
</bpmn:laneSet>
<bpmn:startEvent id="Event_0v73rhy">
<bpmn:outgoing>Flow_17d0j42</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:task id="Activity_0n8uuvk" name="Request more executors">
<bpmn:incoming>Flow_17d0j42</bpmn:incoming>
<bpmn:outgoing>Flow_0opy5tp</bpmn:outgoing>
</bpmn:task>
<bpmn:task id="Activity_06xjrrk" name="Add/start new executors">
<bpmn:incoming>Flow_0opy5tp</bpmn:incoming>
<bpmn:outgoing>Flow_0sudw7l</bpmn:outgoing>
</bpmn:task>
<bpmn:task id="Activity_0uxkytf" name="Exectuor starts">
<bpmn:incoming>Flow_0sudw7l</bpmn:incoming>
<bpmn:outgoing>Flow_02uzxx3</bpmn:outgoing>
</bpmn:task>
<bpmn:endEvent id="Event_01nh9j2">
<bpmn:incoming>Flow_0rpv16j</bpmn:incoming>
</bpmn:endEvent>
<bpmn:subProcess id="Activity_1qgjnyh" name="Executor Requests for work">
<bpmn:incoming>Flow_02uzxx3</bpmn:incoming>
<bpmn:outgoing>Flow_0rpv16j</bpmn:outgoing>
</bpmn:subProcess>
<bpmn:sequenceFlow id="Flow_17d0j42" sourceRef="Event_0v73rhy" targetRef="Activity_0n8uuvk" />
<bpmn:sequenceFlow id="Flow_0opy5tp" sourceRef="Activity_0n8uuvk" targetRef="Activity_06xjrrk" />
<bpmn:sequenceFlow id="Flow_02uzxx3" sourceRef="Activity_0uxkytf" targetRef="Activity_1qgjnyh" />
<bpmn:sequenceFlow id="Flow_0sudw7l" sourceRef="Activity_06xjrrk" targetRef="Activity_0uxkytf" />
<bpmn:sequenceFlow id="Flow_0rpv16j" sourceRef="Activity_1qgjnyh" targetRef="Event_01nh9j2" />
</bpmn:process>
<bpmn:process id="Process_1iep78l" isExecutable="false">
<bpmn:laneSet id="LaneSet_03zwzb7">
<bpmn:lane id="Lane_06xhlk6" name="Executor">
<bpmn:flowNodeRef>Event_1oz3tr5</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Activity_0xk9kck</bpmn:flowNodeRef>
</bpmn:lane>
<bpmn:lane id="Lane_02fg9xj" name="Assignment service">
<bpmn:flowNodeRef>Gateway_079742h</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Activity_0umieiz</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Event_062x6a9</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Activity_0b6bh6v</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Event_1achffx</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Activity_1mme68o</bpmn:flowNodeRef>
</bpmn:lane>
</bpmn:laneSet>
<bpmn:startEvent id="Event_1oz3tr5">
<bpmn:outgoing>Flow_0od6iot</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:task id="Activity_0xk9kck" name="Ask for work">
<bpmn:incoming>Flow_0od6iot</bpmn:incoming>
<bpmn:outgoing>Flow_0k07ofo</bpmn:outgoing>
</bpmn:task>
<bpmn:exclusiveGateway id="Gateway_079742h">
<bpmn:incoming>Flow_0k07ofo</bpmn:incoming>
<bpmn:outgoing>Flow_1fwmda3</bpmn:outgoing>
<bpmn:outgoing>Flow_050yku1</bpmn:outgoing>
</bpmn:exclusiveGateway>
<bpmn:task id="Activity_0umieiz" name="Assign task to executor">
<bpmn:incoming>Flow_1fwmda3</bpmn:incoming>
<bpmn:outgoing>Flow_15lkkxa</bpmn:outgoing>
</bpmn:task>
<bpmn:endEvent id="Event_062x6a9">
<bpmn:incoming>Flow_15lkkxa</bpmn:incoming>
</bpmn:endEvent>
<bpmn:task id="Activity_0b6bh6v" name="Some logic to reduce amount of executors if possible???">
<bpmn:incoming>Flow_050yku1</bpmn:incoming>
<bpmn:outgoing>Flow_1lgcq8d</bpmn:outgoing>
</bpmn:task>
<bpmn:endEvent id="Event_1achffx">
<bpmn:incoming>Flow_0oqra8s</bpmn:incoming>
</bpmn:endEvent>
<bpmn:task id="Activity_1mme68o" name="Executor idle&#39;s">
<bpmn:incoming>Flow_1lgcq8d</bpmn:incoming>
<bpmn:outgoing>Flow_0oqra8s</bpmn:outgoing>
</bpmn:task>
<bpmn:sequenceFlow id="Flow_0od6iot" sourceRef="Event_1oz3tr5" targetRef="Activity_0xk9kck" />
<bpmn:sequenceFlow id="Flow_0k07ofo" name="Check if tasks are in queue" sourceRef="Activity_0xk9kck" targetRef="Gateway_079742h" />
<bpmn:sequenceFlow id="Flow_1fwmda3" name="Yes" sourceRef="Gateway_079742h" targetRef="Activity_0umieiz" />
<bpmn:sequenceFlow id="Flow_15lkkxa" sourceRef="Activity_0umieiz" targetRef="Event_062x6a9" />
<bpmn:sequenceFlow id="Flow_050yku1" name="No" sourceRef="Gateway_079742h" targetRef="Activity_0b6bh6v" />
<bpmn:sequenceFlow id="Flow_1lgcq8d" sourceRef="Activity_0b6bh6v" targetRef="Activity_1mme68o" />
<bpmn:sequenceFlow id="Flow_0oqra8s" sourceRef="Activity_1mme68o" targetRef="Event_1achffx" />
</bpmn:process>
<bpmn:process id="Process_102ufh8" isExecutable="false">
<bpmn:laneSet id="LaneSet_15t2y8k">
<bpmn:lane id="Lane_0lvtv1p" name="Executor">
<bpmn:flowNodeRef>Event_1b2jt5y</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Activity_1ikvmpl</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Event_0y66dbe</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Activity_11lqrhg</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Activity_1oownmu</bpmn:flowNodeRef>
</bpmn:lane>
<bpmn:lane id="Lane_1jghhc4" name="Assignment service">
<bpmn:flowNodeRef>Activity_1ohwol1</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Event_0bbqq3x</bpmn:flowNodeRef>
</bpmn:lane>
<bpmn:lane id="Lane_0k7q1xv" name="task service">
<bpmn:flowNodeRef>Activity_1e9hb9h</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Event_0l7ljcr</bpmn:flowNodeRef>
</bpmn:lane>
</bpmn:laneSet>
<bpmn:startEvent id="Event_1b2jt5y">
<bpmn:outgoing>Flow_046hsk4</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:task id="Activity_1ikvmpl" name="Executor finish work">
<bpmn:incoming>Flow_046hsk4</bpmn:incoming>
<bpmn:outgoing>Flow_0zoqmub</bpmn:outgoing>
</bpmn:task>
<bpmn:endEvent id="Event_0y66dbe">
<bpmn:incoming>Flow_0nyxv8e</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sendTask id="Activity_11lqrhg" name="Send finish message">
<bpmn:incoming>Flow_0zoqmub</bpmn:incoming>
<bpmn:outgoing>Flow_0ip5x3i</bpmn:outgoing>
<bpmn:outgoing>Flow_1bqiz65</bpmn:outgoing>
<bpmn:outgoing>Flow_142xsjm</bpmn:outgoing>
</bpmn:sendTask>
<bpmn:task id="Activity_1ohwol1" name="Update tasks status to finished">
<bpmn:incoming>Flow_1bqiz65</bpmn:incoming>
<bpmn:outgoing>Flow_0znvsoe</bpmn:outgoing>
</bpmn:task>
<bpmn:task id="Activity_1e9hb9h" name="Update task status to finished">
<bpmn:incoming>Flow_142xsjm</bpmn:incoming>
<bpmn:outgoing>Flow_0ue2i8v</bpmn:outgoing>
</bpmn:task>
<bpmn:endEvent id="Event_0l7ljcr">
<bpmn:incoming>Flow_0ue2i8v</bpmn:incoming>
</bpmn:endEvent>
<bpmn:endEvent id="Event_0bbqq3x">
<bpmn:incoming>Flow_0znvsoe</bpmn:incoming>
</bpmn:endEvent>
<bpmn:subProcess id="Activity_1oownmu" name="Executor Requests for work">
<bpmn:incoming>Flow_0ip5x3i</bpmn:incoming>
<bpmn:outgoing>Flow_0nyxv8e</bpmn:outgoing>
</bpmn:subProcess>
<bpmn:sequenceFlow id="Flow_046hsk4" sourceRef="Event_1b2jt5y" targetRef="Activity_1ikvmpl" />
<bpmn:sequenceFlow id="Flow_0zoqmub" sourceRef="Activity_1ikvmpl" targetRef="Activity_11lqrhg" />
<bpmn:sequenceFlow id="Flow_0ip5x3i" sourceRef="Activity_11lqrhg" targetRef="Activity_1oownmu" />
<bpmn:sequenceFlow id="Flow_0nyxv8e" sourceRef="Activity_1oownmu" targetRef="Event_0y66dbe" />
<bpmn:sequenceFlow id="Flow_1bqiz65" sourceRef="Activity_11lqrhg" targetRef="Activity_1ohwol1" />
<bpmn:sequenceFlow id="Flow_142xsjm" sourceRef="Activity_11lqrhg" targetRef="Activity_1e9hb9h" />
<bpmn:sequenceFlow id="Flow_0ue2i8v" sourceRef="Activity_1e9hb9h" targetRef="Event_0l7ljcr" />
<bpmn:sequenceFlow id="Flow_0znvsoe" sourceRef="Activity_1ohwol1" targetRef="Event_0bbqq3x" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_0anvhsf">
<bpmndi:BPMNShape id="Participant_0q8hukc_di" bpmnElement="Participant_0q8hukc" isHorizontal="true">
<dc:Bounds x="140" y="80" width="1728" height="590" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Lane_1qeq039_di" bpmnElement="Lane_1qeq039" isHorizontal="true">
<dc:Bounds x="170" y="200" width="1698" height="470" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Lane_12khd4k_di" bpmnElement="Lane_12khd4k" isHorizontal="true">
<dc:Bounds x="170" y="80" width="1698" height="120" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_1hc51tx_di" bpmnElement="Flow_1hc51tx">
<di:waypoint x="408" y="310" />
<di:waypoint x="495" y="310" />
<bpmndi:BPMNLabel>
<dc:Bounds x="405" y="576" width="83" height="27" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1sajzlx_di" bpmnElement="Flow_1sajzlx">
<di:waypoint x="545" y="310" />
<di:waypoint x="680" y="310" />
<bpmndi:BPMNLabel>
<dc:Bounds x="604" y="292" width="18" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0cpd5ad_di" bpmnElement="Flow_0cpd5ad">
<di:waypoint x="780" y="310" />
<di:waypoint x="915" y="310" />
<bpmndi:BPMNLabel>
<dc:Bounds x="839" y="592" width="18" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0kwvrmc_di" bpmnElement="Flow_0kwvrmc">
<di:waypoint x="965" y="310" />
<di:waypoint x="1070" y="310" />
<bpmndi:BPMNLabel>
<dc:Bounds x="1009" y="292" width="18" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0vpcut0_di" bpmnElement="Flow_0vpcut0">
<di:waypoint x="1170" y="310" />
<di:waypoint x="1345" y="310" />
<bpmndi:BPMNLabel>
<dc:Bounds x="1217" y="276" width="81" height="27" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_179e0hl_di" bpmnElement="Flow_179e0hl">
<di:waypoint x="1395" y="310" />
<di:waypoint x="1542" y="310" />
<bpmndi:BPMNLabel>
<dc:Bounds x="1462" y="292" width="15" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_12nh0g5_di" bpmnElement="Flow_12nh0g5">
<di:waypoint x="1370" y="335" />
<di:waypoint x="1370" y="420" />
<bpmndi:BPMNLabel>
<dc:Bounds x="1376" y="375" width="18" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0366zqm_di" bpmnElement="Flow_0366zqm">
<di:waypoint x="1420" y="460" />
<di:waypoint x="1542" y="460" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1w3uh2m_di" bpmnElement="Flow_1w3uh2m">
<di:waypoint x="940" y="335" />
<di:waypoint x="940" y="420" />
<bpmndi:BPMNLabel>
<dc:Bounds x="948" y="368" width="15" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1n8jm89_di" bpmnElement="Flow_1n8jm89">
<di:waypoint x="990" y="460" />
<di:waypoint x="1102" y="460" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1rwgf2n_di" bpmnElement="Flow_1rwgf2n">
<di:waypoint x="358" y="180" />
<di:waypoint x="358" y="270" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_19dbo28_di" bpmnElement="Flow_19dbo28">
<di:waypoint x="258" y="140" />
<di:waypoint x="308" y="140" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1gvdy5x_di" bpmnElement="Flow_1gvdy5x">
<di:waypoint x="520" y="510" />
<di:waypoint x="520" y="560" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1ijfkpz_di" bpmnElement="Flow_1ijfkpz">
<di:waypoint x="520" y="335" />
<di:waypoint x="520" y="430" />
<bpmndi:BPMNLabel>
<dc:Bounds x="532" y="368" width="15" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1yxp4e8_di" bpmnElement="Flow_1yxp4e8">
<di:waypoint x="570" y="600" />
<di:waypoint x="662" y="600" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="Gateway_1vd3as7_di" bpmnElement="Gateway_1vd3as7" isMarkerVisible="true">
<dc:Bounds x="495" y="285" width="50" height="50" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1jd11bs_di" bpmnElement="Activity_1jd11bs">
<dc:Bounds x="680" y="270" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Gateway_1e4ckdq_di" bpmnElement="Gateway_1e4ckdq" isMarkerVisible="true">
<dc:Bounds x="915" y="285" width="50" height="50" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1dl4fvt_di" bpmnElement="Activity_1dl4fvt">
<dc:Bounds x="1070" y="270" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Gateway_1e3rabp_di" bpmnElement="Gateway_1e3rabp" isMarkerVisible="true">
<dc:Bounds x="1345" y="285" width="50" height="50" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_1lm6x5y_di" bpmnElement="Event_1lm6x5y">
<dc:Bounds x="1542" y="292" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_1ysgenb_di" bpmnElement="Event_1ysgenb">
<dc:Bounds x="1542" y="442" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_00rvb9o_di" bpmnElement="Event_00rvb9o">
<dc:Bounds x="1102" y="442" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_190bh4a_di" bpmnElement="Activity_0u3tts0">
<dc:Bounds x="890" y="420" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0jai885_di" bpmnElement="Activity_0jai885">
<dc:Bounds x="308" y="100" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="222" y="122" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0vs4eam_di" bpmnElement="Activity_0vs4eam">
<dc:Bounds x="470" y="430" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0mwpp9o_di" bpmnElement="Activity_0mwpp9o">
<dc:Bounds x="470" y="560" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_0v7hm2z_di" bpmnElement="Event_0v7hm2z">
<dc:Bounds x="662" y="582" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0paecdb_di" bpmnElement="Activity_0paecdb">
<dc:Bounds x="308" y="270" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0srcl99_di" bpmnElement="Activity_0srcl99">
<dc:Bounds x="308" y="350" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1iyu1x2_di" bpmnElement="Activity_0assw9c">
<dc:Bounds x="1320" y="420" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Participant_143daut_di" bpmnElement="Participant_143daut" isHorizontal="true">
<dc:Bounds x="820" y="710" width="1048" height="250" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_119ldsr_di" bpmnElement="Flow_119ldsr">
<di:waypoint x="990" y="820" />
<di:waypoint x="1110" y="820" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1mm9swr_di" bpmnElement="Flow_1mm9swr">
<di:waypoint x="1210" y="820" />
<di:waypoint x="1312" y="820" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="Activity_0fc3d7o_di" bpmnElement="Activity_1q87dyp">
<dc:Bounds x="890" y="780" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_170rm9y_di" bpmnElement="Event_170rm9y">
<dc:Bounds x="1312" y="802" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0t1gk0s_di" bpmnElement="Activity_0h1d3g9">
<dc:Bounds x="1110" y="780" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Participant_062djli_di" bpmnElement="Participant_062djli" isHorizontal="true">
<dc:Bounds x="820" y="1000" width="1048" height="470" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Lane_06xhlk6_di" bpmnElement="Lane_06xhlk6" isHorizontal="true">
<dc:Bounds x="850" y="1000" width="1018" height="125" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Lane_02fg9xj_di" bpmnElement="Lane_02fg9xj" isHorizontal="true">
<dc:Bounds x="850" y="1125" width="1018" height="345" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_0od6iot_di" bpmnElement="Flow_0od6iot">
<di:waypoint x="948" y="1060" />
<di:waypoint x="1060" y="1060" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0k07ofo_di" bpmnElement="Flow_0k07ofo">
<di:waypoint x="1110" y="1100" />
<di:waypoint x="1110" y="1215" />
<bpmndi:BPMNLabel>
<dc:Bounds x="1116" y="1155" width="88" height="27" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1fwmda3_di" bpmnElement="Flow_1fwmda3">
<di:waypoint x="1135" y="1240" />
<di:waypoint x="1250" y="1240" />
<bpmndi:BPMNLabel>
<dc:Bounds x="1184" y="1222" width="18" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_15lkkxa_di" bpmnElement="Flow_15lkkxa">
<di:waypoint x="1350" y="1240" />
<di:waypoint x="1472" y="1240" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_050yku1_di" bpmnElement="Flow_050yku1">
<di:waypoint x="1110" y="1265" />
<di:waypoint x="1110" y="1380" />
<di:waypoint x="1250" y="1380" />
<bpmndi:BPMNLabel>
<dc:Bounds x="1118" y="1320" width="15" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1lgcq8d_di" bpmnElement="Flow_1lgcq8d">
<di:waypoint x="1350" y="1380" />
<di:waypoint x="1430" y="1380" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0oqra8s_di" bpmnElement="Flow_0oqra8s">
<di:waypoint x="1530" y="1380" />
<di:waypoint x="1602" y="1380" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="Event_1oz3tr5_di" bpmnElement="Event_1oz3tr5">
<dc:Bounds x="912" y="1042" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0xk9kck_di" bpmnElement="Activity_0xk9kck">
<dc:Bounds x="1060" y="1020" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Gateway_079742h_di" bpmnElement="Gateway_079742h" isMarkerVisible="true">
<dc:Bounds x="1085" y="1215" width="50" height="50" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0umieiz_di" bpmnElement="Activity_0umieiz">
<dc:Bounds x="1250" y="1200" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_062x6a9_di" bpmnElement="Event_062x6a9">
<dc:Bounds x="1472" y="1222" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0b6bh6v_di" bpmnElement="Activity_0b6bh6v">
<dc:Bounds x="1250" y="1340" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_1achffx_di" bpmnElement="Event_1achffx">
<dc:Bounds x="1602" y="1362" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1mme68o_di" bpmnElement="Activity_1mme68o">
<dc:Bounds x="1430" y="1340" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Participant_0xytik6_di" bpmnElement="Participant_1q0bjfl" isHorizontal="true">
<dc:Bounds x="140" y="710" width="600" height="370" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Lane_06e7su5_di" bpmnElement="Lane_06e7su5" isHorizontal="true">
<dc:Bounds x="170" y="710" width="570" height="125" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Lane_1lg2d2q_di" bpmnElement="Lane_1lg2d2q" isHorizontal="true">
<dc:Bounds x="170" y="835" width="570" height="125" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Lane_19i1lbs_di" bpmnElement="Lane_19i1lbs" isHorizontal="true">
<dc:Bounds x="170" y="960" width="570" height="120" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_17d0j42_di" bpmnElement="Flow_17d0j42">
<di:waypoint x="268" y="770" />
<di:waypoint x="370" y="770" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0opy5tp_di" bpmnElement="Flow_0opy5tp">
<di:waypoint x="420" y="810" />
<di:waypoint x="420" y="860" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_02uzxx3_di" bpmnElement="Flow_02uzxx3">
<di:waypoint x="470" y="1020" />
<di:waypoint x="520" y="1020" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0sudw7l_di" bpmnElement="Flow_0sudw7l">
<di:waypoint x="420" y="940" />
<di:waypoint x="420" y="980" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0rpv16j_di" bpmnElement="Flow_0rpv16j">
<di:waypoint x="620" y="1020" />
<di:waypoint x="682" y="1020" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="Event_0v73rhy_di" bpmnElement="Event_0v73rhy">
<dc:Bounds x="232" y="752" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0n8uuvk_di" bpmnElement="Activity_0n8uuvk">
<dc:Bounds x="370" y="730" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_06xjrrk_di" bpmnElement="Activity_06xjrrk">
<dc:Bounds x="370" y="860" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_00bhvrm_di" bpmnElement="Activity_0uxkytf">
<dc:Bounds x="370" y="980" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_01nh9j2_di" bpmnElement="Event_01nh9j2">
<dc:Bounds x="682" y="1002" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1r1i7hf_di" bpmnElement="Activity_1qgjnyh">
<dc:Bounds x="520" y="980" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Participant_1ova0gb_di" bpmnElement="Participant_1ova0gb" isHorizontal="true">
<dc:Bounds x="140" y="1530" width="820" height="370" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Lane_0lvtv1p_di" bpmnElement="Lane_0lvtv1p" isHorizontal="true">
<dc:Bounds x="170" y="1530" width="790" height="125" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Lane_1jghhc4_di" bpmnElement="Lane_1jghhc4" isHorizontal="true">
<dc:Bounds x="170" y="1655" width="790" height="125" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Lane_0k7q1xv_di" bpmnElement="Lane_0k7q1xv" isHorizontal="true">
<dc:Bounds x="170" y="1780" width="790" height="120" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_046hsk4_di" bpmnElement="Flow_046hsk4">
<di:waypoint x="268" y="1600" />
<di:waypoint x="320" y="1600" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0zoqmub_di" bpmnElement="Flow_0zoqmub">
<di:waypoint x="420" y="1600" />
<di:waypoint x="530" y="1600" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0ip5x3i_di" bpmnElement="Flow_0ip5x3i">
<di:waypoint x="630" y="1600" />
<di:waypoint x="720" y="1600" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0nyxv8e_di" bpmnElement="Flow_0nyxv8e">
<di:waypoint x="820" y="1600" />
<di:waypoint x="902" y="1600" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1bqiz65_di" bpmnElement="Flow_1bqiz65">
<di:waypoint x="580" y="1640" />
<di:waypoint x="580" y="1710" />
<di:waypoint x="430" y="1710" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_142xsjm_di" bpmnElement="Flow_142xsjm">
<di:waypoint x="580" y="1640" />
<di:waypoint x="580" y="1800" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0ue2i8v_di" bpmnElement="Flow_0ue2i8v">
<di:waypoint x="630" y="1840" />
<di:waypoint x="682" y="1840" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0znvsoe_di" bpmnElement="Flow_0znvsoe">
<di:waypoint x="330" y="1720" />
<di:waypoint x="268" y="1720" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="Event_1b2jt5y_di" bpmnElement="Event_1b2jt5y">
<dc:Bounds x="232" y="1582" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1ikvmpl_di" bpmnElement="Activity_1ikvmpl">
<dc:Bounds x="320" y="1560" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_0y66dbe_di" bpmnElement="Event_0y66dbe">
<dc:Bounds x="902" y="1582" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0ujophe_di" bpmnElement="Activity_11lqrhg">
<dc:Bounds x="530" y="1560" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1ohwol1_di" bpmnElement="Activity_1ohwol1">
<dc:Bounds x="330" y="1680" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1e9hb9h_di" bpmnElement="Activity_1e9hb9h">
<dc:Bounds x="530" y="1800" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_0l7ljcr_di" bpmnElement="Event_0l7ljcr">
<dc:Bounds x="682" y="1822" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_0bbqq3x_di" bpmnElement="Event_0bbqq3x">
<dc:Bounds x="232" y="1702" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1oownmu_di" bpmnElement="Activity_1oownmu">
<dc:Bounds x="720" y="1560" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_1xo6v1g_di" bpmnElement="Flow_1xo6v1g">
<di:waypoint x="940" y="500" />
<di:waypoint x="940" y="780" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>

337
doc/workflow.bpmn Normal file
View File

@ -0,0 +1,337 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_0grlf6g" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.8.1" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.15.0">
<bpmn:collaboration id="Collaboration_0p9il2x">
<bpmn:participant id="Participant_06nkquo" name="Task Service" processRef="Process_12mqbju" />
<bpmn:participant id="Participant_016oseg" name="Roster Service" processRef="Process_1s4t9qw" />
<bpmn:participant id="Participant_11sfrgz" name="Executor Pool" processRef="Process_0bur8vc" />
<bpmn:participant id="Participant_1x7nd70" name="executor" processRef="Process_1wq3sju" />
<bpmn:messageFlow id="Flow_14smr2g" sourceRef="Activity_13xp2vr" targetRef="Activity_0iljjpd" />
<bpmn:messageFlow id="Flow_1pr8430" name="Get All available executors" sourceRef="Activity_0iljjpd" targetRef="Activity_0qbi1wr" />
<bpmn:messageFlow id="Flow_0je874m" name="Return executorlist" sourceRef="Activity_0qbi1wr" targetRef="Activity_05ck4dv" />
<bpmn:messageFlow id="Flow_0z85582" name="notify executor about new tasks in event channel" sourceRef="Activity_0qh2a6b" targetRef="Activity_0feawyi" />
<bpmn:messageFlow id="Flow_02hwoew" sourceRef="Activity_1hdmlbq" targetRef="Activity_0x47yx9" />
<bpmn:messageFlow id="Flow_0jg4g6h" name="return task informations" sourceRef="Activity_0a4kzh7" targetRef="Activity_12tzfd7" />
<bpmn:messageFlow id="Flow_1ejujjc" name="Notify about status change" sourceRef="Activity_0a4kzh7" targetRef="Activity_0fiiuon" />
<bpmn:messageFlow id="Flow_1gknjes" name="Notify about task finish" sourceRef="Activity_1f06uud" targetRef="Activity_01iahon" />
<bpmn:messageFlow id="Flow_0fihv5s" name="return task results" sourceRef="Activity_12tzfd7" targetRef="Activity_1f06uud" />
<bpmn:messageFlow id="Flow_1qv7s55" name="Sends started message to executor pool" sourceRef="Activity_1r2yhx0" targetRef="Activity_14xojfa" />
<bpmn:messageFlow id="Flow_1l0z3bv" name="Return success message if added" sourceRef="Activity_14xojfa" targetRef="Activity_09ae5r2" />
</bpmn:collaboration>
<bpmn:process id="Process_12mqbju" isExecutable="true">
<bpmn:task id="Activity_0fiiuon" name="Change status to assigned" />
<bpmn:task id="Activity_01iahon" name="Update status and task" />
<bpmn:task id="Activity_13xp2vr" name="Task created" />
</bpmn:process>
<bpmn:process id="Process_1s4t9qw" isExecutable="false">
<bpmn:exclusiveGateway id="Gateway_0sqs3j7">
<bpmn:incoming>Flow_1rie16h</bpmn:incoming>
<bpmn:outgoing>Flow_159tlyd</bpmn:outgoing>
<bpmn:outgoing>Flow_01pbz6s</bpmn:outgoing>
</bpmn:exclusiveGateway>
<bpmn:task id="Activity_0qh2a6b" name="Add task to task queue">
<bpmn:incoming>Flow_159tlyd</bpmn:incoming>
</bpmn:task>
<bpmn:task id="Activity_005fqxd" name="Auction House">
<bpmn:incoming>Flow_01pbz6s</bpmn:incoming>
</bpmn:task>
<bpmn:task id="Activity_0x47yx9" name="Check if task available for this executor">
<bpmn:outgoing>Flow_1urp3d2</bpmn:outgoing>
</bpmn:task>
<bpmn:exclusiveGateway id="Gateway_1apm7h8">
<bpmn:incoming>Flow_1urp3d2</bpmn:incoming>
<bpmn:outgoing>Flow_1oy6e8u</bpmn:outgoing>
<bpmn:outgoing>Flow_1rxws1j</bpmn:outgoing>
</bpmn:exclusiveGateway>
<bpmn:task id="Activity_1v2mt3m" name="Return no task available">
<bpmn:incoming>Flow_1oy6e8u</bpmn:incoming>
</bpmn:task>
<bpmn:task id="Activity_0a4kzh7" name="Assign executor to task and add to roster">
<bpmn:incoming>Flow_1rxws1j</bpmn:incoming>
</bpmn:task>
<bpmn:task id="Activity_1f06uud" name="Remove assignment from roster" />
<bpmn:task id="Activity_0iljjpd" name="Receive Task" />
<bpmn:task id="Activity_05ck4dv" name="Check if executor is available">
<bpmn:outgoing>Flow_1rie16h</bpmn:outgoing>
</bpmn:task>
<bpmn:sequenceFlow id="Flow_1rie16h" sourceRef="Activity_05ck4dv" targetRef="Gateway_0sqs3j7" />
<bpmn:sequenceFlow id="Flow_159tlyd" name="Yes" sourceRef="Gateway_0sqs3j7" targetRef="Activity_0qh2a6b" />
<bpmn:sequenceFlow id="Flow_01pbz6s" name="No" sourceRef="Gateway_0sqs3j7" targetRef="Activity_005fqxd" />
<bpmn:sequenceFlow id="Flow_1urp3d2" sourceRef="Activity_0x47yx9" targetRef="Gateway_1apm7h8" />
<bpmn:sequenceFlow id="Flow_1oy6e8u" name="No" sourceRef="Gateway_1apm7h8" targetRef="Activity_1v2mt3m" />
<bpmn:sequenceFlow id="Flow_1rxws1j" sourceRef="Gateway_1apm7h8" targetRef="Activity_0a4kzh7" />
</bpmn:process>
<bpmn:process id="Process_0bur8vc" isExecutable="false">
<bpmn:task id="Activity_0qbi1wr" name="Retrieve executors by type" />
<bpmn:task id="Activity_14xojfa" name="Adds executor to pool" />
</bpmn:process>
<bpmn:process id="Process_1wq3sju" isExecutable="false">
<bpmn:task id="Activity_0feawyi" name="check if right tasktype and if idling">
<bpmn:outgoing>Flow_0nuuhk7</bpmn:outgoing>
</bpmn:task>
<bpmn:exclusiveGateway id="Gateway_0nyndyn">
<bpmn:incoming>Flow_0nuuhk7</bpmn:incoming>
<bpmn:outgoing>Flow_197gie6</bpmn:outgoing>
<bpmn:outgoing>Flow_0ruufha</bpmn:outgoing>
</bpmn:exclusiveGateway>
<bpmn:task id="Activity_1v0d9zm" name="Do nothing">
<bpmn:incoming>Flow_197gie6</bpmn:incoming>
</bpmn:task>
<bpmn:task id="Activity_12tzfd7" name="Execute task" />
<bpmn:task id="Activity_1hdmlbq" name="Apply for Assignment">
<bpmn:incoming>Flow_0ruufha</bpmn:incoming>
<bpmn:incoming>Flow_1duwugb</bpmn:incoming>
</bpmn:task>
<bpmn:task id="Activity_1r2yhx0" name="Executor Starts" />
<bpmn:task id="Activity_09ae5r2" name="Was startup successfull">
<bpmn:outgoing>Flow_19m4xhk</bpmn:outgoing>
</bpmn:task>
<bpmn:exclusiveGateway id="Gateway_1o0lihs">
<bpmn:incoming>Flow_19m4xhk</bpmn:incoming>
<bpmn:outgoing>Flow_0b4g73l</bpmn:outgoing>
<bpmn:outgoing>Flow_1duwugb</bpmn:outgoing>
</bpmn:exclusiveGateway>
<bpmn:task id="Activity_0n6hvhw" name="Shut down">
<bpmn:incoming>Flow_0b4g73l</bpmn:incoming>
</bpmn:task>
<bpmn:sequenceFlow id="Flow_0nuuhk7" sourceRef="Activity_0feawyi" targetRef="Gateway_0nyndyn" />
<bpmn:sequenceFlow id="Flow_197gie6" name="No" sourceRef="Gateway_0nyndyn" targetRef="Activity_1v0d9zm" />
<bpmn:sequenceFlow id="Flow_0ruufha" sourceRef="Gateway_0nyndyn" targetRef="Activity_1hdmlbq" />
<bpmn:sequenceFlow id="Flow_19m4xhk" sourceRef="Activity_09ae5r2" targetRef="Gateway_1o0lihs" />
<bpmn:sequenceFlow id="Flow_0b4g73l" name="No" sourceRef="Gateway_1o0lihs" targetRef="Activity_0n6hvhw" />
<bpmn:sequenceFlow id="Flow_1duwugb" name="Yes" sourceRef="Gateway_1o0lihs" targetRef="Activity_1hdmlbq" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_0p9il2x">
<bpmndi:BPMNShape id="Participant_016oseg_di" bpmnElement="Participant_016oseg" isHorizontal="true">
<dc:Bounds x="160" y="310" width="1950" height="260" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_1rie16h_di" bpmnElement="Flow_1rie16h">
<di:waypoint x="510" y="390" />
<di:waypoint x="805" y="390" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_159tlyd_di" bpmnElement="Flow_159tlyd">
<di:waypoint x="855" y="390" />
<di:waypoint x="950" y="390" />
<bpmndi:BPMNLabel>
<dc:Bounds x="894" y="372" width="18" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_01pbz6s_di" bpmnElement="Flow_01pbz6s">
<di:waypoint x="830" y="415" />
<di:waypoint x="830" y="500" />
<di:waypoint x="950" y="500" />
<bpmndi:BPMNLabel>
<dc:Bounds x="882" y="483" width="15" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1urp3d2_di" bpmnElement="Flow_1urp3d2">
<di:waypoint x="1490" y="400" />
<di:waypoint x="1585" y="400" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1oy6e8u_di" bpmnElement="Flow_1oy6e8u">
<di:waypoint x="1610" y="425" />
<di:waypoint x="1610" y="480" />
<bpmndi:BPMNLabel>
<dc:Bounds x="1618" y="443" width="15" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1rxws1j_di" bpmnElement="Flow_1rxws1j">
<di:waypoint x="1635" y="400" />
<di:waypoint x="1750" y="400" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="Gateway_0sqs3j7_di" bpmnElement="Gateway_0sqs3j7" isMarkerVisible="true">
<dc:Bounds x="805" y="365" width="50" height="50" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0qh2a6b_di" bpmnElement="Activity_0qh2a6b">
<dc:Bounds x="950" y="350" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_005fqxd_di" bpmnElement="Activity_005fqxd">
<dc:Bounds x="950" y="460" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0x47yx9_di" bpmnElement="Activity_0x47yx9">
<dc:Bounds x="1390" y="360" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Gateway_1apm7h8_di" bpmnElement="Gateway_1apm7h8" isMarkerVisible="true">
<dc:Bounds x="1585" y="375" width="50" height="50" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1v2mt3m_di" bpmnElement="Activity_1v2mt3m">
<dc:Bounds x="1560" y="480" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0a4kzh7_di" bpmnElement="Activity_0a4kzh7">
<dc:Bounds x="1750" y="360" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1f06uud_di" bpmnElement="Activity_1f06uud">
<dc:Bounds x="1970" y="360" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0iljjpd_di" bpmnElement="Activity_0iljjpd">
<dc:Bounds x="230" y="350" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_05ck4dv_di" bpmnElement="Activity_05ck4dv">
<dc:Bounds x="410" y="350" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Participant_11sfrgz_di" bpmnElement="Participant_11sfrgz" isHorizontal="true">
<dc:Bounds x="160" y="640" width="860" height="250" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0qbi1wr_di" bpmnElement="Activity_0qbi1wr">
<dc:Bounds x="230" y="730" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_14xojfa_di" bpmnElement="Activity_14xojfa">
<dc:Bounds x="550" y="710" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Participant_1x7nd70_di" bpmnElement="Participant_1x7nd70" isHorizontal="true">
<dc:Bounds x="160" y="930" width="1950" height="300" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_0nuuhk7_di" bpmnElement="Flow_0nuuhk7">
<di:waypoint x="1180" y="1040" />
<di:waypoint x="1265" y="1040" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_197gie6_di" bpmnElement="Flow_197gie6">
<di:waypoint x="1290" y="1065" />
<di:waypoint x="1290" y="1150" />
<di:waypoint x="1400" y="1150" />
<bpmndi:BPMNLabel>
<dc:Bounds x="1332" y="1133" width="15" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0ruufha_di" bpmnElement="Flow_0ruufha">
<di:waypoint x="1315" y="1040" />
<di:waypoint x="1400" y="1040" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_19m4xhk_di" bpmnElement="Flow_19m4xhk">
<di:waypoint x="810" y="1010" />
<di:waypoint x="905" y="1010" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0b4g73l_di" bpmnElement="Flow_0b4g73l">
<di:waypoint x="930" y="1035" />
<di:waypoint x="930" y="1110" />
<bpmndi:BPMNLabel>
<dc:Bounds x="938" y="1063" width="15" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1duwugb_di" bpmnElement="Flow_1duwugb">
<di:waypoint x="930" y="985" />
<di:waypoint x="930" y="960" />
<di:waypoint x="1420" y="960" />
<di:waypoint x="1420" y="1000" />
<bpmndi:BPMNLabel>
<dc:Bounds x="961" y="942" width="18" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="Activity_0feawyi_di" bpmnElement="Activity_0feawyi">
<dc:Bounds x="1080" y="1000" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Gateway_0nyndyn_di" bpmnElement="Gateway_0nyndyn" isMarkerVisible="true">
<dc:Bounds x="1265" y="1015" width="50" height="50" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1v0d9zm_di" bpmnElement="Activity_1v0d9zm">
<dc:Bounds x="1400" y="1110" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_12tzfd7_di" bpmnElement="Activity_12tzfd7">
<dc:Bounds x="1750" y="1000" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1hdmlbq_di" bpmnElement="Activity_1hdmlbq">
<dc:Bounds x="1400" y="1000" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1r2yhx0_di" bpmnElement="Activity_1r2yhx0">
<dc:Bounds x="340" y="1050" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_09ae5r2_di" bpmnElement="Activity_09ae5r2">
<dc:Bounds x="710" y="970" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Gateway_1o0lihs_di" bpmnElement="Gateway_1o0lihs" isMarkerVisible="true">
<dc:Bounds x="905" y="985" width="50" height="50" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0n6hvhw_di" bpmnElement="Activity_0n6hvhw">
<dc:Bounds x="880" y="1110" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Participant_06nkquo_di" bpmnElement="Participant_06nkquo" isHorizontal="true">
<dc:Bounds x="160" y="80" width="1970" height="150" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0fiiuon_di" bpmnElement="Activity_0fiiuon">
<dc:Bounds x="1750" y="120" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_01iahon_di" bpmnElement="Activity_01iahon">
<dc:Bounds x="1970" y="120" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_13xp2vr_di" bpmnElement="Activity_13xp2vr">
<dc:Bounds x="230" y="120" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_14smr2g_di" bpmnElement="Flow_14smr2g">
<di:waypoint x="280" y="200" />
<di:waypoint x="280" y="350" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1pr8430_di" bpmnElement="Flow_1pr8430">
<di:waypoint x="280" y="430" />
<di:waypoint x="280" y="730" />
<bpmndi:BPMNLabel>
<dc:Bounds x="285" y="661" width="80" height="27" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0je874m_di" bpmnElement="Flow_0je874m">
<di:waypoint x="330" y="770" />
<di:waypoint x="460" y="770" />
<di:waypoint x="460" y="430" />
<bpmndi:BPMNLabel>
<dc:Bounds x="379" y="736" width="56" height="27" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0z85582_di" bpmnElement="Flow_0z85582">
<di:waypoint x="1050" y="390" />
<di:waypoint x="1130" y="390" />
<di:waypoint x="1130" y="1000" />
<bpmndi:BPMNLabel>
<dc:Bounds x="1040" y="726" width="81" height="40" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_02hwoew_di" bpmnElement="Flow_02hwoew">
<di:waypoint x="1450" y="1000" />
<di:waypoint x="1450" y="440" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0jg4g6h_di" bpmnElement="Flow_0jg4g6h">
<di:waypoint x="1800" y="440" />
<di:waypoint x="1800" y="1000" />
<bpmndi:BPMNLabel>
<dc:Bounds x="1820" y="717" width="60" height="27" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1ejujjc_di" bpmnElement="Flow_1ejujjc">
<di:waypoint x="1800" y="360" />
<di:waypoint x="1800" y="200" />
<bpmndi:BPMNLabel>
<dc:Bounds x="1815" y="256" width="69" height="27" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0fihv5s_di" bpmnElement="Flow_0fihv5s">
<di:waypoint x="1850" y="1040" />
<di:waypoint x="2020" y="1040" />
<di:waypoint x="2020" y="440" />
<bpmndi:BPMNLabel>
<dc:Bounds x="2036" y="724" width="88" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1gknjes_di" bpmnElement="Flow_1gknjes">
<di:waypoint x="2020" y="360" />
<di:waypoint x="2020" y="200" />
<bpmndi:BPMNLabel>
<dc:Bounds x="2029" y="262" width="82" height="27" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1qv7s55_di" bpmnElement="Flow_1qv7s55">
<di:waypoint x="440" y="1090" />
<di:waypoint x="600" y="1090" />
<di:waypoint x="600" y="790" />
<bpmndi:BPMNLabel>
<dc:Bounds x="486" y="1030" width="68" height="40" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1l0z3bv_di" bpmnElement="Flow_1l0z3bv">
<di:waypoint x="650" y="750" />
<di:waypoint x="760" y="750" />
<di:waypoint x="760" y="970" />
<bpmndi:BPMNLabel>
<dc:Bounds x="777" y="800" width="87" height="27" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>

BIN
doc/workflow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 817 KiB

View File

@ -9,9 +9,9 @@
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>ch.unisg</groupId>
<artifactId>executorBase</artifactId>
<artifactId>executor-base</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>executorBase</name>
<name>executor-base</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
@ -60,6 +60,12 @@
<artifactId>json</artifactId>
<version>20210307</version>
</dependency>
<dependency>
<groupId>ch.unisg</groupId>
<artifactId>common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>

View File

@ -1,13 +0,0 @@
package ch.unisg.executorBase;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Executor1Application {
public static void main(String[] args) {
SpringApplication.run(Executor1Application.class, args);
}
}

View File

@ -1,4 +1,6 @@
package ch.unisg.executorBase.executor.adapter.in.web;
package ch.unisg.executorbase.executor.adapter.in.web;
import java.util.logging.Logger;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
@ -7,9 +9,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.executorBase.executor.application.port.in.TaskAvailableCommand;
import ch.unisg.executorBase.executor.application.port.in.TaskAvailableUseCase;
import ch.unisg.executorBase.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 {
@ -19,9 +21,17 @@ public class TaskAvailableController {
this.taskAvailableUseCase = taskAvailableUseCase;
}
@GetMapping(path = "/newtask/{taskType}")
Logger logger = Logger.getLogger(TaskAvailableController.class.getName());
/**
* Controller for notification about new events.
* @return 200 OK
**/
@GetMapping(path = "/newtask/{taskType}", consumes = { "application/json" })
public ResponseEntity<String> retrieveTaskFromTaskList(@PathVariable("taskType") String taskType) {
logger.info("New " + taskType + " available");
if (ExecutorType.contains(taskType.toUpperCase())) {
TaskAvailableCommand command = new TaskAvailableCommand(
ExecutorType.valueOf(taskType.toUpperCase()));

View File

@ -1,4 +1,4 @@
package ch.unisg.executorBase.executor.adapter.out.web;
package ch.unisg.executorbase.executor.adapter.out.web;
import java.io.IOException;
import java.net.URI;
@ -9,22 +9,29 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Value;
import ch.unisg.executorBase.executor.application.port.out.ExecutionFinishedEventPort;
import ch.unisg.executorBase.executor.domain.ExecutionFinishedEvent;
import ch.unisg.executorbase.executor.application.port.out.ExecutionFinishedEventPort;
import ch.unisg.executorbase.executor.domain.ExecutionFinishedEvent;
public class ExecutionFinishedEventAdapter implements ExecutionFinishedEventPort {
String server = "http://127.0.0.1:8082";
// TODO url doesn't get mapped bc no autowiring
@Value("${roster.url}")
String server = "http://localhost:8082";
Logger logger = Logger.getLogger(ExecutionFinishedEventAdapter.class.getName());
/**
* Publishes the execution finished event
* @return void
**/
@Override
public void publishExecutionFinishedEvent(ExecutionFinishedEvent event) {
String body = new JSONObject()
.put("taskID", event.getTaskID())
.put("result", event.getResult())
.put("outputData", event.getOutputData())
.put("status", event.getStatus())
.toString();
@ -35,15 +42,17 @@ public class ExecutionFinishedEventAdapter implements ExecutionFinishedEventPort
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
try {
client.send(request, HttpResponse.BodyHandlers.ofString());
} catch (IOException | InterruptedException e) {
} catch (InterruptedException e) {
logger.log(Level.SEVERE, e.getLocalizedMessage(), e);
// Restore interrupted state...
Thread.currentThread().interrupt();
} catch (IOException e) {
logger.log(Level.SEVERE, e.getLocalizedMessage(), e);
}
System.out.println("Finish execution event sent with result:" + event.getResult());
logger.log(Level.INFO, "Finish execution event sent with result: {0}", event.getOutputData());
}

View File

@ -1,4 +1,4 @@
package ch.unisg.executorBase.executor.adapter.out.web;
package ch.unisg.executorbase.executor.adapter.out.web;
import java.io.IOException;
import java.net.URI;
@ -8,12 +8,14 @@ import java.net.http.HttpResponse;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import ch.unisg.executorBase.executor.application.port.out.GetAssignmentPort;
import ch.unisg.executorBase.executor.domain.ExecutorType;
import ch.unisg.executorBase.executor.domain.Task;
import ch.unisg.common.valueobject.ExecutorURI;
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;
@ -21,17 +23,23 @@ import org.json.JSONObject;
@Primary
public class GetAssignmentAdapter implements GetAssignmentPort {
// TODO Not working for now bc it doesn't get autowired
@Value("${roster.url}")
String server = "http://127.0.0.1:8082";
Logger logger = Logger.getLogger(GetAssignmentAdapter.class.getName());
/**
* Requests a new task assignment
* @return the assigned task
* @see Task
**/
@Override
public Task getAssignment(ExecutorType executorType, String ip, int port) {
public Task getAssignment(ExecutorType executorType, ExecutorURI executorURI) {
String body = new JSONObject()
.put("executorType", executorType)
.put("ip", ip)
.put("port", port)
.put("executorURI", executorURI.getValue())
.toString();
HttpClient client = HttpClient.newHttpClient();
@ -42,17 +50,22 @@ public class GetAssignmentAdapter implements GetAssignmentPort {
.build();
try {
logger.info("Sending getAssignment Request");
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
logger.log(Level.INFO, "getAssignment request result:\n {0}", response.body());
if (response.body().equals("")) {
return null;
}
JSONObject responseBody = new JSONObject(response.body());
return new Task(new JSONObject(response.body()).getString("taskID"));
String inputData = responseBody.getString("inputData");
return new Task(responseBody.getString("taskID"), inputData);
} catch (IOException | InterruptedException e) {
} catch (InterruptedException e) {
logger.log(Level.SEVERE, e.getLocalizedMessage(), e);
// Restore interrupted state...
Thread.currentThread().interrupt();
} catch (IOException e) {
logger.log(Level.SEVERE, e.getLocalizedMessage(), e);
}
return null;

View File

@ -1,4 +1,4 @@
package ch.unisg.executorBase.executor.adapter.out.web;
package ch.unisg.executorbase.executor.adapter.out.web;
import java.io.IOException;
import java.net.URI;
@ -9,28 +9,35 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Primary;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
import ch.unisg.executorBase.executor.application.port.out.NotifyExecutorPoolPort;
import ch.unisg.executorBase.executor.domain.ExecutorType;
import ch.unisg.common.valueobject.ExecutorURI;
import ch.unisg.executorbase.executor.application.port.out.NotifyExecutorPoolPort;
import ch.unisg.executorbase.executor.domain.ExecutorType;
@Component
@Primary
public class NotifyExecutorPoolAdapter implements NotifyExecutorPoolPort {
// TODO Not working for now bc it doesn't get autowired
@Value("${executor.pool.url}")
String server = "http://127.0.0.1:8083";
Logger logger = Logger.getLogger(NotifyExecutorPoolAdapter.class.getName());
/**
* Notifies the executor-pool about the startup of this executor
* @return if the notification was successful
**/
@Override
public boolean notifyExecutorPool(String ip, int port, ExecutorType executorType) {
public boolean notifyExecutorPool(ExecutorURI executorURI, ExecutorType executorType) {
String body = new JSONObject()
.put("executorTaskType", executorType)
.put("executorIp", ip)
.put("executorPort", Integer.toString(port))
.put("executorUri", executorURI.getValue())
.toString();
HttpClient client = HttpClient.newHttpClient();
@ -45,10 +52,11 @@ public class NotifyExecutorPoolAdapter implements NotifyExecutorPoolPort {
if (response.statusCode() == HttpStatus.CREATED.value()) {
return true;
}
} catch (IOException | InterruptedException e) {
} catch (InterruptedException e) {
logger.log(Level.SEVERE, e.getLocalizedMessage(), e);
// Restore interrupted state...
Thread.currentThread().interrupt();
} catch (IOException e) {
logger.log(Level.SEVERE, e.getLocalizedMessage(), e);
}
return false;

View File

@ -1,10 +1,9 @@
package ch.unisg.executorBase.executor.application.port.in;
import ch.unisg.executorBase.common.SelfValidating;
import ch.unisg.executorBase.executor.domain.ExecutorType;
package ch.unisg.executorbase.executor.application.port.in;
import javax.validation.constraints.NotNull;
import ch.unisg.common.validation.SelfValidating;
import ch.unisg.executorbase.executor.domain.ExecutorType;
import lombok.Value;
@Value

View File

@ -1,4 +1,4 @@
package ch.unisg.executorBase.executor.application.port.in;
package ch.unisg.executorbase.executor.application.port.in;
public interface TaskAvailableUseCase {
void newTaskAvailable(TaskAvailableCommand command);

View File

@ -1,6 +1,6 @@
package ch.unisg.executorBase.executor.application.port.out;
package ch.unisg.executorbase.executor.application.port.out;
import ch.unisg.executorBase.executor.domain.ExecutionFinishedEvent;
import ch.unisg.executorbase.executor.domain.ExecutionFinishedEvent;
public interface ExecutionFinishedEventPort {
void publishExecutionFinishedEvent(ExecutionFinishedEvent event);

View File

@ -1,8 +1,9 @@
package ch.unisg.executorBase.executor.application.port.out;
package ch.unisg.executorbase.executor.application.port.out;
import ch.unisg.executorBase.executor.domain.ExecutorType;
import ch.unisg.executorBase.executor.domain.Task;
import ch.unisg.common.valueobject.ExecutorURI;
import ch.unisg.executorbase.executor.domain.ExecutorType;
import ch.unisg.executorbase.executor.domain.Task;
public interface GetAssignmentPort {
Task getAssignment(ExecutorType executorType, String ip, int port);
Task getAssignment(ExecutorType executorType, ExecutorURI executorURI);
}

View File

@ -1,7 +1,8 @@
package ch.unisg.executorBase.executor.application.port.out;
package ch.unisg.executorbase.executor.application.port.out;
import ch.unisg.executorBase.executor.domain.ExecutorType;
import ch.unisg.common.valueobject.ExecutorURI;
import ch.unisg.executorbase.executor.domain.ExecutorType;
public interface NotifyExecutorPoolPort {
boolean notifyExecutorPool(String ip, int port, ExecutorType executorType);
boolean notifyExecutorPool(ExecutorURI executorURI, ExecutorType executorType);
}

View File

@ -1,7 +1,8 @@
package ch.unisg.executorBase.executor.application.service;
package ch.unisg.executorbase.executor.application.service;
import ch.unisg.executorBase.executor.application.port.out.NotifyExecutorPoolPort;
import ch.unisg.executorBase.executor.domain.ExecutorType;
import ch.unisg.common.valueobject.ExecutorURI;
import ch.unisg.executorbase.executor.application.port.out.NotifyExecutorPoolPort;
import ch.unisg.executorbase.executor.domain.ExecutorType;
import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
@ -9,7 +10,7 @@ public class NotifyExecutorPoolService {
private final NotifyExecutorPoolPort notifyExecutorPoolPort;
public boolean notifyExecutorPool(String ip, int port, ExecutorType executorType) {
return notifyExecutorPoolPort.notifyExecutorPool(ip, port, executorType);
public boolean notifyExecutorPool(ExecutorURI executorURI, ExecutorType executorType) {
return notifyExecutorPoolPort.notifyExecutorPool(executorURI, executorType);
}
}

View File

@ -1,9 +1,9 @@
package ch.unisg.executorBase.executor.application.service;
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 ch.unisg.executorbase.executor.application.port.in.TaskAvailableCommand;
import ch.unisg.executorbase.executor.application.port.in.TaskAvailableUseCase;
import lombok.RequiredArgsConstructor;
import javax.transaction.Transactional;
@ -15,6 +15,6 @@ public class TaskAvailableService implements TaskAvailableUseCase {
@Override
public void newTaskAvailable(TaskAvailableCommand command) {
// Placeholder so spring can create a bean
// Placeholder so spring can create a bean, implementation of this function is inside the executors
}
}

View File

@ -1,21 +1,21 @@
package ch.unisg.executorBase.executor.domain;
package ch.unisg.executorbase.executor.domain;
import lombok.Getter;
public class ExecutionFinishedEvent {
@Getter
private String taskID;
@Getter
private String result;
private String outputData;
@Getter
private String status;
public ExecutionFinishedEvent(String taskID, String result, String status) {
public ExecutionFinishedEvent(String taskID, String outputData, String status) {
this.taskID = taskID;
this.result = result;
this.outputData = outputData;
this.status = status;
}
}

View File

@ -1,45 +1,46 @@
package ch.unisg.executorBase.executor.domain;
package ch.unisg.executorbase.executor.domain;
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.logging.Logger;
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 ch.unisg.common.valueobject.ExecutorURI;
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.port.out.ExecutionFinishedEventPort;
import ch.unisg.executorbase.executor.application.port.out.GetAssignmentPort;
import ch.unisg.executorbase.executor.application.port.out.NotifyExecutorPoolPort;
import ch.unisg.executorbase.executor.application.service.NotifyExecutorPoolService;
import lombok.Getter;
public abstract class ExecutorBase {
@Getter
private String ip;
private ExecutorURI executorURI;
@Getter
private ExecutorType executorType;
@Getter
private int port;
@Getter
private ExecutorStatus status;
// 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
// TODO Violation of the Dependency Inversion Principle?,
// TODO do this with only services
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;
Logger logger = Logger.getLogger(ExecutorBase.class.getName());
protected ExecutorBase(ExecutorType executorType) {
logger.info("Starting Executor");
this.status = ExecutorStatus.STARTING_UP;
if(!notifyExecutorPoolService.notifyExecutorPool(this.ip, this.port, this.executorType)) {
this.executorType = executorType;
// TODO set this automaticly
this.executorURI = new ExecutorURI("http://localhost:8084");
// TODO do this in main
// Notify executor-pool about existence. If executor-pools response is successfull start with getting an assignment, else shut down executor.
if(!notifyExecutorPoolService.notifyExecutorPool(this.executorURI, this.executorType)) {
System.exit(0);
} else {
this.status = ExecutorStatus.IDLING;
@ -47,9 +48,14 @@ public abstract class ExecutorBase {
}
}
/**
* Requests a new task from the task queue
* @return void
**/
public void getAssignment() {
Task newTask = getAssignmentPort.getAssignment(this.getExecutorType(), this.getIp(),
this.getPort());
Task newTask = getAssignmentPort.getAssignment(this.getExecutorType(), this.getExecutorURI());
System.out.println("New assignment");
System.out.println(newTask);
if (newTask != null) {
this.executeTask(newTask);
} else {
@ -57,19 +63,28 @@ public abstract class ExecutorBase {
}
}
/**
* Start the execution of a task
* @return void
**/
private void executeTask(Task task) {
System.out.println("Starting execution");
logger.info("Starting execution");
this.status = ExecutorStatus.EXECUTING;
task.setResult(execution());
task.setOutputData(execution(task.getInputData()));
// TODO implement logic if execution was not successful
executionFinishedEventPort.publishExecutionFinishedEvent(
new ExecutionFinishedEvent(task.getTaskID(), task.getResult(), "SUCCESS"));
new ExecutionFinishedEvent(task.getTaskID(), task.getOutputData(), "SUCCESS"));
System.out.println("Finish execution");
logger.info("Finish execution");
getAssignment();
}
protected abstract String execution();
/**
* Implementation of the actual execution method of an executor
* @return the execution result
**/
protected abstract String execution(String input);
}

View File

@ -1,7 +1,7 @@
package ch.unisg.executorBase.executor.domain;
package ch.unisg.executorbase.executor.domain;
public enum ExecutorStatus {
STARTING_UP,
EXECUTING,
IDLING,
STARTING_UP, // Executor is starting
EXECUTING, // Executor is currently executing a task
IDLING, // Executor has no tasks left and is waiting for new instructions
}

View File

@ -1,8 +1,12 @@
package ch.unisg.executorBase.executor.domain;
package ch.unisg.executorbase.executor.domain;
public enum ExecutorType {
ADDITION, ROBOT;
/**
* Checks if the give executor type exists.
* @return Wheter the given executor type exists
**/
public static boolean contains(String test) {
for (ExecutorType x : ExecutorType.values()) {

View File

@ -1,4 +1,4 @@
package ch.unisg.executorBase.executor.domain;
package ch.unisg.executorbase.executor.domain;
import lombok.Getter;
import lombok.Setter;
@ -10,10 +10,16 @@ public class Task {
@Getter
@Setter
private String result;
private String outputData;
public Task(String taskID) {
// TODO maybe create a value object for inputData so we can make sure it is in the right
// format.
@Getter
private String inputData;
public Task(String taskID, String inputData) {
this.taskID = taskID;
this.inputData= inputData;
}
}

View File

@ -1 +1,6 @@
server.port=8081
roster.url=http://127.0.0.1:8082
executor.pool.url=http://127.0.0.1:8083
executor1.url=http://127.0.0.1:8084
executor2.url=http://127.0.0.1:8085
task-list.url=http://127.0.0.1:8081

View File

@ -9,9 +9,9 @@
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>ch.unisg</groupId>
<artifactId>executor2</artifactId>
<artifactId>executor-computation</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>executor2</name>
<name>executor-computation</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
@ -42,7 +42,7 @@
</dependency>
<dependency>
<groupId>ch.unisg</groupId>
<artifactId>executorBase</artifactId>
<artifactId>executor-base</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>

View File

@ -1,15 +1,15 @@
package ch.unisg.executor2;
package ch.unisg.executorcomputation;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import ch.unisg.executor2.executor.domain.Executor;
import ch.unisg.executorcomputation.executor.domain.Executor;
@SpringBootApplication
public class Executor2Application {
public class ExecutorcomputationApplication {
public static void main(String[] args) {
SpringApplication.run(Executor2Application.class, args);
SpringApplication.run(ExecutorcomputationApplication.class, args);
Executor.getExecutor();
}

View File

@ -1,4 +1,4 @@
package ch.unisg.executor2.executor.adapter.in.web;
package ch.unisg.executorcomputation.executor.adapter.in.web;
import java.util.concurrent.CompletableFuture;
@ -9,9 +9,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.executorBase.executor.application.port.in.TaskAvailableCommand;
import ch.unisg.executorBase.executor.application.port.in.TaskAvailableUseCase;
import ch.unisg.executorBase.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 {

View File

@ -1,11 +1,11 @@
package ch.unisg.executor1.executor.application.service;
package ch.unisg.executorcomputation.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 ch.unisg.executorcomputation.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;
@ -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();
}

View File

@ -0,0 +1,65 @@
package ch.unisg.executorcomputation.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 {
private static final Executor executor = new Executor(ExecutorType.ADDITION);
public static Executor getExecutor() {
return executor;
}
private Executor(ExecutorType executorType) {
super(executorType);
}
@Override
protected
String execution(String inputData) {
System.out.println(inputData);
String operator = "";
if (inputData.contains("+")) {
operator = "+";
} else if (inputData.contains("-")) {
operator = "-";
} else if (inputData.contains("*")) {
operator = "*";
}
// System.out.println(operator);
// double result = Double.NaN;
// System.out.print(inputData.split("+"));
// int a = Integer.parseInt(inputData.split(operator)[0]);
// int b = Integer.parseInt(inputData.split(operator)[1]);
// // try {
// // TimeUnit.SECONDS.sleep(20);
// // } catch (InterruptedException e) {
// // e.printStackTrace();
// // }
// if (operator.equalsIgnoreCase("+")) {
// result = a + b;
// } else if (operator.equalsIgnoreCase("*")) {
// result = a * b;
// } else if (operator.equalsIgnoreCase("-")) {
// result = a - b;
// }
// System.out.println("Result: " + result);
double result = 0.0;
return Double.toString(result);
}
}

View File

@ -1,10 +1,10 @@
package ch.unisg.executor2;
package ch.unisg.executorcomputation;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class Executor2ApplicationTests {
class ExecutorcomputationApplicationTests {
@Test
void contextLoads() {

View File

@ -63,6 +63,12 @@
<artifactId>javax.transaction-api</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.paho</groupId>
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
<version>1.2.5</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>

View File

@ -0,0 +1,22 @@
package ch.unisg.common;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import java.net.URI;
@Component
public class ConfigProperties {
@Autowired
private Environment environment;
/**
* Retrieves the URI of the MQTT broker.
*
* @return the URI of the MQTT broker
*/
public URI getMqttBrokerUri() {
return URI.create(environment.getProperty("mqtt.broker.uri"));
}
}

View File

@ -1,12 +0,0 @@
package ch.unisg.executorpool;
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! Executor Pool";
}
}

View File

@ -0,0 +1,41 @@
package ch.unisg.executorpool.adapter.common.clients;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.eclipse.paho.client.mqttv3.*;
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
import java.nio.charset.StandardCharsets;
import java.util.UUID;
public class TapasMqttClient {
private static final Logger LOGGER = LogManager.getLogger(TapasMqttClient.class);
private static TapasMqttClient tapasClient = null;
private MqttClient mqttClient;
private final String mqttClientId;
private final String brokerAddress;
private TapasMqttClient(String brokerAddress) {
this.mqttClientId = UUID.randomUUID().toString();
this.brokerAddress = brokerAddress;
}
public static synchronized TapasMqttClient getInstance(String brokerAddress) {
if (tapasClient == null) {
tapasClient = new TapasMqttClient(brokerAddress);
}
return tapasClient;
}
public void publishMessage(String topic, String payload) throws MqttException {
mqttClient = new org.eclipse.paho.client.mqttv3.MqttClient(brokerAddress, mqttClientId, new MemoryPersistence());
mqttClient.connect();
MqttMessage message = new MqttMessage(payload.getBytes(StandardCharsets.UTF_8));
mqttClient.publish(topic, message);
mqttClient.disconnect();
}
}

View File

@ -0,0 +1,51 @@
package ch.unisg.executorpool.adapter.common.formats;
import ch.unisg.executorpool.domain.ExecutorClass;
import lombok.Getter;
import lombok.Setter;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.List;
public class ExecutorJsonRepresentation {
public static final String EXECUTOR_MEDIA_TYPE = "application/json";
@Getter @Setter
private String executorUri;
@Getter @Setter
private String executorTaskType;
// TODO Check if this need Setters. Also applies to AuctionJsonRepresentation
public ExecutorJsonRepresentation(String executorUri, String executorTaskType){
this.executorUri = executorUri;
this.executorTaskType = executorTaskType;
}
public static String serialize(ExecutorClass executorClass) {
JSONObject payload = new JSONObject();
payload.put("executorUri", executorClass.getExecutorUri().getValue());
payload.put("executorTaskType", executorClass.getExecutorTaskType().getValue());
return payload.toString();
}
public static String serialize(List<ExecutorClass> listOfExecutors) {
JSONArray jsonArray = new JSONArray();
for (ExecutorClass executor: listOfExecutors) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("executorUri", executor.getExecutorUri().getValue());
jsonObject.put("executorTaskType", executor.getExecutorTaskType().getValue());
jsonArray.put(jsonObject);
}
return jsonArray.toString();
}
private ExecutorJsonRepresentation() { }
}

View File

@ -1,5 +1,7 @@
package ch.unisg.executorpool.adapter.in.web;
import ch.unisg.executorpool.adapter.common.clients.TapasMqttClient;
import ch.unisg.executorpool.adapter.common.formats.ExecutorJsonRepresentation;
import ch.unisg.executorpool.application.port.in.AddNewExecutorToExecutorPoolUseCase;
import ch.unisg.executorpool.application.port.in.AddNewExecutorToExecutorPoolCommand;
import ch.unisg.executorpool.domain.ExecutorClass;
@ -11,6 +13,11 @@ 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.net.URI;
import java.nio.charset.StandardCharsets;
import java.util.UUID;
import org.eclipse.paho.client.mqttv3.*;
@RestController
public class AddNewExecutorToExecutorPoolWebController {
@ -20,19 +27,21 @@ public class AddNewExecutorToExecutorPoolWebController {
this.addNewExecutorToExecutorPoolUseCase = addNewExecutorToExecutorPoolUseCase;
}
@PostMapping(path = "/executor-pool/AddExecutor", consumes = {ExecutorMediaType.EXECUTOR_MEDIA_TYPE})
public ResponseEntity<String> addNewExecutorToExecutorPool(@RequestBody ExecutorClass executorClass){
try{
@PostMapping(path = "/executor-pool/AddExecutor", consumes = {ExecutorJsonRepresentation.EXECUTOR_MEDIA_TYPE})
public ResponseEntity<String> addNewExecutorToExecutorPool(@RequestBody ExecutorJsonRepresentation payload){
try {
AddNewExecutorToExecutorPoolCommand command = new AddNewExecutorToExecutorPoolCommand(
executorClass.getExecutorIp(), executorClass.getExecutorPort(), executorClass.getExecutorTaskType()
new ExecutorClass.ExecutorUri(URI.create(payload.getExecutorUri())),
new ExecutorClass.ExecutorTaskType(payload.getExecutorTaskType())
);
ExecutorClass newExecutor = addNewExecutorToExecutorPoolUseCase.addNewExecutorToExecutorPool(command);
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.add(HttpHeaders.CONTENT_TYPE, ExecutorMediaType.EXECUTOR_MEDIA_TYPE);
responseHeaders.add(HttpHeaders.CONTENT_TYPE, ExecutorJsonRepresentation.EXECUTOR_MEDIA_TYPE);
return new ResponseEntity<>(ExecutorJsonRepresentation.serialize(newExecutor), responseHeaders, HttpStatus.CREATED);
return new ResponseEntity<>(ExecutorMediaType.serialize(newExecutor), responseHeaders, HttpStatus.CREATED);
} catch (ConstraintViolationException e){
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, e.getMessage());
}

View File

@ -1,38 +0,0 @@
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<ExecutorClass> listOfExecutors) {
String serializedList = "[ \n";
for (ExecutorClass executor: listOfExecutors) {
serializedList += serialize(executor) + "\n";
}
// return serializedList + "\n ]";
JSONArray jsonArray = new JSONArray();
JSONObject jsonObject = new JSONObject();
jsonObject.put("executorIp", "localhost");
jsonArray.put(jsonObject);
return jsonArray.toString();
}
private ExecutorMediaType() { }
}

View File

@ -1,35 +0,0 @@
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<String> getAllExecutorInExecutorPoolByType(@PathVariable("taskType") String taskType){
GetAllExecutorInExecutorPoolByTypeQuery query = new GetAllExecutorInExecutorPoolByTypeQuery(new ExecutorTaskType(taskType));
List<ExecutorClass> 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);
}
}

View File

@ -0,0 +1,36 @@
package ch.unisg.executorpool.adapter.in.web;
import ch.unisg.executorpool.adapter.common.formats.ExecutorJsonRepresentation;
import ch.unisg.executorpool.application.port.in.GetAllExecutorsInExecutorPoolByTypeQuery;
import ch.unisg.executorpool.application.port.in.GetAllExecutorsInExecutorPoolByTypeUseCase;
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 GetAllExecutorsInExecutorPoolByTypeWebController {
private final GetAllExecutorsInExecutorPoolByTypeUseCase getAllExecutorsInExecutorPoolByTypeUseCase;
public GetAllExecutorsInExecutorPoolByTypeWebController(GetAllExecutorsInExecutorPoolByTypeUseCase getAllExecutorInExecutorPoolByTypeUseCase){
this.getAllExecutorsInExecutorPoolByTypeUseCase = getAllExecutorInExecutorPoolByTypeUseCase;
}
@GetMapping(path = "/executor-pool/GetAllExecutorsInExecutorPoolByType/{taskType}")
public ResponseEntity<String> getAllExecutorInExecutorPoolByType(@PathVariable("taskType") String taskType){
GetAllExecutorsInExecutorPoolByTypeQuery query = new GetAllExecutorsInExecutorPoolByTypeQuery(new ExecutorTaskType(taskType));
List<ExecutorClass> matchedExecutors = getAllExecutorsInExecutorPoolByTypeUseCase.getAllExecutorsInExecutorPoolByType(query);
// Add the content type as a response header
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.add(HttpHeaders.CONTENT_TYPE, ExecutorJsonRepresentation.EXECUTOR_MEDIA_TYPE);
return new ResponseEntity<>(ExecutorJsonRepresentation.serialize(matchedExecutors), responseHeaders, HttpStatus.OK);
}
}

View File

@ -1,5 +1,6 @@
package ch.unisg.executorpool.adapter.in.web;
import ch.unisg.executorpool.adapter.common.formats.ExecutorJsonRepresentation;
import ch.unisg.executorpool.application.port.in.GetAllExecutorsInExecutorPoolUseCase;
import ch.unisg.executorpool.domain.ExecutorClass;
import org.springframework.http.HttpHeaders;
@ -24,8 +25,8 @@ public class GetAllExecutorsInExecutorPoolWebController {
// Add the content type as a response header
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.add(HttpHeaders.CONTENT_TYPE, ExecutorMediaType.EXECUTOR_MEDIA_TYPE);
responseHeaders.add(HttpHeaders.CONTENT_TYPE, ExecutorJsonRepresentation.EXECUTOR_MEDIA_TYPE);
return new ResponseEntity<>(ExecutorMediaType.serialize(executorClassList), responseHeaders, HttpStatus.OK);
return new ResponseEntity<>(ExecutorJsonRepresentation.serialize(executorClassList), responseHeaders, HttpStatus.OK);
}
}

View File

@ -1,5 +1,6 @@
package ch.unisg.executorpool.adapter.in.web;
import ch.unisg.executorpool.adapter.common.formats.ExecutorJsonRepresentation;
import ch.unisg.executorpool.application.port.in.RemoveExecutorFromExecutorPoolCommand;
import ch.unisg.executorpool.application.port.in.RemoveExecutorFromExecutorPoolUseCase;
import ch.unisg.executorpool.domain.ExecutorClass;
@ -11,6 +12,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.server.ResponseStatusException;
import java.net.URI;
import java.util.Optional;
@RestController
@ -21,9 +23,11 @@ public class RemoveExecutorFromExecutorPoolWebController {
this.removeExecutorFromExecutorPoolUseCase = removeExecutorFromExecutorPoolUseCase;
}
@PostMapping(path = "/executor-pool/RemoveExecutor", consumes = {ExecutorMediaType.EXECUTOR_MEDIA_TYPE})
public ResponseEntity<String> removeExecutorFromExecutorPool(@RequestBody ExecutorClass executorClass){
RemoveExecutorFromExecutorPoolCommand command = new RemoveExecutorFromExecutorPoolCommand(executorClass.getExecutorIp(), executorClass.getExecutorPort());
@PostMapping(path = "/executor-pool/RemoveExecutor", consumes = {ExecutorJsonRepresentation.EXECUTOR_MEDIA_TYPE})
public ResponseEntity<String> removeExecutorFromExecutorPool(@RequestBody ExecutorJsonRepresentation executorJsonRepresentation){
RemoveExecutorFromExecutorPoolCommand command = new RemoveExecutorFromExecutorPoolCommand(
new ExecutorClass.ExecutorUri(URI.create(executorJsonRepresentation.getExecutorUri()))
);
Optional<ExecutorClass> removedExecutor = removeExecutorFromExecutorPoolUseCase.removeExecutorFromExecutorPool(command);
if(removedExecutor.isEmpty()){
@ -31,9 +35,9 @@ public class RemoveExecutorFromExecutorPoolWebController {
}
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.add(HttpHeaders.CONTENT_TYPE, ExecutorMediaType.EXECUTOR_MEDIA_TYPE);
responseHeaders.add(HttpHeaders.CONTENT_TYPE, ExecutorJsonRepresentation.EXECUTOR_MEDIA_TYPE);
return new ResponseEntity<>(ExecutorMediaType.serialize(removedExecutor.get()), responseHeaders,
return new ResponseEntity<>(ExecutorJsonRepresentation.serialize(removedExecutor.get()), responseHeaders,
HttpStatus.OK);
}
}

View File

@ -0,0 +1,43 @@
package ch.unisg.executorpool.adapter.out.messaging;
import ch.unisg.common.ConfigProperties;
import ch.unisg.executorpool.adapter.common.clients.TapasMqttClient;
import ch.unisg.executorpool.adapter.common.formats.ExecutorJsonRepresentation;
import ch.unisg.executorpool.application.port.out.ExecutorAddedEventPort;
import ch.unisg.executorpool.domain.ExecutorAddedEvent;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import java.net.URI;
@Component
@Primary
public class PublishExecutorAddedEventAdapter implements ExecutorAddedEventPort {
private static final Logger LOGGER = LogManager.getLogger(PublishExecutorAddedEventAdapter.class);
// TODO Can't autowire. Find fix
/*
@Autowired
private ConfigProperties config;
*/
@Autowired
private Environment environment;
@Override
public void publishExecutorAddedEvent(ExecutorAddedEvent event){
try{
var mqttClient = TapasMqttClient.getInstance(environment.getProperty("mqtt.broker.uri"));
mqttClient.publishMessage("ch/unisg/tapas/executors/added", ExecutorJsonRepresentation.serialize(event.getExecutorClass()));
}
catch (MqttException e){
LOGGER.error(e.getMessage(), e);
}
}
}

View File

@ -0,0 +1,41 @@
package ch.unisg.executorpool.adapter.out.messaging;
import ch.unisg.executorpool.adapter.common.clients.TapasMqttClient;
import ch.unisg.executorpool.adapter.common.formats.ExecutorJsonRepresentation;
import ch.unisg.executorpool.application.port.out.ExecutorRemovedEventPort;
import ch.unisg.executorpool.domain.ExecutorAddedEvent;
import ch.unisg.executorpool.domain.ExecutorRemovedEvent;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
@Component
@Primary
public class PublishExecutorRemovedEventAdapter implements ExecutorRemovedEventPort {
private static final Logger LOGGER = LogManager.getLogger(PublishExecutorAddedEventAdapter.class);
// TODO Can't autowire. Find fix
/*
@Autowired
private ConfigProperties config;
*/
@Autowired
private Environment environment;
@Override
public void publishExecutorRemovedEvent(ExecutorRemovedEvent event){
try{
var mqttClient = TapasMqttClient.getInstance(environment.getProperty("mqtt.broker.uri"));
mqttClient.publishMessage("ch/unisg/tapas/executors/removed", ExecutorJsonRepresentation.serialize(event.getExecutorClass()));
}
catch (MqttException e){
LOGGER.error(e.getMessage(), e);
}
}
}

View File

@ -2,8 +2,7 @@ package ch.unisg.executorpool.application.port.in;
import ch.unisg.common.SelfValidating;
import ch.unisg.executorpool.domain.ExecutorPool;
import ch.unisg.executorpool.domain.ExecutorClass.ExecutorIp;
import ch.unisg.executorpool.domain.ExecutorClass.ExecutorPort;
import ch.unisg.executorpool.domain.ExecutorClass.ExecutorUri;
import ch.unisg.executorpool.domain.ExecutorClass.ExecutorTaskType;
import lombok.Value;
import javax.validation.constraints.NotNull;
@ -11,17 +10,13 @@ import javax.validation.constraints.NotNull;
@Value
public class AddNewExecutorToExecutorPoolCommand extends SelfValidating<AddNewExecutorToExecutorPoolCommand> {
@NotNull
private final ExecutorIp executorIp;
@NotNull
private final ExecutorPort executorPort;
private final ExecutorUri executorUri;
@NotNull
private final ExecutorTaskType executorTaskType;
public AddNewExecutorToExecutorPoolCommand(ExecutorIp executorIp, ExecutorPort executorPort, ExecutorTaskType executorTaskType){
this.executorIp = executorIp;
this.executorPort = executorPort;
public AddNewExecutorToExecutorPoolCommand(ExecutorUri executorUri, ExecutorTaskType executorTaskType){
this.executorUri = executorUri;
this.executorTaskType = executorTaskType;
this.validateSelf();
}

View File

@ -1,9 +0,0 @@
package ch.unisg.executorpool.application.port.in;
import ch.unisg.executorpool.domain.ExecutorClass;
import java.util.List;
public interface GetAllExecutorInExecutorPoolByTypeUseCase {
List<ExecutorClass> getAllExecutorInExecutorPoolByType(GetAllExecutorInExecutorPoolByTypeQuery query);
}

View File

@ -7,11 +7,11 @@ import lombok.Value;
import javax.validation.constraints.NotNull;
@Value
public class GetAllExecutorInExecutorPoolByTypeQuery extends SelfValidating<GetAllExecutorInExecutorPoolByTypeQuery> {
public class GetAllExecutorsInExecutorPoolByTypeQuery extends SelfValidating<GetAllExecutorsInExecutorPoolByTypeQuery> {
@NotNull
private final ExecutorTaskType executorTaskType;
public GetAllExecutorInExecutorPoolByTypeQuery(ExecutorTaskType executorTaskType){
public GetAllExecutorsInExecutorPoolByTypeQuery(ExecutorTaskType executorTaskType){
this.executorTaskType = executorTaskType;
this.validateSelf();
}

View File

@ -0,0 +1,9 @@
package ch.unisg.executorpool.application.port.in;
import ch.unisg.executorpool.domain.ExecutorClass;
import java.util.List;
public interface GetAllExecutorsInExecutorPoolByTypeUseCase {
List<ExecutorClass> getAllExecutorsInExecutorPoolByType(GetAllExecutorsInExecutorPoolByTypeQuery query);
}

View File

@ -1,9 +1,7 @@
package ch.unisg.executorpool.application.port.in;
import ch.unisg.executorpool.domain.ExecutorClass;
import ch.unisg.common.SelfValidating;
import ch.unisg.executorpool.domain.ExecutorClass.ExecutorIp;
import ch.unisg.executorpool.domain.ExecutorClass.ExecutorPort;
import ch.unisg.executorpool.domain.ExecutorClass.ExecutorUri;
import lombok.Value;
import javax.validation.constraints.NotNull;
@ -11,14 +9,10 @@ import javax.validation.constraints.NotNull;
@Value
public class RemoveExecutorFromExecutorPoolCommand extends SelfValidating<RemoveExecutorFromExecutorPoolCommand> {
@NotNull
private final ExecutorIp executorIp;
private final ExecutorUri executorUri;
@NotNull
private final ExecutorPort executorPort;
public RemoveExecutorFromExecutorPoolCommand(ExecutorIp executorIp, ExecutorPort executorPort){
this.executorIp = executorIp;
this.executorPort = executorPort;
public RemoveExecutorFromExecutorPoolCommand(ExecutorUri executorUri){
this.executorUri = executorUri;
this.validateSelf();
}
}

View File

@ -0,0 +1,8 @@
package ch.unisg.executorpool.application.port.out;
import ch.unisg.executorpool.domain.ExecutorAddedEvent;
import org.eclipse.paho.client.mqttv3.MqttException;
public interface ExecutorAddedEventPort {
void publishExecutorAddedEvent(ExecutorAddedEvent event);
}

View File

@ -0,0 +1,7 @@
package ch.unisg.executorpool.application.port.out;
import ch.unisg.executorpool.domain.ExecutorRemovedEvent;
public interface ExecutorRemovedEventPort {
void publishExecutorRemovedEvent(ExecutorRemovedEvent event);
}

View File

@ -2,24 +2,33 @@ 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.application.port.out.ExecutorAddedEventPort;
import ch.unisg.executorpool.domain.ExecutorAddedEvent;
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 {
private final ExecutorAddedEventPort executorAddedEventPort;
public AddNewExecutorToExecutorPoolService(ExecutorAddedEventPort executorAddedEventPort){
this.executorAddedEventPort = executorAddedEventPort;
}
@Override
public ExecutorClass addNewExecutorToExecutorPool(AddNewExecutorToExecutorPoolCommand command){
ExecutorPool executorPool = ExecutorPool.getExecutorPool();
var newExecutor = executorPool.addNewExecutor(command.getExecutorUri(), command.getExecutorTaskType());
return executorPool.addNewExecutor(command.getExecutorIp(), command.getExecutorPort(), command.getExecutorTaskType());
var executorAddedEvent = new ExecutorAddedEvent(newExecutor);
executorAddedEventPort.publishExecutorAddedEvent(executorAddedEvent);
return newExecutor;
}
}

View File

@ -1,7 +1,7 @@
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.application.port.in.GetAllExecutorsInExecutorPoolByTypeQuery;
import ch.unisg.executorpool.application.port.in.GetAllExecutorsInExecutorPoolByTypeUseCase;
import ch.unisg.executorpool.domain.ExecutorClass;
import ch.unisg.executorpool.domain.ExecutorPool;
import lombok.RequiredArgsConstructor;
@ -13,10 +13,10 @@ import java.util.List;
@RequiredArgsConstructor
@Component
@Transactional
public class GetAllExecutorInExecutorPoolByTypeService implements GetAllExecutorInExecutorPoolByTypeUseCase {
public class GetAllExecutorsInExecutorPoolByTypeService implements GetAllExecutorsInExecutorPoolByTypeUseCase {
@Override
public List<ExecutorClass> getAllExecutorInExecutorPoolByType(GetAllExecutorInExecutorPoolByTypeQuery query){
public List<ExecutorClass> getAllExecutorsInExecutorPoolByType(GetAllExecutorsInExecutorPoolByTypeQuery query){
ExecutorPool executorPool = ExecutorPool.getExecutorPool();
return executorPool.getAllExecutorsByType(query.getExecutorTaskType());
}

View File

@ -2,21 +2,36 @@ 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.application.port.out.ExecutorRemovedEventPort;
import ch.unisg.executorpool.domain.ExecutorClass;
import ch.unisg.executorpool.domain.ExecutorPool;
import ch.unisg.executorpool.domain.ExecutorRemovedEvent;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import javax.transaction.Transactional;
import java.util.Optional;
@RequiredArgsConstructor
@Component
@Transactional
public class RemoveExecutorFromExecutorPoolService implements RemoveExecutorFromExecutorPoolUseCase {
private final ExecutorRemovedEventPort executorRemovedEventPort;
public RemoveExecutorFromExecutorPoolService(ExecutorRemovedEventPort executorRemovedEventPort){
this.executorRemovedEventPort = executorRemovedEventPort;
}
@Override
public Optional<ExecutorClass> removeExecutorFromExecutorPool(RemoveExecutorFromExecutorPoolCommand command){
ExecutorPool executorPool = ExecutorPool.getExecutorPool();
return executorPool.removeExecutorByIpAndPort(command.getExecutorIp(), command.getExecutorPort());
var removedExecutor = executorPool.removeExecutorByIpAndPort(command.getExecutorUri());
if(removedExecutor.isPresent()){
var executorRemovedEvent = new ExecutorRemovedEvent(removedExecutor.get());
executorRemovedEventPort.publishExecutorRemovedEvent(executorRemovedEvent);
}
return removedExecutor;
}
}

View File

@ -0,0 +1,10 @@
package ch.unisg.executorpool.domain;
import lombok.Getter;
public class ExecutorAddedEvent {
@Getter
private ExecutorClass executorClass;
public ExecutorAddedEvent(ExecutorClass executorClass) { this.executorClass = executorClass; }
}

View File

@ -3,36 +3,29 @@ package ch.unisg.executorpool.domain;
import lombok.Getter;
import lombok.Value;
import java.net.URI;
public class ExecutorClass {
@Getter
private final ExecutorIp executorIp;
@Getter
private final ExecutorPort executorPort;
private final ExecutorUri executorUri;
@Getter
private final ExecutorTaskType executorTaskType;
public ExecutorClass(ExecutorIp executorIp, ExecutorPort executorPort, ExecutorTaskType executorTaskType){
this.executorIp = executorIp;
this.executorPort = executorPort;
public ExecutorClass(ExecutorUri executorUri, ExecutorTaskType executorTaskType){
this.executorUri = executorUri;
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);
protected static ExecutorClass createExecutorClass(ExecutorUri executorUri, ExecutorTaskType executorTaskType){
System.out.println("New Executor: " + executorUri.value.toString() + " " + executorTaskType.getValue());
return new ExecutorClass(executorUri, executorTaskType);
}
@Value
public static class ExecutorIp {
private String value;
}
@Value
public static class ExecutorPort {
private String value;
public static class ExecutorUri {
private URI value;
}
@Value

View File

@ -1,5 +1,8 @@
package ch.unisg.executorpool.domain;
import ch.unisg.executorpool.domain.ExecutorClass.ExecutorUri;
import ch.unisg.executorpool.domain.ExecutorClass.ExecutorTaskType;
import lombok.Getter;
import lombok.Value;
@ -20,19 +23,17 @@ public class ExecutorPool {
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);
public ExecutorClass addNewExecutor(ExecutorUri executorUri, ExecutorTaskType executorTaskType){
ExecutorClass newExecutor = ExecutorClass.createExecutorClass(executorUri, executorTaskType);
listOfExecutors.value.add(newExecutor);
System.out.println("Number of executors: " + listOfExecutors.value.size());
return newExecutor;
}
public Optional<ExecutorClass> getExecutorByIpAndPort(ExecutorClass.ExecutorIp executorIp, ExecutorClass.ExecutorPort executorPort){
public Optional<ExecutorClass> getExecutorByUri(ExecutorUri executorUri){
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())){
if(executor.getExecutorUri().getValue().equals(executorUri)){
return Optional.of(executor);
}
}
@ -54,11 +55,10 @@ public class ExecutorPool {
return matchedExecutors;
}
public Optional<ExecutorClass> removeExecutorByIpAndPort(ExecutorClass.ExecutorIp executorIp, ExecutorClass.ExecutorPort executorPort){
public Optional<ExecutorClass> removeExecutorByIpAndPort(ExecutorUri executorUri){
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())){
if(executor.getExecutorUri().getValue().equals(executorUri.getValue())){
listOfExecutors.value.remove(executor);
return Optional.of(executor);
}

View File

@ -0,0 +1,11 @@
package ch.unisg.executorpool.domain;
import ch.unisg.executorpool.domain.ExecutorClass;
import lombok.Getter;
public class ExecutorRemovedEvent {
@Getter
private ExecutorClass executorClass;
public ExecutorRemovedEvent(ExecutorClass executorClass) { this.executorClass = executorClass; }
}

View File

@ -1 +1,3 @@
server.port=8083
mqtt.broker.uri=tcp://broker.hivemq.com:1883

Some files were not shown because too many files have changed in this diff Show More