Clover icon

Coverage Report

  1. Project Clover database Thu Dec 4 2025 16:11:35 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
183
100
18
0.38
48
1
18

Classes

Class Line # Actions
JobStateSummary 35 48 18
0.3827160638.3%
 

Contributing tests

This file is covered by 1 test. .

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    * TODO: separate from the GUI cleanly since it also holds logic for
30    * interpreting failure states
31    *
32    * @author JimP
33    *
34    */
 
35    public class JobStateSummary
36    {
37    /**
38    * number of jobs running
39    */
40    int running = 0;
41   
42    /**
43    * number of jobs queued
44    */
45    int queuing = 0;
46   
47    /**
48    * number of jobs finished
49    */
50    int finished = 0;
51   
52    /**
53    * number of jobs failed
54    */
55    int error = 0;
56   
57    /**
58    * number of jobs stopped due to server error
59    */
60    int serror = 0;
61   
62    /**
63    * number of jobs cancelled
64    */
65    int cancelled = 0;
66   
67    /**
68    * number of jobs finished with results
69    */
70    int results = 0;
71   
72    /**
73    * processes an AWSJob's status and updates job status counters and WebService
74    * status displays
75    *
76    * @param wsInfo
77    * @param OutputHeader
78    * @param j
79    */
 
80  1 toggle public void updateJobPanelState(WebserviceInfo wsInfo,
81    String OutputHeader, AWsJob j)
82    {
83  1 if (j.cancelled)
84    {
85  0 cancelled++;
86  0 j.subjobComplete = true;
87  0 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_CANCELLED_OK);
88  0 return;
89    }
90  1 if (j.submitted)
91    {
92  1 String progheader = "";
93    // Parse state of job[j]
94  1 if (j.isRunning())
95    {
96  0 running++;
97  0 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_RUNNING);
98    }
99  1 else if (j.isQueued())
100    {
101  0 queuing++;
102  0 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_QUEUING);
103    }
104  1 else if (j.isFinished())
105    {
106  0 finished++;
107  0 j.subjobComplete = true;
108  0 if (j.hasResults())
109    {
110  0 results++;
111    }
112  0 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_STOPPED_OK);
113    }
114  1 else if (j.isFailed())
115    {
116  0 progheader += "Job failed.\n";
117  0 j.subjobComplete = true;
118  0 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_STOPPED_ERROR);
119  0 error++;
120    }
121  1 else if (j.isServerError())
122    {
123  0 serror++;
124  0 j.subjobComplete = true;
125  0 wsInfo.setStatus(j.jobnum,
126    WebserviceInfo.STATE_STOPPED_SERVERERROR);
127    }
128  1 else if (j.isBroken())
129    {
130  0 progheader += "Job was broken.\n";
131  0 error++;
132  0 j.subjobComplete = true;
133  0 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_STOPPED_ERROR);
134    }
135    // and pass on any sub-job messages to the user
136  1 StringBuffer output = new StringBuffer();
137  1 if (OutputHeader != null)
138    {
139   
140  0 output.append(OutputHeader);
141    }
142  1 if (progheader != null)
143    {
144  1 output.append(progheader);
145    }
146  1 if (j.hasStatus())
147    {
148    // Could try to squash OOMs here, but it usually doesn't help - there
149    // probably won't be
150    // enough memory to handle the results later on anyway.
151    // try {
152  1 String stat = j.getStatus();
153  1 if (stat != null)
154    {
155  1 output.append(stat);
156    }
157    // } catch (OutOfMemoryError e)
158    // {
159    // jalview.bin.Console.errPrintln("Out of memory when displaying status.
160    // Squashing
161    // error.");
162    // wsInfo.appendProgressText(j.jobnum,
163    // "..\n(Out of memory when displaying status)\n");
164    // }
165    }
166  1 wsInfo.setProgressText(j.jobnum, output.toString());
167    }
168    else
169    {
170  0 if (j.submitted && j.subjobComplete)
171    {
172  0 if (j.allowedServerExceptions == 0)
173    {
174  0 serror++;
175    }
176  0 else if (!j.hasResults())
177    {
178  0 error++;
179    }
180    }
181    }
182    }
183    }