2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
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.
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.
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.
23 import jalview.gui.WebserviceInfo;
26 * bookkeeper class for the WebServiceInfo GUI, maintaining records of web
27 * service jobs handled by the window and reflecting any status updates.
29 * TODO: separate from the GUI cleanly since it also holds logic for
30 * interpreting failure states
35 public class JobStateSummary
38 * number of jobs running
43 * number of jobs queued
48 * number of jobs finished
53 * number of jobs failed
58 * number of jobs stopped due to server error
63 * number of jobs cancelled
68 * number of jobs finished with results
73 * processes an AWSJob's status and updates job status counters and WebService
80 public void updateJobPanelState(WebserviceInfo wsInfo,
81 String OutputHeader, AWsJob j)
86 j.subjobComplete = true;
87 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_CANCELLED_OK);
92 String progheader = "";
93 // Parse state of job[j]
97 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_RUNNING);
99 else if (j.isQueued())
102 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_QUEUING);
104 else if (j.isFinished())
107 j.subjobComplete = true;
112 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_STOPPED_OK);
114 else if (j.isFailed())
116 progheader += "Job failed.\n";
117 j.subjobComplete = true;
118 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_STOPPED_ERROR);
121 else if (j.isServerError())
124 j.subjobComplete = true;
125 wsInfo.setStatus(j.jobnum,
126 WebserviceInfo.STATE_STOPPED_SERVERERROR);
128 else if (j.isBroken())
130 progheader += "Job was broken.\n";
132 j.subjobComplete = true;
133 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_STOPPED_ERROR);
135 // and pass on any sub-job messages to the user
136 StringBuffer output = new StringBuffer();
137 if (OutputHeader != null)
140 output.append(OutputHeader);
142 if (progheader != null)
144 output.append(progheader);
148 // Could try to squash OOMs here, but it usually doesn't help - there
150 // enough memory to handle the results later on anyway.
152 String stat = j.getStatus();
157 // } catch (OutOfMemoryError e)
159 // System.err.println("Out of memory when displaying status. Squashing
161 // wsInfo.appendProgressText(j.jobnum,
162 // "..\n(Out of memory when displaying status)\n");
165 wsInfo.setProgressText(j.jobnum, output.toString());
169 if (j.submitted && j.subjobComplete)
171 if (j.allowedServerExceptions == 0)
175 else if (!j.hasResults())