diff --git a/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/core/BenchmarkJobManager.java b/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/core/BenchmarkJobManager.java index bc7edb19ad551d3fe98617cf49472910cfcea338..2c9e4317ea1352d4374240d7d0816769ecc86065 100644 --- a/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/core/BenchmarkJobManager.java +++ b/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/core/BenchmarkJobManager.java @@ -170,6 +170,8 @@ public class BenchmarkJobManager { if (tasks == null) { fillTasks(); } + // Carry on in output processing + processOutput(); return tasks; } @@ -203,8 +205,7 @@ public class BenchmarkJobManager { List<String> chronologicList = STATISTICS_TASK_NAME_MAP.keySet().stream().collect(Collectors.toList()); Collections.sort(tasks, Comparator.comparingInt(task -> chronologicList.indexOf(task.getDescription()))); - // Carry on in output processing - processOutput(); + } private void processOutput() { diff --git a/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/core/TaskComputation.java b/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/core/TaskComputation.java index 958ac5884870e61b7c53cefdc2339f83905c313f..c609a02b77507804b5949b2ac6a3be717a8d2f37 100644 --- a/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/core/TaskComputation.java +++ b/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/core/TaskComputation.java @@ -10,93 +10,98 @@ public class TaskComputation { private final SPIMComputationAccessor computationAccessor; private final int timepoint; - + private JobState state; private int positionInOutput; - + private Collection<String> inputs; + @SuppressWarnings("unused") private Collection<String> outputs; private Collection<String> logs; private Long id; - + /** - * Creates a TaskComputation object - * Note: At the time of creation, the job parameters are not populated - */ + * Creates a TaskComputation object Note: At the time of creation, the job + * parameters are not populated + */ public TaskComputation(SPIMComputationAccessor computationAccessor, int timepoint) { this.computationAccessor = computationAccessor; this.timepoint = timepoint; this.state = JobState.Unknown; updateState(); } - + /** * @return current job state */ public JobState getState() { + updateState(); return state; } - + /** * @return job timepoint */ public int getTimepoint() { return timepoint; } - + /** * @return job id */ public Long getId() { return id; } - + // TODO: Method stub public void update() { - + } - + /** * Populates parameters of the current object by searching the output - * @param positionInOutput: Index of the output position to search from + * + * @param positionInOutput: + * Index of the output position to search from * @return success flag */ public boolean populateParameters(int positionInOutput) { - - // Should the state be different than unknown, there is no need to populate parameters + + // Should the state be different than unknown, there is no need to populate + // parameters if (state != JobState.Unknown) { return false; } - + this.positionInOutput = positionInOutput; if (!resolveJobParameters()) { return false; } - - state = JobState.Queued; + + state = JobState.Queued; updateState(); - + return true; } private void updateState() { // Should the state be queued, try to find out whether a log file exists - if (state == JobState.Queued ) { - if (!logs.stream().anyMatch(logFile -> computationAccessor.fileExists(logFile))) { + if (state == JobState.Queued) { + if (null != logs && !logs.stream().anyMatch(logFile -> computationAccessor.fileExists(logFile))) { return; // No log file exists yet } - state = JobState.Running; + state = JobState.Running; } - + // Finally, look up any traces that the job has failed or finished if (state == JobState.Running) { - + final String OUTPUT_PARSING_FINISHED_JOB = "Finished job "; final String desiredPatternFinishedJob = OUTPUT_PARSING_FINISHED_JOB + id.toString(); final String OUTPUT_PARSING_ERRONEOUS_JOB = "Error job "; final String desiredPatternErroneousJob = OUTPUT_PARSING_ERRONEOUS_JOB + id.toString(); - + Scanner scanner = new Scanner(computationAccessor.getActualOutput().substring(positionInOutput)); String currentLine; while (scanner.hasNextLine()) { @@ -112,15 +117,15 @@ public class TaskComputation { scanner.close(); } } - + private boolean resolveJobParameters() { - + final String OUTPUT_PARSING_COMMA_SPACE = ", "; final String OUTPUT_PARSING_INPUTS = "input: "; final String OUTPUT_PARSING_OUTPUTS = "output: "; final String OUTPUT_PARSING_LOGS = "log: "; final String OUTPUT_PARSING_JOB_ID = "jobid: "; - + Scanner scanner = new Scanner(computationAccessor.getActualOutput().substring(positionInOutput)); String currentLine; while (scanner.hasNextLine()) { @@ -131,16 +136,15 @@ public class TaskComputation { outputs = Arrays.asList(currentLine.split(OUTPUT_PARSING_OUTPUTS)[1].split(OUTPUT_PARSING_COMMA_SPACE)); } else if (currentLine.contains(OUTPUT_PARSING_LOGS)) { logs = Arrays.asList(currentLine.split(OUTPUT_PARSING_LOGS)[1].split(OUTPUT_PARSING_COMMA_SPACE)); - } else - if (currentLine.contains(OUTPUT_PARSING_JOB_ID)) { + } else if (currentLine.contains(OUTPUT_PARSING_JOB_ID)) { id = Long.parseLong(currentLine.split(OUTPUT_PARSING_JOB_ID)[1]); } else if (currentLine.trim().isEmpty()) { - break; + break; } } scanner.close(); - - return !(inputs == null || outputs == null || logs == null || id == null); + + return !(inputs == null || id == null); } - + }