assignment service + executor pool improvments
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package ch.unisg.executor2.executor.adapter.in.web;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import ch.unisg.executorBase.executor.application.port.in.TaskAvailableCommand;
|
||||
import ch.unisg.executorBase.executor.application.port.in.TaskAvailableUseCase;
|
||||
import ch.unisg.executorBase.executor.domain.ExecutorType;
|
||||
|
||||
@RestController
|
||||
public class TaskAvailableController {
|
||||
private final TaskAvailableUseCase taskAvailableUseCase;
|
||||
|
||||
public TaskAvailableController(TaskAvailableUseCase taskAvailableUseCase) {
|
||||
this.taskAvailableUseCase = taskAvailableUseCase;
|
||||
}
|
||||
|
||||
@GetMapping(path = "/newtask/{taskType}")
|
||||
public ResponseEntity<String> retrieveTaskFromTaskList(@PathVariable("taskType") String taskType) {
|
||||
|
||||
if (ExecutorType.contains(taskType.toUpperCase())) {
|
||||
TaskAvailableCommand command = new TaskAvailableCommand(
|
||||
ExecutorType.valueOf(taskType.toUpperCase()));
|
||||
taskAvailableUseCase.newTaskAvailable(command);
|
||||
}
|
||||
|
||||
// Add the content type as a response header
|
||||
HttpHeaders responseHeaders = new HttpHeaders();
|
||||
|
||||
return new ResponseEntity<>("OK", responseHeaders, HttpStatus.OK);
|
||||
}
|
||||
}
|
@@ -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();
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@ import ch.unisg.executorBase.executor.domain.ExecutorBase;
|
||||
import ch.unisg.executorBase.executor.domain.ExecutorType;
|
||||
|
||||
public class Executor extends ExecutorBase {
|
||||
|
||||
|
||||
private static final Executor executor = new Executor(ExecutorType.ADDITION);
|
||||
|
||||
public static Executor getExecutor() {
|
||||
@@ -19,7 +19,7 @@ public class Executor extends ExecutorBase {
|
||||
@Override
|
||||
protected
|
||||
String execution() {
|
||||
|
||||
|
||||
int a = 20;
|
||||
int b = 20;
|
||||
try {
|
||||
|
@@ -1 +1 @@
|
||||
server.port=8081
|
||||
server.port=8085
|
||||
|
Reference in New Issue
Block a user