From bd6e2f14dd1a60bb11e1be975574e462a1a6b256 Mon Sep 17 00:00:00 2001 From: jprocter Date: Thu, 2 Jun 2005 15:27:20 +0000 Subject: [PATCH] tidied the exceptions and ws server error behaviour --- src/jalview/ws/JPredClient.java | 42 +++++++++++++++++++++++++++++++++------ src/jalview/ws/MsaWSClient.java | 40 ++++++++++++++++++++++++++++++------- 2 files changed, 69 insertions(+), 13 deletions(-) diff --git a/src/jalview/ws/JPredClient.java b/src/jalview/ws/JPredClient.java index 3842e15..232d6d6 100755 --- a/src/jalview/ws/JPredClient.java +++ b/src/jalview/ws/JPredClient.java @@ -67,6 +67,7 @@ public class JPredClient extends WSClient JPredWSServiceLocator loc = new JPredWSServiceLocator(); // Default try { this.server = loc.getjpred(new java.net.URL(WsURL)); // JBPNote will be set from properties + ((JpredSoapBindingStub) this.server).setTimeout(60000); // one minute stub } catch (Exception ex) { JOptionPane.showMessageDialog(Desktop.desktop, "The Secondary Structure Prediction Service named " @@ -74,6 +75,7 @@ public class JPredClient extends WSClient "Internal Jalview Error", JOptionPane.WARNING_MESSAGE); wsInfo.setProgressText("Serious! "+WebServiceName+" Service location failed\nfor URL :" +WsURL+"\n"+ex.getMessage()); + wsInfo.setStatus(wsInfo.STATE_STOPPED_SERVERERROR); } JPredThread jthread = new JPredThread(seq); @@ -120,7 +122,8 @@ public class JPredClient extends WSClient { try { - result = server.getresult(jobId); + if ((result = server.getresult(jobId))==null) + throw(new Exception("Timed out when communicating with server\nTry again later.\n")); if( result.isRunning() ) wsInfo.setStatus(WebserviceInfo.STATE_RUNNING); @@ -138,7 +141,13 @@ public class JPredClient extends WSClient wsInfo.setProgressText(OutputHeader + "\n" + result.getStatus()); if (! (result.isJobFailed() || result.isServerError())) { - Thread.sleep(5000); + try + { + Thread.sleep(5000); + } + catch (InterruptedException ex1) + { + } // System.out.println("I'm alive "+seqid+" "+jobid); } else { wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_ERROR); @@ -149,6 +158,14 @@ public class JPredClient extends WSClient { allowedServerExceptions--; wsInfo.appendProgressText("\nJPredWS Server exception!\n" + ex.getMessage()); + try + { + if (allowedServerExceptions>0) + Thread.sleep(5000); + } + catch (InterruptedException ex1) + { + } } } @@ -167,13 +184,26 @@ public class JPredClient extends WSClient } else { jobId = server.predict(sequence); } - System.out.println(WsURL+" Job Id '"+jobId+"'"); + if (jobId!=null) { + if (jobId.startsWith("Broken")) { + throw new Exception("Submission " + jobId); + } else { + System.out.println(WsURL+" Job Id '"+jobId+"'"); + } + } else { + throw new Exception("Server timed out - try again later\n"); + + } } catch (Exception e) { - System.err.println("JPredWS Client: Failed to submit the prediction\n" + - e.toString() + "\n"); - e.printStackTrace(); + wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_SERVERERROR); + allowedServerExceptions=0; + jobComplete=false; + wsInfo.appendProgressText("Failed to submit the prediction: "+e.toString()+"\nJust close the window\n"); + System.err.println("JPredWS Client: Failed to submit the prediction\n" + + e.toString() + "\n"); + // e.printStackTrace(); TODO: JBPNote DEBUG } } diff --git a/src/jalview/ws/MsaWSClient.java b/src/jalview/ws/MsaWSClient.java index 9626132..faf2faf 100755 --- a/src/jalview/ws/MsaWSClient.java +++ b/src/jalview/ws/MsaWSClient.java @@ -53,6 +53,7 @@ public class MsaWSClient MuscleWSServiceLocator loc = new MuscleWSServiceLocator(); // Default try { this.server = (MuscleWS) loc.getMuscleWS(new java.net.URL(WsURL)); + ((MuscleWSSoapBindingStub) this.server).setTimeout(60000); // One minute timeout } catch (Exception ex) { wsInfo.setProgressText("Serious! "+WebServiceName+" Service location failed\nfor URL :" @@ -60,7 +61,7 @@ public class MsaWSClient wsInfo.setStatus(wsInfo.ERROR); ex.printStackTrace(); } - + loc.getEngine().setOption("axis","1"); MsaWSThread musclethread = new MsaWSThread(WebServiceName+" alignment of "+altitle, msa, submitGaps, preserveOrder); wsInfo.setthisService(musclethread); musclethread.start(); @@ -119,7 +120,7 @@ public class MsaWSClient boolean jobComplete = false; public void cancelJob() { - if (!jobComplete) { + if (jobId!=null && !jobId.equals("") && !jobComplete) { String cancelledMessage=""; try { vamsas.objects.simple.WsJobId cancelledJob = server.cancel(jobId); @@ -147,6 +148,11 @@ public class MsaWSClient exc.printStackTrace(); } wsInfo.setProgressText(OutputHeader + cancelledMessage+"\n"); + } else { + if (!jobComplete) + { + wsInfo.setProgressText(OutputHeader + "Server cannot cancel this job because it has not been submitted properly. just close the window.\n"); + } } } @@ -159,7 +165,8 @@ public class MsaWSClient { try { - result = server.getResult(jobId); + if ((result = server.getResult(jobId))==null) + throw(new Exception("Timed out when communicating with server\nTry again later.\n")); if (result.isRunning()) wsInfo.setStatus(WebserviceInfo.STATE_RUNNING); @@ -192,7 +199,18 @@ public class MsaWSClient allowedServerExceptions--; wsInfo.appendProgressText("\n" + ServiceName + " Server exception!\n" + ex.getMessage()); - ex.printStackTrace(); + System.err.println(ServiceName + " Server exception: " + + ex.getMessage()); + // ex.printStackTrace(); JBPNote Debug + try + { + if (allowedServerExceptions>0) + Thread.sleep(5000); + } + catch (InterruptedException ex1) + { + } + } } if (allowedServerExceptions == 0) @@ -217,18 +235,26 @@ public class MsaWSClient try { vamsas.objects.simple.WsJobId jobsubmit = server.align(seqs); - if (jobsubmit.getStatus()==1) { + if (jobsubmit!=null && jobsubmit.getStatus()==1) { jobId=jobsubmit.getJobId(); System.out.println(WsURL+" Job Id '"+jobId+"'"); } else { + if (jobsubmit == null) { + throw new Exception("Server at "+WsURL+" returned null object, it probably cannot be contacted. Try again later ?"); + } throw new Exception(jobsubmit.getJobId()); } } catch (Exception e) { - System.err.println(ServiceName + " Client: Failed to submit the prediction\n" + + // TODO: JBPNote catch timeout or other fault types explicitly + // For unexpected errors + System.err.println(WebServiceName + " Client: Failed to submit the sequences for alignment.\n"+WsURL+" : " + e.toString() + "\n"); - e.printStackTrace(); + this.allowedServerExceptions=0; + wsInfo.setStatus(wsInfo.STATE_STOPPED_SERVERERROR); + wsInfo.appendProgressText("Server problems! "+e.toString()+"\nFailed to submit sequences for alignment. Just close the window\n"); + // e.printStackTrace(); // TODO: JBPNote DEBUG } } -- 1.7.10.2