2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)
3 * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
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 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
20 import jalview.gui.WebserviceInfo;
23 * bookkeeper class for the WebServiceInfo GUI, maintaining records of web
24 * service jobs handled by the window and reflecting any status updates.
29 public class JobStateSummary
32 * number of jobs running
37 * number of jobs queued
42 * number of jobs finished
47 * number of jobs failed
52 * number of jobs stopped due to server error
57 * number of jobs cancelled
62 * number of jobs finished with results
67 * processes an AWSJob's status and updates job status counters and WebService
74 public void updateJobPanelState(WebserviceInfo wsInfo,
75 String OutputHeader, AWsJob j)
79 String progheader = "";
80 // Parse state of job[j]
84 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_RUNNING);
86 else if (j.isQueued())
89 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_QUEUING);
91 else if (j.isFinished())
94 j.subjobComplete = true;
99 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_STOPPED_OK);
101 else if (j.isFailed())
103 progheader += "Job failed.\n";
104 j.subjobComplete = true;
105 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_STOPPED_ERROR);
108 else if (j.isServerError())
111 j.subjobComplete = true;
112 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_STOPPED_SERVERERROR);
114 else if (j.isBroken())
116 progheader += "Job was broken.\n";
118 j.subjobComplete = true;
119 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_STOPPED_ERROR);
121 // and pass on any sub-job messages to the user
122 StringBuffer output=new StringBuffer();
123 if (OutputHeader!=null) {
125 output.append(OutputHeader);
127 if (progheader!=null)
129 output.append(progheader);
133 // Could try to squash OOMs here, but it usually doesn't help - there
135 // enough memory to handle the results later on anyway.
137 String stat = j.getStatus();
141 // } catch (OutOfMemoryError e)
143 // System.err.println("Out of memory when displaying status. Squashing error.");
144 // wsInfo.appendProgressText(j.jobnum,
145 // "..\n(Out of memory when displaying status)\n");
148 wsInfo.setProgressText(j.jobnum,output.toString());
152 if (j.submitted && j.subjobComplete)
154 if (j.allowedServerExceptions == 0)
158 else if (!j.hasResults())