2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
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 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/>.
17 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 import jalview.gui.WebserviceInfo;
24 * bookkeeper class for the WebServiceInfo GUI, maintaining records of web
25 * service jobs handled by the window and reflecting any status updates.
30 public class JobStateSummary
33 * number of jobs running
38 * number of jobs queued
43 * number of jobs finished
48 * number of jobs failed
53 * number of jobs stopped due to server error
58 * number of jobs cancelled
63 * number of jobs finished with results
68 * processes an AWSJob's status and updates job status counters and WebService
75 public void updateJobPanelState(WebserviceInfo wsInfo,
76 String OutputHeader, AWsJob j)
80 String progheader = "";
81 // Parse state of job[j]
85 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_RUNNING);
87 else if (j.isQueued())
90 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_QUEUING);
92 else if (j.isFinished())
95 j.subjobComplete = true;
100 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_STOPPED_OK);
102 else if (j.isFailed())
104 progheader += "Job failed.\n";
105 j.subjobComplete = true;
106 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_STOPPED_ERROR);
109 else if (j.isServerError())
112 j.subjobComplete = true;
113 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_STOPPED_SERVERERROR);
115 else if (j.isBroken())
117 progheader += "Job was broken.\n";
119 j.subjobComplete = true;
120 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_STOPPED_ERROR);
122 // and pass on any sub-job messages to the user
123 StringBuffer output = new StringBuffer();
124 if (OutputHeader != null)
127 output.append(OutputHeader);
129 if (progheader != null)
131 output.append(progheader);
135 // Could try to squash OOMs here, but it usually doesn't help - there
137 // enough memory to handle the results later on anyway.
139 String stat = j.getStatus();
144 // } catch (OutOfMemoryError e)
146 // System.err.println("Out of memory when displaying status. Squashing error.");
147 // wsInfo.appendProgressText(j.jobnum,
148 // "..\n(Out of memory when displaying status)\n");
151 wsInfo.setProgressText(j.jobnum, output.toString());
155 if (j.submitted && j.subjobComplete)
157 if (j.allowedServerExceptions == 0)
161 else if (!j.hasResults())