fixes
This commit is contained in:
@@ -29,12 +29,9 @@ public class ExecutionFinishedEventAdapter implements ExecutionFinishedEventPort
|
||||
@Override
|
||||
public void publishExecutionFinishedEvent(ExecutionFinishedEvent event) {
|
||||
|
||||
System.out.println("HI");
|
||||
System.out.println(server);
|
||||
|
||||
String body = new JSONObject()
|
||||
.put("taskID", event.getTaskID())
|
||||
.put("result", event.getResult())
|
||||
.put("outputData", event.getOutputData())
|
||||
.put("status", event.getStatus())
|
||||
.toString();
|
||||
|
||||
@@ -46,8 +43,6 @@ public class ExecutionFinishedEventAdapter implements ExecutionFinishedEventPort
|
||||
.build();
|
||||
|
||||
|
||||
System.out.println(server);
|
||||
|
||||
try {
|
||||
client.send(request, HttpResponse.BodyHandlers.ofString());
|
||||
} catch (InterruptedException e) {
|
||||
@@ -57,7 +52,7 @@ public class ExecutionFinishedEventAdapter implements ExecutionFinishedEventPort
|
||||
logger.log(Level.SEVERE, e.getLocalizedMessage(), e);
|
||||
}
|
||||
|
||||
logger.log(Level.INFO, "Finish execution event sent with result: {0}", event.getResult());
|
||||
logger.log(Level.INFO, "Finish execution event sent with result: {0}", event.getOutputData());
|
||||
|
||||
}
|
||||
|
||||
|
@@ -58,9 +58,8 @@ public class GetAssignmentAdapter implements GetAssignmentPort {
|
||||
}
|
||||
JSONObject responseBody = new JSONObject(response.body());
|
||||
|
||||
String[] input = { "1", "+", "2" };
|
||||
// TODO Add input in roster + tasklist
|
||||
return new Task(responseBody.getString("taskID"), input);
|
||||
String inputData = responseBody.getString("inputData");
|
||||
return new Task(responseBody.getString("taskID"), inputData);
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
logger.log(Level.SEVERE, e.getLocalizedMessage(), e);
|
||||
|
@@ -8,14 +8,14 @@ public class ExecutionFinishedEvent {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@@ -71,13 +71,11 @@ public abstract class ExecutorBase {
|
||||
logger.info("Starting execution");
|
||||
this.status = ExecutorStatus.EXECUTING;
|
||||
|
||||
task.setResult(execution(task.getInput()));
|
||||
|
||||
System.out.println(task.getResult());
|
||||
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"));
|
||||
|
||||
logger.info("Finish execution");
|
||||
getAssignment();
|
||||
@@ -87,6 +85,6 @@ public abstract class ExecutorBase {
|
||||
* Implementation of the actual execution method of an executor
|
||||
* @return the execution result
|
||||
**/
|
||||
protected abstract String execution(String... input);
|
||||
protected abstract String execution(String input);
|
||||
|
||||
}
|
||||
|
@@ -10,14 +10,16 @@ public class Task {
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private String result;
|
||||
private String outputData;
|
||||
|
||||
// TODO maybe create a value object for inputData so we can make sure it is in the right
|
||||
// format.
|
||||
@Getter
|
||||
private String[] input;
|
||||
private String inputData;
|
||||
|
||||
public Task(String taskID, String... input) {
|
||||
public Task(String taskID, String inputData) {
|
||||
this.taskID = taskID;
|
||||
this.input = input;
|
||||
this.inputData= inputData;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user