2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.1)
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)
81 j.subjobComplete=true;
82 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_CANCELLED_OK);
87 String progheader = "";
88 // Parse state of job[j]
92 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_RUNNING);
94 else if (j.isQueued())
97 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_QUEUING);
99 else if (j.isFinished())
102 j.subjobComplete = true;
107 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_STOPPED_OK);
109 else if (j.isFailed())
111 progheader += "Job failed.\n";
112 j.subjobComplete = true;
113 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_STOPPED_ERROR);
116 else if (j.isServerError())
119 j.subjobComplete = true;
120 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_STOPPED_SERVERERROR);
122 else if (j.isBroken())
124 progheader += "Job was broken.\n";
126 j.subjobComplete = true;
127 wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_STOPPED_ERROR);
129 // and pass on any sub-job messages to the user
130 StringBuffer output = new StringBuffer();
131 if (OutputHeader != null)
134 output.append(OutputHeader);
136 if (progheader != null)
138 output.append(progheader);
142 // Could try to squash OOMs here, but it usually doesn't help - there
144 // enough memory to handle the results later on anyway.
146 String stat = j.getStatus();
151 // } catch (OutOfMemoryError e)
153 // System.err.println("Out of memory when displaying status. Squashing error.");
154 // wsInfo.appendProgressText(j.jobnum,
155 // "..\n(Out of memory when displaying status)\n");
158 wsInfo.setProgressText(j.jobnum, output.toString());
162 if (j.submitted && j.subjobComplete)
164 if (j.allowedServerExceptions == 0)
168 else if (!j.hasResults())