From bc7c6b545d858f698f4e60f782b354e59430dddb Mon Sep 17 00:00:00 2001 From: Mateusz Warowny Date: Fri, 1 Oct 2021 17:35:55 +0200 Subject: [PATCH] JAL-3878 Fix workers done condition to account for broken jobs. --- src/jalview/ws2/WebServiceExecutor.java | 5 +++-- src/jalview/ws2/WebServiceWorkerI.java | 2 +- src/jalview/ws2/operations/AlignmentOperation.java | 7 ++++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/jalview/ws2/WebServiceExecutor.java b/src/jalview/ws2/WebServiceExecutor.java index 4b41464..86016d2 100644 --- a/src/jalview/ws2/WebServiceExecutor.java +++ b/src/jalview/ws2/WebServiceExecutor.java @@ -35,9 +35,10 @@ public class WebServiceExecutor private void pollJobs(WebServiceWorkerI worker) { + boolean done; try { - worker.pollJobs(); + done = worker.pollJobs(); } catch (Exception e) { Cache.log.error("Failed to poll web service jobs.", e); @@ -48,7 +49,7 @@ public class WebServiceExecutor wsThreadSupport.pollFailed(worker, e); return; } - if (!worker.isDone()) + if (!done) { executor.schedule(() -> pollJobs(worker), 1, TimeUnit.SECONDS); } diff --git a/src/jalview/ws2/WebServiceWorkerI.java b/src/jalview/ws2/WebServiceWorkerI.java index be719c1..f1864fc 100644 --- a/src/jalview/ws2/WebServiceWorkerI.java +++ b/src/jalview/ws2/WebServiceWorkerI.java @@ -25,7 +25,7 @@ public interface WebServiceWorkerI return false; for (WSJob job : getJobs()) { - if (!job.getStatus().isDone()) + if (!job.getStatus().isDone() && !job.getStatus().isFailed()) return false; } return true; diff --git a/src/jalview/ws2/operations/AlignmentOperation.java b/src/jalview/ws2/operations/AlignmentOperation.java index f72978a..f836c91 100644 --- a/src/jalview/ws2/operations/AlignmentOperation.java +++ b/src/jalview/ws2/operations/AlignmentOperation.java @@ -366,6 +366,7 @@ public class AlignmentOperation implements Operation @Override public void startJobs() throws IOException { + Cache.log.info(format("Starting new %s job.", service.getName())); String outputHeader = String.format("%s of %s%nJob details%n", submitGaps ? "Re-alignment" : "Alignment", alnTitle); SequenceI[][] conmsa = msa.getVisibleContigs('-'); @@ -382,7 +383,7 @@ public class AlignmentOperation implements Operation WSJob job = new WSJob(service.getProviderName(), service.getName(), service.getHostName()); job.setJobNum(wsInfo.addJobPane()); - if (conmsa.length > 0) + if (conmsa.length > 1) { wsInfo.setProgressName(String.format("region %d", i), job.getJobNum()); @@ -448,7 +449,7 @@ public class AlignmentOperation implements Operation boolean done = true; for (WSJob job : getJobs()) { - if (!job.getStatus().isDone()) + if (!job.getStatus().isDone() && !job.getStatus().isFailed()) { Cache.log.debug(format("Polling job %s.", job)); try @@ -479,7 +480,7 @@ public class AlignmentOperation implements Operation Cache.log.debug( format("Job %s status is %s", job, job.getStatus())); } - done &= job.getStatus().isDone(); + done &= job.getStatus().isDone() || job.getStatus().isFailed(); } updateWSInfoGlobalStatus(); return done; -- 1.7.10.2