Persistency Bugfixes #86

Merged
Maece97 merged 1 commits from persistency-bugfixes into dev 2021-11-25 14:58:12 +00:00
21 changed files with 215 additions and 105 deletions
Showing only changes of commit 3c35f84913 - Show all commits

View File

@ -26,14 +26,28 @@ services:
- "traefik.http.routers.http-catchall.middlewares=redirect-to-https" - "traefik.http.routers.http-catchall.middlewares=redirect-to-https"
- "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https" - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
tapas-db:
image: mongo
restart: unless-stopped
container_name: tapas_mongodb
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: password
ports:
- "27017:27017"
command: mongod --quiet --logpath /dev/null
tapas-tasks: tapas-tasks:
image: openjdk image: openjdk
command: "java -jar /data/tapas-tasks-0.0.1-SNAPSHOT.jar" command: "java -jar /data/tapas-tasks-0.0.1-SNAPSHOT.jar"
restart: unless-stopped restart: unless-stopped
depends_on:
- tapas-db
volumes: volumes:
- ./:/data/ - ./:/data/
environment: environment:
roster.uri: http://roster:8082 roster.uri: http://roster:8082
spring.data.mongodb.uri: mongodb://root:password@mongodb:27017
labels: labels:
- "traefik.enable=true" - "traefik.enable=true"
- "traefik.http.routers.tapas-tasks.rule=Host(`tapas-tasks.${PUB_IP}.nip.io`)" - "traefik.http.routers.tapas-tasks.rule=Host(`tapas-tasks.${PUB_IP}.nip.io`)"
@ -47,6 +61,8 @@ services:
image: openjdk image: openjdk
command: "java -jar /data/tapas-auction-house-0.0.1-SNAPSHOT.jar" command: "java -jar /data/tapas-auction-house-0.0.1-SNAPSHOT.jar"
restart: unless-stopped restart: unless-stopped
depends_on:
- tapas-db
volumes: volumes:
- ./:/data/ - ./:/data/
environment: environment:
@ -64,6 +80,8 @@ services:
image: openjdk image: openjdk
command: "java -jar /data/roster-0.0.1-SNAPSHOT.jar" command: "java -jar /data/roster-0.0.1-SNAPSHOT.jar"
restart: unless-stopped restart: unless-stopped
depends_on:
- tapas-db
volumes: volumes:
- ./:/data/ - ./:/data/
environment: environment:
@ -71,6 +89,7 @@ services:
executor-robot.uri: http://executor-robot:8084 executor-robot.uri: http://executor-robot:8084
executor-computation.uri: http://executor-computation:8085 executor-computation.uri: http://executor-computation:8085
mqtt.broker.uri: tcp://broker.hivemq.com:1883 mqtt.broker.uri: tcp://broker.hivemq.com:1883
spring.data.mongodb.uri: mongodb://root:password@mongodb:27017
labels: labels:
- "traefik.enable=true" - "traefik.enable=true"
- "traefik.http.routers.roster.rule=Host(`roster.${PUB_IP}.nip.io`)" - "traefik.http.routers.roster.rule=Host(`roster.${PUB_IP}.nip.io`)"
@ -84,10 +103,13 @@ services:
image: openjdk image: openjdk
command: "java -jar /data/executor-pool-0.0.1-SNAPSHOT.jar" command: "java -jar /data/executor-pool-0.0.1-SNAPSHOT.jar"
restart: unless-stopped restart: unless-stopped
depends_on:
- tapas-db
volumes: volumes:
- ./:/data/ - ./:/data/
environment: environment:
mqtt.broker.uri: tcp://broker.hivemq.com:1883 mqtt.broker.uri: tcp://broker.hivemq.com:1883
spring.data.mongodb.uri: mongodb://root:password@mongodb:27017
labels: labels:
- "traefik.enable=true" - "traefik.enable=true"
- "traefik.http.routers.executor-pool.rule=Host(`executor-pool.${PUB_IP}.nip.io`)" - "traefik.http.routers.executor-pool.rule=Host(`executor-pool.${PUB_IP}.nip.io`)"
@ -104,6 +126,7 @@ services:
depends_on: depends_on:
- executor-pool - executor-pool
- roster - roster
- tapas-db
volumes: volumes:
- ./:/data/ - ./:/data/
environment: environment:
@ -124,6 +147,7 @@ services:
depends_on: depends_on:
- executor-pool - executor-pool
- roster - roster
- tapas-db
volumes: volumes:
- ./:/data/ - ./:/data/
environment: environment:

