JAL-961 JAL-975 extend api to support removal of workers no-longer required by the...
[jalview.git] / src / jalview / api / AlignCalcManagerI.java
1 package jalview.api;
2
3 import java.util.List;
4
5 import jalview.datamodel.AlignmentAnnotation;
6 import jalview.ws.jws2.AAConsClient;
7
8 public interface AlignCalcManagerI
9 {
10
11
12   /**
13    * tell manager that a worker is initialised and has started to run
14    * @param worker
15    */
16   void notifyStart(AlignCalcWorkerI worker);
17
18   /**
19    * check if a calculation of this type is already active
20    * @param worker
21    * @return
22    */
23   boolean alreadyDoing(AlignCalcWorkerI worker);
24
25   /**
26    * tell manager that worker is now processing data
27    * @param worker
28    */
29   boolean notifyWorking(AlignCalcWorkerI worker);
30
31
32   /**
33    * notify manager that the worker has completed, and results may be ready to collect
34    * @param worker
35    */
36   void workerComplete(AlignCalcWorkerI worker);
37
38   /**
39    * indicate that a worker like this cannot run on the platform and shouldn't be started again
40    * @param worker
41    */
42   void workerCannotRun(AlignCalcWorkerI worker);
43
44   /**
45    * indicate that a worker like this may be run on the platform.
46    * @param worker of class to be removed from the execution blacklist
47    */
48   void workerMayRun(AlignCalcWorkerI worker);
49   /**
50    * launch a new worker
51    * @param worker
52    */
53   void startWorker(AlignCalcWorkerI worker);
54
55   /**
56    *
57    * @param worker
58    * @return
59    */
60   boolean isWorking(AlignCalcWorkerI worker);
61
62   /**
63    * if any worker thread is operational, return true!
64    * @return
65    */
66   boolean isWorking();
67
68
69   /**
70    * register a restartable worker
71    * @param worker
72    */
73   void registerWorker(AlignCalcWorkerI worker);
74
75   /**
76    * restart any registered workers
77    */
78   void restartWorkers();
79
80   /**
81    *
82    * @param alignmentAnnotation
83    * @return true if a currently registered and working worker indicates its involvement with the given alignmentAnnotation
84    */
85   boolean workingInvolvedWith(AlignmentAnnotation alignmentAnnotation);
86
87   /**
88    * kick any known instances of the given worker class to update their annotation
89    * @param workerClass
90    */
91   void updateAnnotationFor(Class workerClass);
92
93   /**
94    * return any registered workers of the given class
95    * @param workerClass
96    * @return null or one or more workers of the given class
97    */
98   List<AlignCalcWorkerI> getRegisteredWorkersOfClass(
99           Class workerClass);
100
101   /**
102    * start any workers of the given class
103    * @param workerClass
104    * @return false if no workers of given class were registered
105    * (note - blacklisted classes cannot be restarted, so this method will return true for blacklisted workers)
106    */
107   boolean startRegisteredWorkersOfClass(Class workerClass);
108
109   /**
110    * work out if there is an instance of a worker that is *waiting* to start
111    * calculating
112    *
113    * @param workingClass
114    * @return true if workingClass is already waiting to calculate. false if it
115    *         is calculating, or not queued.
116    */
117   boolean isPending(AlignCalcWorkerI workingClass);
118
119   /**
120    * deregister and otherwise remove any registered and working instances of the given worker type
121    * @param typeToRemove
122    */
123   void removeRegisteredWorkersOfClass(Class typeToRemove);
124
125 }