import jalview.gui.*;\r
import jalview.gui.FeatureRenderer.FeatureRendererSettings;\r
\r
-public abstract class WSThread\r
- extends Thread\r
+public abstract class WSThread extends Thread\r
{\r
/**\r
* Generic properties for Web Service Client threads.\r
* view that this job was associated with\r
*/\r
AlignmentI currentView = null;\r
+\r
/**\r
* feature settings from view that job was associated with\r
*/\r
FeatureRendererSettings featureSettings = null;\r
+\r
/**\r
* metadata about this web service\r
*/\r
WebserviceInfo wsInfo = null;\r
+\r
/**\r
* original input data for this job\r
*/\r
AlignmentView input = null;\r
+\r
/**\r
* dataset sequence relationships to be propagated onto new results\r
*/\r
AlignedCodonFrame[] codonframe = null;\r
+\r
/**\r
* are there jobs still running in this thread.\r
*/\r
boolean jobComplete = false;\r
- \r
+\r
abstract class WSJob\r
{\r
/**\r
- * Generic properties for an individual job within a Web Service Client thread\r
+ * Generic properties for an individual job within a Web Service Client\r
+ * thread\r
*/\r
int jobnum = 0; // WebServiceInfo pane for this job\r
+\r
String jobId; // ws job ticket\r
+\r
/**\r
* has job been cancelled\r
*/\r
boolean cancelled = false;\r
+\r
/**\r
* number of exceptions left before job dies\r
*/\r
int allowedServerExceptions = 3;\r
+\r
/**\r
* has job been submitted\r
*/\r
boolean submitted = false;\r
+\r
/**\r
* are all sub-jobs complete\r
*/\r
boolean subjobComplete = false;\r
+\r
/**\r
- *\r
+ * \r
* @return true if job has completed and valid results are available\r
*/\r
abstract boolean hasResults();\r
\r
/**\r
- *\r
+ * \r
* @return boolean true if job can be submitted.\r
*/\r
abstract boolean hasValidInput();\r
* number of jobs running\r
*/\r
int running = 0;\r
+\r
/**\r
* number of jobs queued\r
*/\r
int queuing = 0;\r
+\r
/**\r
* number of jobs finished\r
*/\r
int finished = 0;\r
+\r
/**\r
* number of jobs failed\r
*/\r
int error = 0;\r
+\r
/**\r
* number of jobs stopped due to server error\r
*/\r
int serror = 0;\r
+\r
/**\r
* number of jobs cancelled\r
*/\r
int cancelled = 0;\r
+\r
/**\r
* number of jobs finished with results\r
*/\r
int results = 0;\r
+\r
/**\r
- * processes WSJob and updates job status counters and WebService status displays\r
+ * processes WSJob and updates job status counters and WebService status\r
+ * displays\r
+ * \r
* @param wsInfo\r
* @param OutputHeader\r
* @param j\r
*/\r
void updateJobPanelState(WebserviceInfo wsInfo, String OutputHeader,\r
- WSJob j)\r
+ WSJob j)\r
{\r
if (j.result != null)\r
{\r
serror++;\r
j.subjobComplete = true;\r
wsInfo.setStatus(j.jobnum,\r
- WebserviceInfo.STATE_STOPPED_SERVERERROR);\r
+ WebserviceInfo.STATE_STOPPED_SERVERERROR);\r
}\r
else if (j.result.isBroken() || j.result.isFailed())\r
{\r
}\r
}\r
}\r
+\r
/**\r
* one or more jobs being managed by this thread.\r
*/\r
WSJob jobs[] = null;\r
+\r
/**\r
* full name of service\r
*/\r
String WebServiceName = null;\r
+\r
String OutputHeader;\r
+\r
String WsUrl = null;\r
+\r
/**\r
- * query web service for status of job.\r
- * on return, job.result must not be null - if it is then it will be\r
- * assumed that the job status query timed out and a server exception\r
- * will be logged.\r
+ * query web service for status of job. on return, job.result must not be null -\r
+ * if it is then it will be assumed that the job status query timed out and a\r
+ * server exception will be logged.\r
+ * \r
* @param job\r
- * @throws Exception will be logged as a server exception for this job\r
+ * @throws Exception\r
+ * will be logged as a server exception for this job\r
*/\r
- abstract void pollJob(WSJob job)\r
- throws Exception;\r
+ abstract void pollJob(WSJob job) throws Exception;\r
\r
public void run()\r
{\r
if (jobs[j].result == null)\r
{\r
throw (new Exception(\r
- "Timed out when communicating with server\nTry again later.\n"));\r
+ "Timed out when communicating with server\nTry again later.\n"));\r
}\r
- jalview.bin.Cache.log.debug("Job " + j + " Result state " +\r
- jobs[j].result.getState()\r
- + "(ServerError=" +\r
- jobs[j].result.isServerError() + ")");\r
- }\r
- catch (Exception ex)\r
+ jalview.bin.Cache.log.debug("Job " + j + " Result state "\r
+ + jobs[j].result.getState() + "(ServerError="\r
+ + jobs[j].result.isServerError() + ")");\r
+ } catch (Exception ex)\r
{\r
// Deal with Transaction exceptions\r
wsInfo.appendProgressText(jobs[j].jobnum, "\n" + WebServiceName\r
- + " Server exception!\n" + ex.getMessage());\r
+ + " Server exception!\n" + ex.getMessage());\r
Cache.log.warn(WebServiceName + " job(" + jobs[j].jobnum\r
- + ") Server exception: " + ex.getMessage());\r
+ + ") Server exception: " + ex.getMessage());\r
\r
if (jobs[j].allowedServerExceptions > 0)\r
{\r
try\r
{\r
Thread.sleep(5000);\r
- }\r
- catch (InterruptedException ex1)\r
+ } catch (InterruptedException ex1)\r
{\r
}\r
}\r
Cache.log.warn("Dropping job " + j + " " + jobs[j].jobId);\r
jobs[j].subjobComplete = true;\r
wsInfo.setStatus(jobs[j].jobnum,\r
- WebserviceInfo.STATE_STOPPED_SERVERERROR);\r
+ WebserviceInfo.STATE_STOPPED_SERVERERROR);\r
}\r
- }\r
- catch (OutOfMemoryError er)\r
+ } catch (OutOfMemoryError er)\r
{\r
jobComplete = true;\r
jobs[j].subjobComplete = true;\r
jobs[j].result = null; // may contain out of date result object\r
wsInfo.setStatus(jobs[j].jobnum,\r
- WebserviceInfo.STATE_STOPPED_ERROR);\r
- JOptionPane\r
- .showInternalMessageDialog(\r
- Desktop.desktop,\r
- "Out of memory handling result for job !!"\r
- +\r
- "\nSee help files for increasing Java Virtual Machine memory.",\r
- "Out of memory", JOptionPane.WARNING_MESSAGE);\r
- Cache.log.error("Out of memory when retrieving Job " + j + " id:" +\r
- WsUrl + "/" + jobs[j].jobId, er);\r
+ WebserviceInfo.STATE_STOPPED_ERROR);\r
+ Cache.log.error("Out of memory when retrieving Job " + j\r
+ + " id:" + WsUrl + "/" + jobs[j].jobId, er);\r
+ new jalview.gui.OOMWarning("retrieving result for "\r
+ + WebServiceName, er);\r
System.gc();\r
}\r
}\r
try\r
{\r
Thread.sleep(5000);\r
- }\r
- catch (InterruptedException e)\r
+ } catch (InterruptedException e)\r
{\r
- Cache.log.debug("Interrupted sleep waiting for next job poll.", e);\r
+ Cache.log\r
+ .debug("Interrupted sleep waiting for next job poll.", e);\r
}\r
// System.out.println("I'm alive "+alTitle);\r
}\r
}\r
else\r
{\r
- Cache.log.debug("WebServiceJob poll loop finished with no jobs created.");\r
+ Cache.log\r
+ .debug("WebServiceJob poll loop finished with no jobs created.");\r
wsInfo.setFinishedNoResults();\r
}\r
}\r
\r
/**\r
* submit job to web service\r
+ * \r
* @param job\r
*/\r
abstract void StartJob(WSJob job);\r
abstract void parseResult();\r
\r
/**\r
- * helper function to conserve dataset references to sequence objects returned from web services\r
- * 1. Propagates AlCodonFrame data from <code>codonframe</code> to <code>al</code>\r
+ * helper function to conserve dataset references to sequence objects returned\r
+ * from web services 1. Propagates AlCodonFrame data from\r
+ * <code>codonframe</code> to <code>al</code>\r
+ * \r
* @param al\r
*/\r
protected void propagateDatasetMappings(Alignment al)\r
{\r
- if (codonframe!=null)\r
+ if (codonframe != null)\r
{\r
SequenceI[] alignment = al.getSequencesArray();\r
- for (int sq = 0; sq<alignment.length; sq++)\r
+ for (int sq = 0; sq < alignment.length; sq++)\r
{\r
- for (int i=0; i<codonframe.length; i++)\r
+ for (int i = 0; i < codonframe.length; i++)\r
{\r
- if (codonframe[i]!=null &&\r
- codonframe[i].involvesSequence(alignment[sq]))\r
+ if (codonframe[i] != null\r
+ && codonframe[i].involvesSequence(alignment[sq]))\r
{\r
al.addCodonFrame(codonframe[i]);\r
codonframe[i] = null;\r
\r
/**\r
* \r
- * @param alignFrame reference for copying mappings across\r
- * @param wsInfo gui attachment point\r
- * @param input input data for the calculation\r
- * @param webServiceName name of service\r
- * @param wsUrl url of the service being invoked\r
+ * @param alignFrame\r
+ * reference for copying mappings across\r
+ * @param wsInfo\r
+ * gui attachment point\r
+ * @param input\r
+ * input data for the calculation\r
+ * @param webServiceName\r
+ * name of service\r
+ * @param wsUrl\r
+ * url of the service being invoked\r
*/\r
public WSThread(AlignFrame alignFrame, WebserviceInfo wsinfo,\r
- AlignmentView input, String webServiceName,\r
- String wsUrl)\r
+ AlignmentView input, String webServiceName, String wsUrl)\r
{\r
this(alignFrame, wsinfo, input, wsUrl);\r
WebServiceName = webServiceName;\r
}\r
+\r
char defGapChar = '-';\r
+\r
/**\r
* \r
* @return gap character to use for any alignment generation\r
\r
/**\r
* \r
- * @param alframe - reference for copying mappings and display styles across\r
- * @param wsinfo2 - gui attachment point\r
- * @param alview - input data for the calculation\r
- * @param wsurl2 - url of the service being invoked\r
+ * @param alframe -\r
+ * reference for copying mappings and display styles across\r
+ * @param wsinfo2 -\r
+ * gui attachment point\r
+ * @param alview -\r
+ * input data for the calculation\r
+ * @param wsurl2 -\r
+ * url of the service being invoked\r
*/\r
public WSThread(AlignFrame alframe, WebserviceInfo wsinfo2,\r
AlignmentView alview, String wsurl2)\r
this.wsInfo = wsinfo2;\r
this.input = alview;\r
WsUrl = wsurl2;\r
- if (alframe!=null)\r
+ if (alframe != null)\r
{\r
- AlignedCodonFrame[] cf = alframe.getViewport().getAlignment().getCodonFrames();\r
- if (cf!=null)\r
+ AlignedCodonFrame[] cf = alframe.getViewport().getAlignment()\r
+ .getCodonFrames();\r
+ if (cf != null)\r
{\r
codonframe = new AlignedCodonFrame[cf.length];\r
System.arraycopy(cf, 0, codonframe, 0, cf.length);\r