View File

@ -1,62 +1,77 @@
version: "3.6" version: "3.6"
services: services:
tapas-tasks: # tapas-tasks:
container_name: tapas-tasks # container_name: tapas-tasks
build: # build:
context: "./tapas-tasks" # context: "./tapas-tasks"
dockerfile: "Dockerfile" # dockerfile: "Dockerfile"
target: development # target: development
# ports:
# - "8081:8081"
# - "5005:5005"
# volumes:
# - ./tapas-tasks/src:/opt/app/src
# - ./tapas-tasks/target:/opt/app/target
# assignment:
# container_name: assignment
# build:
# context: "./assignment"
# dockerfile: "Dockerfile"
# target: development
# ports:
# - "8082:8082"
# - "5006:5005"
# volumes:
# - ./assignment/src:/opt/app/src
# - ./assignment/target:/opt/app/target
# executor-pool:
# container_name: executor-pool
# build:
# context: "./executor-pool"
# dockerfile: "Dockerfile"
# target: development
# ports:
# - "8083:8083"
# - "5007:5005"
# volumes:
# - ./executor-pool/src:/opt/app/src
# - ./executor-pool/target:/opt/app/target
# executor1:
# container_name: executor1
# build:
# context: "./executor1"
# dockerfile: "Dockerfile"
# target: development
# ports:
# - "8084:8084"
# - "5008:5005"
# volumes:
# - ./executor1/src:/opt/app/src
# - ./executor1/target:/opt/app/target
# executor2:
# container_name: executor2
# build:
# context: "./executor2"
# dockerfile: "Dockerfile"
# target: development
# ports:
# - "8085:8085"
# - "5009:5005"
# volumes:
# - ./executor2/src:/opt/app/src
# - ./executor2/target:/opt/app/target
tapas-db:
image: mongo
restart: unless-stopped
container_name: tapas_mongodb
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: password
ports: ports:
- "8081:8081" - "27017:27017"
- "5005:5005" command: mongod --quiet --logpath /dev/null
volumes: hivemq:
- ./tapas-tasks/src:/opt/app/src image: hivemq/hivemq4
- ./tapas-tasks/target:/opt/app/target restart: unless-stopped
assignment:
container_name: assignment
build:
context: "./assignment"
dockerfile: "Dockerfile"
target: development
ports: ports:
- "8082:8082" - "1883:1883"
- "5006:5005"
volumes:
- ./assignment/src:/opt/app/src
- ./assignment/target:/opt/app/target
executor-pool:
container_name: executor-pool
build:
context: "./executor-pool"
dockerfile: "Dockerfile"
target: development
ports:
- "8083:8083"
- "5007:5005"
volumes:
- ./executor-pool/src:/opt/app/src
- ./executor-pool/target:/opt/app/target
executor1:
container_name: executor1
build:
context: "./executor1"
dockerfile: "Dockerfile"
target: development
ports:
- "8084:8084"
- "5008:5005"
volumes:
- ./executor1/src:/opt/app/src
- ./executor1/target:/opt/app/target
executor2:
container_name: executor2
build:
context: "./executor2"
dockerfile: "Dockerfile"
target: development
ports:
- "8085:8085"
- "5009:5005"
volumes:
- ./executor2/src:/opt/app/src
- ./executor2/target:/opt/app/target

View File

