001: /*
002: * This file or a portion of this file is licensed under the terms of
003: * the Globus Toolkit Public License, found in file GTPL, or at
004: * http://www.globus.org/toolkit/download/license.html. This notice must
005: * appear in redistributions of this file, with or without modification.
006: *
007: * Redistributions of this Software, with or without modification, must
008: * reproduce the GTPL in: (1) the Software, or (2) the Documentation or
009: * some other similar material which is provided with the Software (if
010: * any).
011: *
012: * Copyright 1999-2004 University of Chicago and The University of
013: * Southern California. All rights reserved.
014: */
015:
016: package org.griphyn.cPlanner.classes;
017:
018: import org.griphyn.common.util.Currently;
019:
020: import java.util.Date;
021:
022: /**
023: * A Data class containing the metrics about the planning instance.
024: *
025: * @author Karan Vahi
026: * @version $Revision: 319 $
027: */
028: public class PlannerMetrics extends Data {
029:
030: /**
031: * The base submit directory where the files are being created.
032: */
033: private String mBaseSubmitDirectory;
034:
035: /**
036: * The relative submit directory for this run.
037: */
038: private String mRelativeSubmitDirectory;
039:
040: /**
041: * The path to the DAX that was planned by the workflow.
042: */
043: private String mDAXPath;
044:
045: /**
046: * The pointer to the properties file that was used.
047: */
048: private String mPropertiesPath;
049:
050: /**
051: * The user who planned the workflow.
052: */
053: private String mUser;
054:
055: /**
056: * The VOGroup to which the user belonged to.
057: */
058: private String mVOGroup;
059:
060: /**
061: * The metrics about the workflow.
062: */
063: private WorkflowMetrics mWFMetrics;
064:
065: /**
066: * The start time for hte planning.
067: */
068: private Date mStartTime;
069:
070: /**
071: * The end time for the planning.
072: */
073: private Date mEndTime;
074:
075: /**
076: * The default metrics.
077: */
078: public PlannerMetrics() {
079:
080: }
081:
082: /**
083: * Returns the workflow metrics.
084: *
085: * @return the workflow metrics.
086: */
087: public WorkflowMetrics getWorkflowMetrics() {
088: return mWFMetrics;
089: }
090:
091: /**
092: * Sets the workflow metrics.
093: *
094: * @param metrics the workflow metrics.
095: */
096: public void setWorkflowMetrics(WorkflowMetrics metrics) {
097: mWFMetrics = metrics;
098: }
099:
100: /**
101: * Returns the username.
102: *
103: * @return the user.
104: */
105: public String setUser() {
106: return mUser;
107: }
108:
109: /**
110: * Sets the user.
111: *
112: * @param user the user.
113: */
114: public void setUser(String user) {
115: mUser = user;
116: }
117:
118: /**
119: * Sets the vo group
120: *
121: * @param group the vo group.
122: */
123: public void setVOGroup(String group) {
124: this .mVOGroup = group;
125: }
126:
127: /**
128: * Returns the VO Group.
129: *
130: * @return the VO Group to which the user belongs
131: */
132: public String getVOGroup() {
133: return this .mVOGroup;
134: }
135:
136: /**
137: * Sets the path to the properties file for the run.
138: *
139: * @param path the path to the properties file.
140: */
141: public void setProperties(String path) {
142: mPropertiesPath = path;
143: }
144:
145: /**
146: * Returns the path to the properties file for the run.
147: *
148: * @return the path to the properties file.
149: */
150: public String getProperties() {
151: return mPropertiesPath;
152: }
153:
154: /**
155: * Sets the path to the base submit directory.
156: *
157: * @param base the path to the base submit directory.
158: */
159: public void setBaseSubmitDirectory(String base) {
160: mBaseSubmitDirectory = base;
161: }
162:
163: /**
164: * Returns the path to the base submit directory.
165: *
166: * @return the path to the base submit directory.
167: */
168: public String getBaseSubmitDirectory() {
169: return mBaseSubmitDirectory;
170: }
171:
172: /**
173: * Sets the path to the submit directory relative to the base.
174: *
175: * @param relative the relative path from the base submit directory.
176: */
177: public void setRelativeSubmitDirectory(String relative) {
178: mRelativeSubmitDirectory = relative;
179: }
180:
181: /**
182: * Returns the path to the relative submit directory.
183: *
184: * @return the path to the relative submit directory.
185: */
186: public String getRelativeSubmitDirectory() {
187: return mRelativeSubmitDirectory;
188: }
189:
190: /**
191: * Sets the path to the DAX.
192: *
193: * @param path the path to the DAX file.
194: */
195: public void setDAX(String path) {
196: mDAXPath = path;
197: }
198:
199: /**
200: * Sets the path to the DAX.
201: *
202: * @return the path to the DAX file.
203: */
204: public String getDAX() {
205: return mDAXPath;
206: }
207:
208: /**
209: * Set the start time for the planning operation.
210: *
211: * @param start the start time.
212: */
213: public void setStartTime(Date start) {
214: mStartTime = start;
215: }
216:
217: /**
218: * Returns the start time for the planning operation.
219: *
220: * @return the start time.
221: */
222: public Date getStartTime() {
223: return mStartTime;
224: }
225:
226: /**
227: * Set the end time for the planning operation.
228: *
229: * @param end the end time.
230: */
231: public void setEndTime(Date end) {
232: mEndTime = end;
233: }
234:
235: /**
236: * Returns the end time for the planning operation.
237: *
238: * @return the end time.
239: */
240: public Date getEndTime() {
241: return mEndTime;
242: }
243:
244: /**
245: * Returns a textual description of the object.
246: *
247: * @return Object
248: */
249: public String toString() {
250: StringBuffer sb = new StringBuffer();
251:
252: sb.append("{").append("\n");
253:
254: append(sb, "user", this .mUser);
255: append(sb, "vogroup", this .mVOGroup);
256: append(sb, "submitdir.base", this .mBaseSubmitDirectory);
257: append(sb, "submitdir.relative", this .mRelativeSubmitDirectory);
258: append(sb, "planning.start", Currently.iso8601(false, true,
259: false, mStartTime));
260: append(sb, "planning.end", Currently.iso8601(false, true,
261: false, mEndTime));
262: append(sb, "properties", this .mPropertiesPath);
263: append(sb, "dax", this .mDAXPath);
264: sb.append(this .getWorkflowMetrics());
265:
266: sb.append("}").append("\n");
267:
268: return sb.toString();
269: }
270:
271: /**
272: * Appends a key=value pair to the StringBuffer.
273: *
274: * @param buffer the StringBuffer that is to be appended to.
275: * @param key the key.
276: * @param value the value.
277: */
278: protected void append(StringBuffer buffer, String key, String value) {
279: buffer.append(key).append(" = ").append(value).append("\n");
280: }
281:
282: /**
283: * Returns the clone of the object.
284: *
285: * @return the clone
286: */
287: public Object clone() {
288: PlannerMetrics pm;
289: try {
290: pm = (PlannerMetrics) super .clone();
291: } catch (CloneNotSupportedException e) {
292: //somewhere in the hierarch chain clone is not implemented
293: throw new RuntimeException(
294: "Clone not implemented in the base class of "
295: + this.getClass().getName(), e);
296: }
297:
298: pm.setUser(this.mUser);
299: pm.setVOGroup(this.mVOGroup);
300: pm.setBaseSubmitDirectory(this.mBaseSubmitDirectory);
301: pm.setRelativeSubmitDirectory(this.mRelativeSubmitDirectory);
302: pm.setProperties(this.mPropertiesPath);
303: pm.setDAX(this.mDAXPath);
304: pm.setStartTime(this.mStartTime);
305: pm.setEndTime(this.mEndTime);
306:
307: return pm;
308: }
309: }
|