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.
32 public class JobStateSummary
35 * number of jobs running
40 * number of jobs queued
45 * number of jobs finished
50 * number of jobs failed
55 * number of jobs stopped due to server error
60 * number of jobs cancelled
65 * number of jobs finished with results
70 * processes an AWSJob's status and updates job status counters and WebService
77 public void updateJobPanelState(WebserviceInfo wsInfo,
78 String OutputHeader, AWsJob j)
83 j.subjobComplete = true;
84 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_CANCELLED_OK);
89 String progheader = "";
90 // Parse state of job[j]
94 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_RUNNING);
96 else if (j.isQueued())
99 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_QUEUING);
101 else if (j.isFinished())
104 j.subjobComplete = true;
109 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_STOPPED_OK);
111 else if (j.isFailed())
113 progheader += "Job failed.\n";
114 j.subjobComplete = true;
115 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_STOPPED_ERROR);
118 else if (j.isServerError())
121 j.subjobComplete = true;
122 wsInfo.setStatus(j.jobnum,
123 WebserviceInfo.STATE_STOPPED_SERVERERROR);
125 else if (j.isBroken())
127 progheader += "Job was broken.\n";
129 j.subjobComplete = true;
130 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_STOPPED_ERROR);
132 // and pass on any sub-job messages to the user
133 StringBuffer output = new StringBuffer();
134 if (OutputHeader != null)
137 output.append(OutputHeader);
139 if (progheader != null)
141 output.append(progheader);
145 // Could try to squash OOMs here, but it usually doesn't help - there
147 // enough memory to handle the results later on anyway.
149 String stat = j.getStatus();
154 // } catch (OutOfMemoryError e)
156 // System.err.println("Out of memory when displaying status. Squashing
158 // wsInfo.appendProgressText(j.jobnum,
159 // "..\n(Out of memory when displaying status)\n");
162 wsInfo.setProgressText(j.jobnum, output.toString());
166 if (j.submitted && j.subjobComplete)
168 if (j.allowedServerExceptions == 0)
172 else if (!j.hasResults())