@ -34,11 +34,11 @@ public class Executor extends ExecutorBase {
double result = Double.NaN; double result = Double.NaN;
// try { try {
// TimeUnit.SECONDS.sleep(5); TimeUnit.SECONDS.sleep(5);
// } catch (InterruptedException e) { } catch (InterruptedException e) {
// e.printStackTrace(); e.printStackTrace();
// } }
if (operator.equalsIgnoreCase("+")) { if (operator.equalsIgnoreCase("+")) {
String[] parts = inputData.split("\\+"); String[] parts = inputData.split("\\+");

View File

@ -1,13 +1,31 @@
package ch.unisg.executorpool; package ch.unisg.executorpool;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
import ch.unisg.executorpool.adapter.out.persistence.mongodb.ExecutorRepository;
import ch.unisg.executorpool.application.port.out.LoadExecutorPort;
import ch.unisg.executorpool.domain.ExecutorPool;
@SpringBootApplication @SpringBootApplication
@EnableMongoRepositories(basePackageClasses = ExecutorRepository.class)
public class ExecutorPoolApplication { public class ExecutorPoolApplication {
@Autowired
private LoadExecutorPort loadExecutorPort;
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(ExecutorPoolApplication.class, args); SpringApplication.run(ExecutorPoolApplication.class, args);
} }
@PostConstruct
public void initializeExecutorPool() {
// Is this allowed in main or does it need to be in a service?
ExecutorPool.getExecutorPool().initExecutorPool(loadExecutorPort.loadAllExecutors());
}
} }

View File

@ -1,5 +1,8 @@
package ch.unisg.executorpool.adapter.out.persistence.mongodb; package ch.unisg.executorpool.adapter.out.persistence.mongodb;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -12,7 +15,7 @@ import lombok.RequiredArgsConstructor;
@Component @Component
@RequiredArgsConstructor @RequiredArgsConstructor
public class ExecutorPersistenceAdapter implements AddExecutorPort, RemoveExecutorPort, LoadExecutorPort { public class ExecutorPersistenceAdapter implements AddExecutorPort, RemoveExecutorPort, LoadExecutorPort {
@Autowired @Autowired
private final ExecutorRepository executorRepository; private final ExecutorRepository executorRepository;
@ -26,8 +29,7 @@ public class ExecutorPersistenceAdapter implements AddExecutorPort, RemoveExecut
@Override @Override
public void removeExecutor(ExecutorClass executorClass) { public void removeExecutor(ExecutorClass executorClass) {
MongoExecutorDocument mongoExecutorDocument = executorMapper.mapToMongoDocument(executorClass); executorRepository.deleteByExecutorUri(executorClass.getExecutorUri().getValue().toString());
executorRepository.delete(mongoExecutorDocument);
} }
@Override @Override
@ -37,4 +39,13 @@ public class ExecutorPersistenceAdapter implements AddExecutorPort, RemoveExecut
return executorClass; return executorClass;
} }
@Override
public List<ExecutorClass> loadAllExecutors() {
List<ExecutorClass> executorClasses = new ArrayList<>();
for (MongoExecutorDocument exe : executorRepository.findAll()) {
executorClasses.add(executorMapper.mapToDomainEntity(exe));
}
return executorClasses;
}
} }

View File

@ -11,5 +11,7 @@ public interface ExecutorRepository extends MongoRepository<MongoExecutorDocumen
public MongoExecutorDocument findByExecutorUri(String executorUri, String executorTaskType); public MongoExecutorDocument findByExecutorUri(String executorUri, String executorTaskType);
public List<MongoExecutorDocument> findByExecutorTaskType(String executorTaskType); public List<MongoExecutorDocument> findByExecutorTaskType(String executorTaskType);
public void deleteByExecutorUri(String executorUri);
} }

View File

@ -1,15 +1,18 @@
package ch.unisg.executorpool.adapter.out.persistence.mongodb; package ch.unisg.executorpool.adapter.out.persistence.mongodb;
import org.springframework.data.mongodb.core.mapping.Document;
import lombok.Data; import lombok.Data;
@Data @Data
@Document(collection = "executors")
public class MongoExecutorDocument { public class MongoExecutorDocument {
public String executorUri; public String executorUri;
public String executorTaskType; public String executorTaskType;
public MongoExecutorDocument(String executorUri, String executorTaskType) { public MongoExecutorDocument(String executorUri, String executorTaskType) {
this.executorUri = executorUri; this.executorUri = executorUri;
this.executorTaskType = executorTaskType; this.executorTaskType = executorTaskType;
} }

View File

@ -1,9 +1,13 @@
package ch.unisg.executorpool.application.port.out; package ch.unisg.executorpool.application.port.out;
import java.util.List;
import ch.unisg.executorpool.domain.ExecutorClass; import ch.unisg.executorpool.domain.ExecutorClass;
public interface LoadExecutorPort { public interface LoadExecutorPort {
ExecutorClass loadExecutor(ExecutorClass.ExecutorUri executorUri, ExecutorClass.ExecutorTaskType executorTaskType); ExecutorClass loadExecutor(ExecutorClass.ExecutorUri executorUri, ExecutorClass.ExecutorTaskType executorTaskType);
List<ExecutorClass> loadAllExecutors();
} }

View File

@ -31,11 +31,10 @@ public class RemoveExecutorFromExecutorPoolService implements RemoveExecutorFrom
if(removedExecutor.isPresent()){ if(removedExecutor.isPresent()){
var executorRemovedEvent = new ExecutorRemovedEvent(removedExecutor.get()); var executorRemovedEvent = new ExecutorRemovedEvent(removedExecutor.get());
removeExecutorFromRepositoryPort.removeExecutor(removedExecutor.get());
executorRemovedEventPort.publishExecutorRemovedEvent(executorRemovedEvent); executorRemovedEventPort.publishExecutorRemovedEvent(executorRemovedEvent);
} }
removeExecutorFromRepositoryPort.removeExecutor(removedExecutor);
return removedExecutor; return removedExecutor;
} }
} }

