From: jprocter Date: Tue, 28 Aug 2012 13:10:41 +0000 (+0100) Subject: JAL-974 JAL-975 try to cope with temporary server errors and timeouts X-Git-Tag: Jalview_2_9~389 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=a42ecef51ac7b090afe4d4894344e01eaa4e9a2d;p=jalview.git JAL-974 JAL-975 try to cope with temporary server errors and timeouts --- diff --git a/src/jalview/ws/jws2/JabawsAlignCalcWorker.java b/src/jalview/ws/jws2/JabawsAlignCalcWorker.java index 630faae..1d23ec0 100644 --- a/src/jalview/ws/jws2/JabawsAlignCalcWorker.java +++ b/src/jalview/ws/jws2/JabawsAlignCalcWorker.java @@ -4,8 +4,11 @@ import jalview.analysis.AlignSeq; import jalview.analysis.SeqsetUtils; import jalview.api.AlignViewportI; import jalview.api.AlignmentViewPanel; +import jalview.bin.Cache; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; +import jalview.datamodel.Annotation; +import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceI; import jalview.gui.AlignFrame; import jalview.gui.IProgressIndicator; @@ -14,13 +17,18 @@ import jalview.ws.jws2.dm.JabaWsParamSet; import jalview.ws.jws2.jabaws2.Jws2Instance; import jalview.ws.params.WsParamSetI; +import java.awt.Color; import java.util.ArrayList; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; +import com.sun.xml.internal.ws.client.ClientTransportException; + import compbio.data.msa.SequenceAnnotation; import compbio.data.sequence.FastaSequence; +import compbio.data.sequence.Score; import compbio.data.sequence.ScoreManager; import compbio.metadata.Argument; import compbio.metadata.ChunkHolder; @@ -117,6 +125,8 @@ public abstract class JabawsAlignCalcWorker extends AlignCalcWorker } long progressId = -1; + int serverErrorsLeft = 3; + String rslt = "JOB NOT DEFINED"; StringBuffer msg=new StringBuffer(); try @@ -189,30 +199,42 @@ public abstract class JabawsAlignCalcWorker extends AlignCalcWorker return; } long cpos; - ChunkHolder stats; + ChunkHolder stats = null; do { cpos = rpos; - try + boolean retry = false; + do { - stats = aaservice.pullExecStatistics(rslt, rpos); - } catch (Exception x) - { - - if (x.getMessage().contains( - "Position in a file could not be negative!")) + try { - // squash index out of bounds exception- seems to happen for - // disorder predictors which don't (apparently) produce any - // progress information and JABA server throws an exception - // because progress length is -1. - stats = null; - } - else + stats = aaservice.pullExecStatistics(rslt, rpos); + } catch (Exception x) { - throw x; + + if (x.getMessage().contains( + "Position in a file could not be negative!")) + { + // squash index out of bounds exception- seems to happen for + // disorder predictors which don't (apparently) produce any + // progress information and JABA server throws an exception + // because progress length is -1. + stats = null; + } + else + { + if (--serverErrorsLeft > 0) + { + retry = true; + try { + Thread.sleep(200); + } catch (InterruptedException q) {}; + } else { + throw x; + } + } } - } + } while (retry); if (stats != null) { System.out.print(stats.getChunk()); @@ -232,23 +254,31 @@ public abstract class JabawsAlignCalcWorker extends AlignCalcWorker ; } } while (!finished); - try + if (serverErrorsLeft>0) { - Thread.sleep(200); - } catch (InterruptedException x) - { - } - ; - scoremanager = aaservice.getAnnotation(rslt); - if (scoremanager != null) - { - jalview.bin.Cache.log.debug("Updating result annotation from Job "+rslt+" at "+service.getUri()); - updateResultAnnotation(true); + try + { + Thread.sleep(200); + } catch (InterruptedException x) + { + } + ; + scoremanager = aaservice.getAnnotation(rslt); + if (scoremanager != null) + { + jalview.bin.Cache.log + .debug("Updating result annotation from Job " + rslt + + " at " + service.getUri()); + updateResultAnnotation(true); + } } - } catch (JobSubmissionException x) + } + + catch (JobSubmissionException x) { - System.err.println("submission error with "+getServiceActionText()+" :"); + System.err.println("submission error with " + getServiceActionText() + + " :"); x.printStackTrace(); calcMan.workerCannotRun(this); } catch (ResultNotAvailableException x)