JAL - 3690 AlignCalc rebuilt - FutureTask-based manager
[jalview.git] / src / jalview / ws / jws2 / SeqAnnotationServiceCalcWorker.java
index 132408b..ae03dfb 100644 (file)
@@ -227,15 +227,15 @@ public class SeqAnnotationServiceCalcWorker extends AlignCalcWorker
   private int min_valid_seqs;
 
   @Override
-  public void run()
+  public void run() throws Exception
   {
-    if (checkDone())
+    if (alignViewport.isClosed())
     {
+      abortAndDestroy();
       return;
     }
     if (!hasService())
     {
-      calcMan.workerComplete(this);
       return;
     }
 
@@ -257,7 +257,6 @@ public class SeqAnnotationServiceCalcWorker extends AlignCalcWorker
       {
         jalview.bin.Cache.log.debug(
                 "Sequences for analysis service were null or not valid");
-        calcMan.workerComplete(this);
         return;
       }
 
@@ -329,41 +328,13 @@ public class SeqAnnotationServiceCalcWorker extends AlignCalcWorker
           Cache.log.debug("Status now " + running.getState());
         }
 
-        if (calcMan.isPending(this) && isInteractiveUpdate())
-        {
-          Cache.log.debug("Analysis service job is stale. aborting.");
-          // job has become stale.
-          if (!finished) {
-            finished = true;
-            // cancel this job and yield to the new job
-            try
-            {
-              if (cancellable
-                        && ((CancellableI) annotService).cancel(running))
-              {
-                System.err.println("Cancelled job: " + rslt);
-              }
-              else
-              {
-                System.err.println("FAILED TO CANCEL job: " + rslt);
-              }
-  
-            } catch (Exception x)
-            {
-  
-            }
-          }
-          rslt = running.getJobHandle();
-          return;
-        }
-
         // pull any stats - some services need to flush log output before
         // results are available
         Cache.log.debug("Updating progress log for annotation service.");
 
         try
         {
-        annotService.updateJobProgress(running);
+          annotService.updateJobProgress(running);
         } catch (Throwable thr)
         {
           Cache.log.debug("Ignoring exception during progress update.",
@@ -523,10 +494,10 @@ public class SeqAnnotationServiceCalcWorker extends AlignCalcWorker
       System.err
               .println("Blacklisting worker due to unexpected exception:");
       x.printStackTrace();
+      throw new Exception(x);
     } finally
     {
 
-      calcMan.workerComplete(this);
       if (ap != null)
       {
         if (guiProgress != null && progressId != -1)
@@ -889,43 +860,6 @@ public class SeqAnnotationServiceCalcWorker extends AlignCalcWorker
     }
   }
 
-  /**
-   * notify manager that we have started, and wait for a free calculation slot
-   * 
-   * @return true if slot is obtained and work still valid, false if another
-   *         thread has done our work for us.
-   */
-  protected boolean checkDone()
-  {
-    calcMan.notifyStart(this);
-    ap.paintAlignment(false, false);
-    while (!calcMan.notifyWorking(this))
-    {
-      if (calcMan.isWorking(this))
-      {
-        return true;
-      }
-      try
-      {
-        if (ap != null)
-        {
-          ap.paintAlignment(false, false);
-        }
-
-        Thread.sleep(200);
-      } catch (Exception ex)
-      {
-        ex.printStackTrace();
-      }
-    }
-    if (alignViewport.isClosed())
-    {
-      abortAndDestroy();
-      return true;
-    }
-    return false;
-  }
-
   protected void updateOurAnnots(List<AlignmentAnnotation> ourAnnot)
   {
     List<AlignmentAnnotation> our = ourAnnots;