1. Project Clover database Fri Dec 6 2024 13:47:14 GMT
  2. Package jalview.ws

File JobStateSummary.java

 

Coverage histogram

../../img/srcFileCovDistChart4.png
49% of files have more coverage

Code metrics

32
48
1
1
180
100
18
0.38
48
1
18

Classes

Class
Line #
Actions
JobStateSummary 32 48 18
0.3827160638.3%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
7    * Jalview is free software: you can redistribute it and/or
8    * modify it under the terms of the GNU General Public License
9    * as published by the Free Software Foundation, either version 3
10    * of the License, or (at your option) any later version.
11    *
12    * Jalview is distributed in the hope that it will be useful, but
13    * WITHOUT ANY WARRANTY; without even the implied warranty
14    * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15    * PURPOSE. See the GNU General Public License for more details.
16    *
17    * You should have received a copy of the GNU General Public License
18    * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19    * The Jalview Authors are detailed in the 'AUTHORS' file.
20    */
21    package jalview.ws;
22   
23    import jalview.gui.WebserviceInfo;
24   
25    /**
26    * bookkeeper class for the WebServiceInfo GUI, maintaining records of web
27    * service jobs handled by the window and reflecting any status updates.
28    *
29    * @author JimP
30    *
31    */
 
32    public class JobStateSummary
33    {
34    /**
35    * number of jobs running
36    */
37    int running = 0;
38   
39    /**
40    * number of jobs queued
41    */
42    int queuing = 0;
43   
44    /**
45    * number of jobs finished
46    */
47    int finished = 0;
48   
49    /**
50    * number of jobs failed
51    */
52    int error = 0;
53   
54    /**
55    * number of jobs stopped due to server error
56    */
57    int serror = 0;
58   
59    /**
60    * number of jobs cancelled
61    */
62    int cancelled = 0;
63   
64    /**
65    * number of jobs finished with results
66    */
67    int results = 0;
68   
69    /**
70    * processes an AWSJob's status and updates job status counters and WebService
71    * status displays
72    *
73    * @param wsInfo
74    * @param OutputHeader
75    * @param j
76    */
 
77  1 toggle public void updateJobPanelState(WebserviceInfo wsInfo,
78    String OutputHeader, AWsJob j)
79    {
80  1 if (j.cancelled)
81    {
82  0 cancelled++;
83  0 j.subjobComplete = true;
84  0 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_CANCELLED_OK);
85  0 return;
86    }
87  1 if (j.submitted)
88    {
89  1 String progheader = "";
90    // Parse state of job[j]
91  1 if (j.isRunning())
92    {
93  0 running++;
94  0 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_RUNNING);
95    }
96  1 else if (j.isQueued())
97    {
98  0 queuing++;
99  0 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_QUEUING);
100    }
101  1 else if (j.isFinished())
102    {
103  0 finished++;
104  0 j.subjobComplete = true;
105  0 if (j.hasResults())
106    {
107  0 results++;
108    }
109  0 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_STOPPED_OK);
110    }
111  1 else if (j.isFailed())
112    {
113  0 progheader += "Job failed.\n";
114  0 j.subjobComplete = true;
115  0 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_STOPPED_ERROR);
116  0 error++;
117    }
118  1 else if (j.isServerError())
119    {
120  0 serror++;
121  0 j.subjobComplete = true;
122  0 wsInfo.setStatus(j.jobnum,
123    WebserviceInfo.STATE_STOPPED_SERVERERROR);
124    }
125  1 else if (j.isBroken())
126    {
127  0 progheader += "Job was broken.\n";
128  0 error++;
129  0 j.subjobComplete = true;
130  0 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_STOPPED_ERROR);
131    }
132    // and pass on any sub-job messages to the user
133  1 StringBuffer output = new StringBuffer();
134  1 if (OutputHeader != null)
135    {
136   
137  0 output.append(OutputHeader);
138    }
139  1 if (progheader != null)
140    {
141  1 output.append(progheader);
142    }
143  1 if (j.hasStatus())
144    {
145    // Could try to squash OOMs here, but it usually doesn't help - there
146    // probably won't be
147    // enough memory to handle the results later on anyway.
148    // try {
149  1 String stat = j.getStatus();
150  1 if (stat != null)
151    {
152  1 output.append(stat);
153    }
154    // } catch (OutOfMemoryError e)
155    // {
156    // jalview.bin.Console.errPrintln("Out of memory when displaying status.
157    // Squashing
158    // error.");
159    // wsInfo.appendProgressText(j.jobnum,
160    // "..\n(Out of memory when displaying status)\n");
161    // }
162    }
163  1 wsInfo.setProgressText(j.jobnum, output.toString());
164    }
165    else
166    {
167  0 if (j.submitted && j.subjobComplete)
168    {
169  0 if (j.allowedServerExceptions == 0)
170    {
171  0 serror++;
172    }
173  0 else if (!j.hasResults())
174    {
175  0 error++;
176    }
177    }
178    }
179    }
180    }