1 | /* |
---|
2 | * This program is free software; you can redistribute it and/or modify |
---|
3 | * it under the terms of the GNU General Public License as published by |
---|
4 | * the Free Software Foundation; either version 2 of the License, or |
---|
5 | * (at your option) any later version. |
---|
6 | * |
---|
7 | * This program is distributed in the hope that it will be useful, |
---|
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
10 | * GNU General Public License for more details. |
---|
11 | * |
---|
12 | * You should have received a copy of the GNU General Public License |
---|
13 | * along with this program; if not, write to the Free Software |
---|
14 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
15 | */ |
---|
16 | |
---|
17 | /* |
---|
18 | * TaskStatusInfo.java |
---|
19 | * Copyright (C) 2001 University of Waikato, Hamilton, New Zealand |
---|
20 | * |
---|
21 | */ |
---|
22 | |
---|
23 | package weka.experiment; |
---|
24 | |
---|
25 | import weka.core.RevisionHandler; |
---|
26 | import weka.core.RevisionUtils; |
---|
27 | |
---|
28 | import java.io.Serializable; |
---|
29 | |
---|
30 | /** |
---|
31 | * A class holding information for tasks being executed |
---|
32 | * on RemoteEngines. Also holds an object encapsulating any returnable result |
---|
33 | * produced by the task (Note: result object must be serializable). Task |
---|
34 | * objects execute methods return instances of this class. RemoteEngines also |
---|
35 | * use this class for storing progress information for tasks that they |
---|
36 | * execute. |
---|
37 | * |
---|
38 | * @author <a href="mailto:mhall@cs.waikato.ac.nz">Mark Hall</a> |
---|
39 | * @version $Revision: 1.5 $ |
---|
40 | */ |
---|
41 | public class TaskStatusInfo |
---|
42 | implements Serializable, RevisionHandler { |
---|
43 | |
---|
44 | /** for serialization */ |
---|
45 | private static final long serialVersionUID = -6129343303703560015L; |
---|
46 | |
---|
47 | public static final int TO_BE_RUN = 0; |
---|
48 | public static final int PROCESSING=1; |
---|
49 | public static final int FAILED=2; |
---|
50 | public static final int FINISHED=3; |
---|
51 | |
---|
52 | /** |
---|
53 | * Holds current execution status. |
---|
54 | */ |
---|
55 | private int m_ExecutionStatus = TO_BE_RUN; |
---|
56 | |
---|
57 | /** |
---|
58 | * Holds current status message. |
---|
59 | */ |
---|
60 | private String m_StatusMessage = "New Task"; |
---|
61 | |
---|
62 | /** |
---|
63 | * Holds task result. Set to null for no returnable result. |
---|
64 | */ |
---|
65 | private Object m_TaskResult = null; |
---|
66 | |
---|
67 | /** |
---|
68 | * Set the execution status of this Task. |
---|
69 | * |
---|
70 | * @param newStatus the new execution status code |
---|
71 | */ |
---|
72 | public void setExecutionStatus(int newStatus) { |
---|
73 | m_ExecutionStatus = newStatus; |
---|
74 | } |
---|
75 | |
---|
76 | /** |
---|
77 | * Get the execution status of this Task. |
---|
78 | * @return the execution status |
---|
79 | */ |
---|
80 | public int getExecutionStatus() { |
---|
81 | return m_ExecutionStatus; |
---|
82 | } |
---|
83 | |
---|
84 | /** |
---|
85 | * Set the status message. |
---|
86 | * |
---|
87 | * @param newMessage the new status message |
---|
88 | */ |
---|
89 | public void setStatusMessage(String newMessage) { |
---|
90 | m_StatusMessage = newMessage; |
---|
91 | } |
---|
92 | |
---|
93 | /** |
---|
94 | * Get the status message. |
---|
95 | * |
---|
96 | * @return the status message |
---|
97 | */ |
---|
98 | public String getStatusMessage() { |
---|
99 | return m_StatusMessage; |
---|
100 | } |
---|
101 | |
---|
102 | /** |
---|
103 | * Set the returnable result for this task.. |
---|
104 | * |
---|
105 | * @param taskResult the new returnable result for the task. null if no |
---|
106 | * result is returnable. |
---|
107 | */ |
---|
108 | public void setTaskResult(Object taskResult) { |
---|
109 | m_TaskResult = taskResult; |
---|
110 | } |
---|
111 | |
---|
112 | /** |
---|
113 | * Get the returnable result of this task. |
---|
114 | * |
---|
115 | * @return an object encapsulating the result of executing the task. May |
---|
116 | * be null if the task has no returnable result (eg. a remote experiment |
---|
117 | * task that sends its results to a data base). |
---|
118 | */ |
---|
119 | public Object getTaskResult() { |
---|
120 | return m_TaskResult; |
---|
121 | } |
---|
122 | |
---|
123 | /** |
---|
124 | * Returns the revision string. |
---|
125 | * |
---|
126 | * @return the revision |
---|
127 | */ |
---|
128 | public String getRevision() { |
---|
129 | return RevisionUtils.extract("$Revision: 1.5 $"); |
---|
130 | } |
---|
131 | } |
---|