pullJobExecutionStats for JAL-493
authorjprocter <Jim Procter>
Mon, 17 May 2010 16:14:48 +0000 (16:14 +0000)
committerjprocter <Jim Procter>
Mon, 17 May 2010 16:14:48 +0000 (16:14 +0000)
src/jalview/ws/jws2/MsaWSThread.java

index c8c49c5..9063b1f 100644 (file)
@@ -493,12 +493,21 @@ class MsaWSThread extends AWS2Thread implements WSClientI
   {
     // TODO: investigate if we still need to cast here in J1.6
     MsaWSJob j=((MsaWSJob) job);
+    // this is standard code, but since the interface doesn't comprise of a basic one that implements (getJobStatus, pullExecStatistics) we have to repeat the code for all jw2s services.
     j.setjobStatus(server.getJobStatus(job.getJobId()));
+    updateJobProgress(j);
+  }
+  protected void updateJobProgress(MsaWSJob j) throws Exception {
     StringBuffer response = j.jobProgress;
-    ChunkHolder chunk = server.pullExecStatistics(job.getJobId(), j.getLastChunk());
-    response.append(chunk.getChunk());
-    j.setLastChunk(chunk.getNextPosition());
-     
+    long lastchunk = j.getLastChunk();
+    do {
+      j.setLastChunk(lastchunk);
+      ChunkHolder chunk = server.pullExecStatistics(j.getJobId(), lastchunk);
+      if (chunk!=null) {
+        response.append(chunk.getChunk());
+        lastchunk = chunk.getNextPosition();
+      };
+    } while (lastchunk>=0 && j.getLastChunk()!=lastchunk);
   }
 
   public void StartJob(AWsJob job)
@@ -582,6 +591,20 @@ class MsaWSThread extends AWS2Thread implements WSClientI
         if (jobs[j].isFinished() && msjob.alignment==null)
         {
           try {
+            updateJobProgress(msjob);
+          } catch (Exception e)
+          {
+            Cache.log.warn("Exception when retrieving remaining Job progress data for job "+msjob.getJobId()+" on server "+WsUrl);
+            e.printStackTrace();
+          }
+          if (Cache.log.isDebugEnabled())
+          {
+            System.out.println("Job Execution file for job: "+msjob.getJobId()+" on server "+WsUrl);
+            System.out.println(msjob.getStatus());
+            System.out.println("*** End of status");
+            
+          }
+          try {
             msjob.alignment = server.getResult(msjob.getJobId());
           }
           catch (Exception e)