View File

@ -67,6 +67,12 @@ public class ExecutorPool {
return Optional.empty(); return Optional.empty();
} }
public void initExecutorPool(List<ExecutorClass> executors){
for (ExecutorClass executor : executors) {
listOfExecutors.value.add(executor);
}
}
@Value @Value
public static class ListOfExecutors { public static class ListOfExecutors {
private List<ExecutorClass> value; private List<ExecutorClass> value;

View File

@ -1,3 +1,6 @@
server.port=8083 server.port=8083
mqtt.broker.uri=tcp://localhost:1883 mqtt.broker.uri=tcp://localhost:1883
spring.data.mongodb.uri=mongodb://root:password@localhost:27017
spring.data.mongodb.database=tapas-executors

View File

@ -76,6 +76,11 @@
<dependency> <dependency>
<groupId>org.springframework.data</groupId> <groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId> <artifactId>spring-data-mongodb</artifactId>
<version>3.2.6</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency> </dependency>

View File

@ -4,11 +4,14 @@ import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.annotation.PostConstruct;
import ch.unisg.roster.roster.adapter.out.persistence.mongodb.RosterRepository; import ch.unisg.roster.roster.adapter.out.persistence.mongodb.RosterRepository;
import ch.unisg.roster.roster.application.port.in.LoadRosterItemPort; import ch.unisg.roster.roster.application.port.in.LoadRosterItemPort;
import ch.unisg.roster.roster.domain.Roster; import ch.unisg.roster.roster.domain.Roster;
import ch.unisg.roster.roster.domain.RosterItem; import ch.unisg.roster.roster.domain.RosterItem;
import org.eclipse.paho.client.mqttv3.MqttException; import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.ConfigurableEnvironment;
@ -26,14 +29,14 @@ public class RosterApplication {
private static ConfigurableEnvironment ENVIRONMENT; private static ConfigurableEnvironment ENVIRONMENT;
private static final LoadRosterItemPort loadRosterItemPort; @Autowired
private LoadRosterItemPort loadRosterItemPort;
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication rosterApp = new SpringApplication(RosterApplication.class); SpringApplication rosterApp = new SpringApplication(RosterApplication.class);
ENVIRONMENT = rosterApp.run(args).getEnvironment(); ENVIRONMENT = rosterApp.run(args).getEnvironment();
bootstrapMarketplaceWithMqtt(); bootstrapMarketplaceWithMqtt();
initialiseRoster();
} }
/** /**
@ -52,9 +55,9 @@ public class RosterApplication {
} }
} }
private static void initialiseRoster(){ @PostConstruct
List<RosterItem> rosterItemList = loadRosterItemPort.loadAllRosterItems(); private void initialiseRoster(){
Roster.getInstance().initialiseRoster(rosterItemList); Roster.getInstance().initialiseRoster(loadRosterItemPort.loadAllRosterItems());
} }
} }

View File

@ -1,6 +1,5 @@
package ch.unisg.roster.roster.adapter.out.persistence.mongodb; package ch.unisg.roster.roster.adapter.out.persistence.mongodb;
import ch.unisg.roster.roster.application.port.in.AddRosterItemPort; import ch.unisg.roster.roster.application.port.in.AddRosterItemPort;
import ch.unisg.roster.roster.application.port.in.DeleteRosterItem; import ch.unisg.roster.roster.application.port.in.DeleteRosterItem;
import ch.unisg.roster.roster.application.port.in.LoadRosterItemPort; import ch.unisg.roster.roster.application.port.in.LoadRosterItemPort;

View File

@ -3,3 +3,6 @@ executor-robot.uri=http://127.0.0.1:8084
executor-computation.uri=http://127.0.0.1:8085 executor-computation.uri=http://127.0.0.1:8085
task-list.uri=http://127.0.0.1:8081 task-list.uri=http://127.0.0.1:8081
mqtt.broker.uri=tcp://localhost:1883 mqtt.broker.uri=tcp://localhost:1883
spring.data.mongodb.uri=mongodb://root:password@localhost:27017/
spring.data.mongodb.database=tapas-roster

View File

@ -15,18 +15,23 @@ public class MongoTaskDocument {
public String taskType; public String taskType;
public String originalTaskUri; public String originalTaskUri;
public String taskStatus; public String taskStatus;
public String inputData;
public String outputData;
public String taskListName; public String taskListName;
public MongoTaskDocument(String taskId, String taskName, String taskType, public MongoTaskDocument(String taskId, String taskName, String taskType,
String originalTaskUri, String originalTaskUri,
String taskStatus, String taskListName) { String taskStatus, String inputData, String outputData,
String taskListName) {
this.taskId = taskId; this.taskId = taskId;
this.taskName = taskName; this.taskName = taskName;
this.taskType = taskType; this.taskType = taskType;
this.originalTaskUri = originalTaskUri; this.originalTaskUri = originalTaskUri;
this.taskStatus = taskStatus; this.taskStatus = taskStatus;
this.inputData = inputData;
this.outputData = outputData;
this.taskListName = taskListName; this.taskListName = taskListName;
} }
} }

View File

@ -2,18 +2,23 @@ package ch.unisg.tapastasks.tasks.adapter.out.persistence.mongodb;
import ch.unisg.tapastasks.tasks.domain.Task; import ch.unisg.tapastasks.tasks.domain.Task;
import ch.unisg.tapastasks.tasks.domain.TaskList; import ch.unisg.tapastasks.tasks.domain.TaskList;
import java.util.Objects;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@Component @Component
class TaskMapper { class TaskMapper {
Task mapToDomainEntity(MongoTaskDocument task) { Task mapToDomainEntity(MongoTaskDocument task) {
return Task.withIdNameTypeOriginaluriStatus( return Task.createTaskWithIdNameTypeOriginaluriStatusInputAndOutputData(
new Task.TaskId(task.taskId), new Task.TaskId(task.taskId),
new Task.TaskName(task.taskName), new Task.TaskName(task.taskName),
new Task.TaskType(task.taskType), new Task.TaskType(task.taskType),
new Task.OriginalTaskUri(task.originalTaskUri), new Task.OriginalTaskUri(task.originalTaskUri),
new Task.TaskStatus(Task.Status.valueOf(task.taskStatus)) new Task.TaskStatus(Task.Status.valueOf(task.taskStatus)),
new Task.InputData(task.inputData),
new Task.OutputData(task.outputData)
); );
} }
@ -22,8 +27,10 @@ class TaskMapper {
task.getTaskId().getValue(), task.getTaskId().getValue(),
task.getTaskName().getValue(), task.getTaskName().getValue(),
task.getTaskType().getValue(), task.getTaskType().getValue(),
task.getOriginalTaskUri().getValue(), Objects.isNull(task.getOriginalTaskUri()) ? null : task.getOriginalTaskUri().getValue(),
task.getTaskStatus().getValue().toString(), task.getTaskStatus().getValue().toString(),
Objects.isNull(task.getInputData()) ? null : task.getInputData().getValue(),
Objects.isNull(task.getOutputData()) ? null : task.getOutputData().getValue(),
TaskList.getTapasTaskList().getTaskListName().getValue() TaskList.getTapasTaskList().getTaskListName().getValue()
); );
} }

View File

@ -13,6 +13,8 @@ import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Objects;
import javax.transaction.Transactional; import javax.transaction.Transactional;
@RequiredArgsConstructor @RequiredArgsConstructor
@ -29,7 +31,7 @@ public class AddNewTaskToTaskListService implements AddNewTaskToTaskListUseCase
public Task addNewTaskToTaskList(AddNewTaskToTaskListCommand command) { public Task addNewTaskToTaskList(AddNewTaskToTaskListCommand command) {
TaskList taskList = TaskList.getTapasTaskList(); TaskList taskList = TaskList.getTapasTaskList();
taskListLock.lockTaskList(taskList.getTaskListName()); // taskListLock.lockTaskList(taskList.getTaskListName());
Task newTask; Task newTask;
@ -47,7 +49,7 @@ public class AddNewTaskToTaskListService implements AddNewTaskToTaskListUseCase
} }
addTaskToRepositoryPort.addTask(newTask); addTaskToRepositoryPort.addTask(newTask);
taskListLock.releaseTaskList(taskList.getTaskListName()); // taskListLock.releaseTaskList(taskList.getTaskListName());
//Here we are using the application service to emit the domain event to the outside of the bounded context. //Here we are using the application service to emit the domain event to the outside of the bounded context.
//This event should be considered as a light-weight "integration event" to communicate with other services. //This event should be considered as a light-weight "integration event" to communicate with other services.
@ -60,7 +62,7 @@ public class AddNewTaskToTaskListService implements AddNewTaskToTaskListUseCase
taskList.getTaskListName().getValue(), taskList.getTaskListName().getValue(),
newTask.getTaskId().getValue(), newTask.getTaskId().getValue(),
newTask.getTaskType().getValue(), newTask.getTaskType().getValue(),
newTask.getInputData().getValue() Objects.isNull(newTask.getInputData()) ? null : newTask.getInputData().getValue()
); );
newTaskAddedEventPort.publishNewTaskAddedEvent(newTaskAdded); newTaskAddedEventPort.publishNewTaskAddedEvent(newTaskAdded);
} }

View File

@ -81,18 +81,18 @@ public class Task {
} }
public Task(TaskId taskId, TaskName taskName, TaskType taskType, OriginalTaskUri taskUri, public Task(TaskId taskId, TaskName taskName, TaskType taskType, OriginalTaskUri taskUri,
TaskStatus taskStatus) { TaskStatus taskStatus, InputData inputData, OutputData outputData) {
this.taskId = taskId; this.taskId = taskId;
this.taskName = taskName; this.taskName = taskName;
this.taskType = taskType; this.taskType = taskType;
this.originalTaskUri = taskUri; this.originalTaskUri = taskUri;
this.taskStatus = taskStatus; this.taskStatus = taskStatus;
this.inputData = null; this.inputData = inputData;
this.outputData = null; this.outputData = outputData;
} }
protected static Task createTaskWithNameAndType(TaskName name, TaskType type) { protected static Task createTaskWithNameAndType(TaskName name, TaskType type) {
return new Task(name, type); return new Task(name, type);
} }
public static Task createTaskWithNameAndTypeAndOriginalTaskUri(TaskName name, TaskType type, public static Task createTaskWithNameAndTypeAndOriginalTaskUri(TaskName name, TaskType type,
@ -110,11 +110,10 @@ this.outputData = null;
return new Task(name, type, originalTaskUri, inputData); return new Task(name, type, originalTaskUri, inputData);
} }
public static Task withIdNameTypeOriginaluriStatus(TaskId taskId, TaskName taskName, public static Task createTaskWithIdNameTypeOriginaluriStatusInputAndOutputData(TaskId taskId,
TaskType taskType, TaskName taskName, TaskType taskType, OriginalTaskUri originalTaskUri, TaskStatus taskStatus,
OriginalTaskUri originalTaskUri, InputData inputData, OutputData outputData) {
TaskStatus taskStatus) { return new Task(taskId, taskName, taskType, originalTaskUri, taskStatus, inputData, outputData);
return new Task(taskId, taskName, taskType, originalTaskUri, taskStatus);
} }
@Value @Value

View File

@ -74,9 +74,12 @@ public class TaskList {
//However, we skip this here as it makes the core even more complex (e.g., we have to implement a light-weight //However, we skip this here as it makes the core even more complex (e.g., we have to implement a light-weight
//domain event publisher and subscribers (see "Implementing Domain-Driven Design by V. Vernon, pp. 296ff). //domain event publisher and subscribers (see "Implementing Domain-Driven Design by V. Vernon, pp. 296ff).
listOfTasks.value.add(newTask); listOfTasks.value.add(newTask);
logger.log(Level.INFO, "New task created! Id: " + newTask.getTaskId().getValue() + String message = "New task created! Id: " + newTask.getTaskId().getValue() +
" | Name: " + newTask.getTaskName().getValue() + " | Name: " + newTask.getTaskName().getValue();
" | InputData: " + newTask.getInputData().getValue()); if (newTask.getInputData() != null) {
message += " | Input data: " + newTask.getInputData().getValue();
}
logger.log(Level.INFO, message);
logger.log(Level.INFO, "Number of tasks: {0}", listOfTasks.value.size()); logger.log(Level.INFO, "Number of tasks: {0}", listOfTasks.value.size());
} }

View File

@ -1,6 +1,5 @@
server.port=8081 server.port=8081
spring.data.mongodb.uri=mongodb://127.0.0.1:27017 spring.data.mongodb.uri=mongodb://root:password@localhost:27017/
#spring.data.mongodb.uri=mongodb://root:8nP7s0a@mongodb:27017/
spring.data.mongodb.database=tapas-tasks spring.data.mongodb.database=tapas-tasks
baseuri=https://tapas-tasks.86-119-34-23.nip.io/ baseuri=https://tapas-tasks.86-119-34-23.nip.io/