2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3 * Copyright (C) 2014 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, WebserviceInfo.STATE_STOPPED_SERVERERROR);
124 else if (j.isBroken())
126 progheader += "Job was broken.\n";
128 j.subjobComplete = true;
129 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_STOPPED_ERROR);
131 // and pass on any sub-job messages to the user
132 StringBuffer output = new StringBuffer();
133 if (OutputHeader != null)
136 output.append(OutputHeader);
138 if (progheader != null)
140 output.append(progheader);
144 // Could try to squash OOMs here, but it usually doesn't help - there
146 // enough memory to handle the results later on anyway.
148 String stat = j.getStatus();
153 // } catch (OutOfMemoryError e)
155 // System.err.println("Out of memory when displaying status. Squashing error.");
156 // wsInfo.appendProgressText(j.jobnum,
157 // "..\n(Out of memory when displaying status)\n");
160 wsInfo.setProgressText(j.jobnum, output.toString());
164 if (j.submitted && j.subjobComplete)
166 if (j.allowedServerExceptions == 0)
170 else if (!j.hasResults())