diff --git a/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/BenchmarkJobManager.java b/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/BenchmarkJobManager.java index 1e17bb454a55f4252471f6839ef137192ea3c34c..0e0f2ee91fd2f81429df711a1898a95b12d4b239 100644 --- a/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/BenchmarkJobManager.java +++ b/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/BenchmarkJobManager.java @@ -40,8 +40,8 @@ public class BenchmarkJobManager { return new UploadingFileFromResource("", CONFIG_YAML); } - public Collection<JobInfo> getJobs() { - return jobManager.getJobs(); + public Collection<JobInfo> getJobs() throws IOException { + return jobManager.getJobs(progress); } } diff --git a/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/CheckStatusOfHaaS.java b/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/CheckStatusOfHaaS.java index 94ed84f0a80f604d75a2dbf59a6b88d8ded3e4cd..b03c09ff9a334763a58c4a080b785b821c944572 100644 --- a/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/CheckStatusOfHaaS.java +++ b/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/CheckStatusOfHaaS.java @@ -53,7 +53,7 @@ public class CheckStatusOfHaaS implements Command { window = ModalDialogs.doModal(new CheckStatusOfHaaSWindow(getFrame(), context)); ProgressDialog dialog = ModalDialogs.doModal(new ProgressDialog(window)); dialog.setTitle("Downloading info about jobs"); - Collection<JobInfo> jobs = jobManager.getJobs(); + Collection<JobInfo> jobs = jobManager.getJobs(dialog); int count = 0; for (JobInfo ji : jobs) { String item; diff --git a/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/Job.java b/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/Job.java index db0c5b31cb826fc5f1e13ad7173de2cc32b43e04..1ff1eae21842ce1588ae38101994f4dfade49fde 100644 --- a/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/Job.java +++ b/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/Job.java @@ -78,18 +78,17 @@ public class Job { private String name; public Job(String name, Path basePath, Supplier<HaaSClient> haasClientSupplier, Progress progress) throws IOException { - this(haasClientSupplier); + this(haasClientSupplier, progress); HaaSClient client = this.haasClientSupplier.get(); - long id = client.createJob(name, Collections.emptyList(), - notifier = new P_ProgressNotifierAdapter(progress)); + long id = client.createJob(name, Collections.emptyList(),notifier); jobDir = basePath.resolve("" + id); this.name = name; Files.createDirectory(jobDir); updateState(); } - public Job(Path p, Supplier<HaaSClient> haasClientSupplier) throws IOException { - this(haasClientSupplier); + public Job(Path p, Supplier<HaaSClient> haasClientSupplier, Progress progress) throws IOException { + this(haasClientSupplier, progress); jobDir = p; loadJobInfo(); } @@ -108,7 +107,8 @@ public class Job { client.submitJob(jobId, notifier); } - private Job(Supplier<HaaSClient> haasClientSupplier) { + private Job(Supplier<HaaSClient> haasClientSupplier, Progress progress) { + notifier = new P_ProgressNotifierAdapter(progress); this.haasClientSupplier = haasClientSupplier; } diff --git a/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/JobManager.java b/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/JobManager.java index 9382ef1e2fbf4a8f405673700048ebb933650226..e0414ad19f127a56173d25642e9a4bae0cf8d224 100644 --- a/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/JobManager.java +++ b/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/JobManager.java @@ -27,23 +27,15 @@ public class JobManager { private Path workDirectory; - private Collection<Job> jobs = new LinkedList<>(); + private Collection<Job> jobs; private HaaSClient haasClient; private Settings settings; - public JobManager(Path workDirectory, Settings settings) throws IOException { + public JobManager(Path workDirectory, Settings settings){ this.workDirectory = workDirectory; this.settings = settings; - Files.list(this.workDirectory).filter(p -> Files.isDirectory(p) && Job.isJobPath(p)).forEach(p -> { - try { - jobs.add(new Job(p, this::getHaasClient)); - } catch (IOException e) { - e.printStackTrace(); - } - }); - } public JobInfo createJob(Progress progress) throws IOException { @@ -73,7 +65,17 @@ public class JobManager { return () -> jobs.stream().filter(j -> j.needsDownload()).map(j -> new JobInfo(j)).iterator(); } - public Collection<JobInfo> getJobs() { + public Collection<JobInfo> getJobs(Progress progress) throws IOException { + if(jobs == null) { + jobs = new LinkedList<>(); + Files.list(this.workDirectory).filter(p -> Files.isDirectory(p) && Job.isJobPath(p)).forEach(p -> { + try { + jobs.add(new Job(p, this::getHaasClient, progress)); + } catch (IOException e) { + e.printStackTrace(); + } + }); + } return jobs.stream().map(j -> new JobInfo(j)).collect(Collectors.toList()); } diff --git a/haas-imagej-client/src/test/java/cz/it4i/fiji/haas/RunBenchmark.java b/haas-imagej-client/src/test/java/cz/it4i/fiji/haas/RunBenchmark.java index 48f89714fb65f70acf7e7d6f25abde78a40e0621..da4f5ad3954869d048c05401143d39dcc966d210 100644 --- a/haas-imagej-client/src/test/java/cz/it4i/fiji/haas/RunBenchmark.java +++ b/haas-imagej-client/src/test/java/cz/it4i/fiji/haas/RunBenchmark.java @@ -38,7 +38,7 @@ public class RunBenchmark { log.info("job: " + ji.getId() + " hasStatus " + ji.getState()); if (ji.getState() == JobState.Configuring) { benchmarkJobManager.startJob(ji); - } else if (ji.getState() != JobState.Running) { + } else if (ji.getState() != JobState.Running && ji.getState() != JobState.Queued) { ji.downloadData(new P_Progress()); } }