executor 2 change

This commit is contained in:
rahimiankeanu
2021-11-02 21:21:52 +01:00
parent d08a6d0b67
commit dacb5605d7
4 changed files with 25 additions and 12 deletions

View File

@@ -46,8 +46,8 @@ public class GetAssignmentAdapter implements GetAssignmentPort {
if (response.body().equals("")) {
return null;
}
return new Task(new JSONObject(response.body()).getString("taskID"));
JSONObject responseBody = new JSONObject(response.body());
return new Task(responseBody.getString("taskID"), responseBody.getString("input"));
} catch (IOException | InterruptedException e) {
logger.log(Level.SEVERE, e.getLocalizedMessage(), e);

View File

@@ -61,7 +61,7 @@ public abstract class ExecutorBase {
System.out.println("Starting execution");
this.status = ExecutorStatus.EXECUTING;
task.setResult(execution());
task.setResult(execution(task.getInput()));
executionFinishedEventPort.publishExecutionFinishedEvent(
new ExecutionFinishedEvent(task.getTaskID(), task.getResult(), "SUCCESS"));
@@ -70,6 +70,6 @@ public abstract class ExecutorBase {
getAssignment();
}
protected abstract String execution();
protected abstract String execution(String... input);
}

View File

@@ -12,8 +12,12 @@ public class Task {
@Setter
private String result;
public Task(String taskID) {
@Getter
private String[] input;
public Task(String taskID, String... input) {
this.taskID = taskID;
this.input = input;
}
}