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 6baaf057d5bce57d2aa916cc8d1ec772a5b4fa21..25da9cf239c7734ac588d5908df20239d248103d 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 @@ -418,28 +418,24 @@ public class BenchmarkJobManager implements Closeable { String mainFile = job.getProperty(SPIM_OUTPUT_FILENAME_PATTERN) + ".xml"; final ProgressNotifierTemporarySwitchOff notifierSwitch = new ProgressNotifierTemporarySwitchOff(downloadNotifier, job); - job.startDownload(downloadFileNameExtractDecorator(fileName->fileName.equals(mainFile))) - .whenComplete((X,e1)-> { - notifierSwitch.switchOn(); - if(e1 == null) { - Set<String> otherFiles = extractNames(getOutputDirectory().resolve(mainFile)); - try { - job.startDownload(downloadFileNameExtractDecorator(name -> otherFiles.contains(name))) - .whenComplete((X2,e2) -> { - result.complete(null); - if(e2 != null) { - log.error(e2.getMessage(), e2); - } - }); - } catch (IOException e) { - e1 = e; - } - } - if(e1 != null){ - log.error(e1.getMessage(), e1); - result.complete(null); - } - }); + job.startDownload(downloadFileNameExtractDecorator(fileName -> fileName.equals(mainFile))) + .whenComplete((X, E) -> { + notifierSwitch.switchOn(); + }).thenCompose(X -> { + Set<String> otherFiles = extractNames(getOutputDirectory().resolve(mainFile)); + try { + return job + .startDownload(downloadFileNameExtractDecorator(name -> otherFiles.contains(name))); + } catch (IOException e) { + throw new RuntimeException(e); + } + + }).whenComplete((X, e) -> { + if (e != null) { + log.error(e.getMessage(), e); + } + result.complete(null); + }); } private Set<String> extractNames(Path resolve) { diff --git a/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/core/ProgressNotifierTemporarySwitchOff.java b/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/core/ProgressNotifierTemporarySwitchOff.java index a1a1d275064bb4a169fc7906490a8387acd7e18f..f1bb00186ed177ff31a523429d03177f5da6e8d5 100644 --- a/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/core/ProgressNotifierTemporarySwitchOff.java +++ b/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/core/ProgressNotifierTemporarySwitchOff.java @@ -6,7 +6,7 @@ import cz.it4i.fiji.haas_java_client.ProgressNotifier; public class ProgressNotifierTemporarySwitchOff { - private final ProgressNotifier notifier; + private ProgressNotifier notifier; private final Job job; public ProgressNotifierTemporarySwitchOff(ProgressNotifier downloadNotifier, Job job) { @@ -17,10 +17,11 @@ public class ProgressNotifierTemporarySwitchOff { } } - public void switchOn() { + synchronized public void switchOn() { if(notifier != null) { this.job.setDownloadNotifier(notifier); } + notifier = null; } }