Line | Hits | Source |
---|---|---|
1 | package umich.cac.data; | |
2 | ||
3 | import java.util.List; | |
4 | ||
5 | /** | |
6 | * | |
7 | * FieldName class This class encapsulates the display name (the name given to | |
8 | * the XML tag) | |
9 | * | |
10 | * and raw name (the name PBS used to encode the data) to a field | |
11 | * | |
12 | * <p> | |
13 | * | |
14 | * For example, PBS encodes the exit status of a job with the name | |
15 | * "Exit_status", this is the raw name. | |
16 | * | |
17 | * We display in the XML the name "exit_status", which is the display name for | |
18 | * this raw field. | |
19 | * | |
20 | * @author rmach@umich.edu | |
21 | * @version $Header: /cvsroot/pbsaccounting/pbsaccounting/src/umich/cac/data/FieldName.java,v 1.4 2003/10/21 19:08:00 rodmach Exp $ | |
22 | * | |
23 | */ | |
24 | ||
25 | public class FieldName { | |
26 | ||
27 | 267 | private String displayName = null; |
28 | ||
29 | 267 | private String rawName = null; |
30 | ||
31 | 267 | private FieldType fieldType = null; |
32 | ||
33 | /** The name of the queue from which the job was executed */ | |
34 | ||
35 | 3 | public final static FieldName QUEUE = |
36 | new FieldName("queue", "queue", FieldType.GENERIC); | |
37 | ||
38 | /** | |
39 | * A node. The raw name for this field is not defined in PBS, and is used | |
40 | * for container of node information | |
41 | */ | |
42 | ||
43 | 3 | public final static FieldName NODE = |
44 | new FieldName("node", "node", FieldType.GENERIC); | |
45 | ||
46 | /** The group name under which the job executed */ | |
47 | ||
48 | 3 | public final static FieldName GROUP = |
49 | new FieldName("group", "group", FieldType.GENERIC); | |
50 | ||
51 | /** The name of the job as chosen by the user */ | |
52 | ||
53 | 3 | public final static FieldName JOBNAME = |
54 | new FieldName("jobname", "jobname", FieldType.GENERIC); | |
55 | ||
56 | /** | |
57 | * The ctime of the job, the time in seconds when the job was created | |
58 | * (first submitted) | |
59 | */ | |
60 | ||
61 | 3 | public final static FieldName CTIME = |
62 | new FieldName("ctime", "ctime", FieldType.GENERIC); | |
63 | ||
64 | /** | |
65 | * The qtime of the job, the time in seconds when the job was queued into | |
66 | * the current queue | |
67 | */ | |
68 | ||
69 | 3 | public final static FieldName QTIME = |
70 | new FieldName("qtime", "qtime", FieldType.GENERIC); | |
71 | ||
72 | /** | |
73 | * The etime of the job, the time in seconds when the job became eligible | |
74 | * to run, no holds etc | |
75 | */ | |
76 | ||
77 | 3 | public final static FieldName ETIME = |
78 | new FieldName("etime", "etime", FieldType.GENERIC); | |
79 | ||
80 | /** The start of the job, the time in seconds when job execution started */ | |
81 | ||
82 | 3 | public final static FieldName START = |
83 | new FieldName("start", "start", FieldType.GENERIC); | |
84 | ||
85 | /** The memory of the job */ | |
86 | ||
87 | 3 | public final static FieldName MEMORY = |
88 | new FieldName("memory", "memory", FieldType.GENERIC); | |
89 | ||
90 | /** The memory units of the job */ | |
91 | ||
92 | 3 | public final static FieldName UNITS = |
93 | new FieldName("units", "units", FieldType.GENERIC); | |
94 | ||
95 | /** The session number of the job */ | |
96 | ||
97 | 3 | public final static FieldName SESSION = |
98 | new FieldName("session", "session", FieldType.GENERIC); | |
99 | ||
100 | /** The end of the job */ | |
101 | ||
102 | 3 | public final static FieldName END = |
103 | new FieldName("end", "end", FieldType.GENERIC); | |
104 | ||
105 | /** Exit status of job */ | |
106 | ||
107 | 3 | public final static FieldName EXIT_STATUS = |
108 | new FieldName("exit_status", "Exit_status", FieldType.GENERIC); | |
109 | ||
110 | /** container of user running job, not defined in PBS */ | |
111 | ||
112 | 3 | public final static FieldName USER = |
113 | new FieldName("user", "user", FieldType.GENERIC); | |
114 | ||
115 | /** Name of user running job */ | |
116 | ||
117 | 3 | public final static FieldName NAME = |
118 | new FieldName("name", "name", FieldType.GENERIC); | |
119 | ||
120 | /** Date, part of base record */ | |
121 | ||
122 | 3 | public final static FieldName DATE = |
123 | new FieldName("date", "date", FieldType.GENERIC); | |
124 | ||
125 | /** | |
126 | * The day of the record, as in 10/12/2002, not defined in PBS, it is | |
127 | * extracted from Date | |
128 | */ | |
129 | ||
130 | 3 | public final static FieldName DAY = |
131 | new FieldName("day", "day", FieldType.GENERIC); | |
132 | ||
133 | /** | |
134 | * The time of the record, as in 10:11:11, not defined in PBS, it is | |
135 | * extracted from Date | |
136 | */ | |
137 | ||
138 | 3 | public final static FieldName TIME = |
139 | new FieldName("time", "time", FieldType.GENERIC); | |
140 | ||
141 | /** Job Id, part of base */ | |
142 | ||
143 | 3 | public final static FieldName JOBID = |
144 | new FieldName("jobid", "jobid", FieldType.GENERIC); | |
145 | ||
146 | /** Nodename lists node resources job ran on */ | |
147 | ||
148 | 3 | public final static FieldName NODENAME = |
149 | new FieldName("nodename", "nodename", FieldType.GENERIC); | |
150 | ||
151 | /** | |
152 | * CPU is the cpu number the job ran on, not defined in PBS, it is | |
153 | * extracted from nodename | |
154 | */ | |
155 | ||
156 | 3 | public final static FieldName CPU = |
157 | new FieldName("cpu", "cpu", FieldType.GENERIC); | |
158 | ||
159 | /** The requester for a job cancellation */ | |
160 | ||
161 | 3 | public final static FieldName REQUESTOR = |
162 | new FieldName("requestor", "requestor", FieldType.GENERIC); | |
163 | ||
164 | /** A list of nodes assigned to job */ | |
165 | ||
166 | 3 | public final static FieldName NEED_NODES = |
167 | new FieldName( | |
168 | "neednodes", | |
169 | "Resource_List.neednodes", | |
170 | FieldType.RESOURCE_LIST); | |
171 | ||
172 | /** The node count requested */ | |
173 | ||
174 | 3 | public final static FieldName NODECT = |
175 | new FieldName( | |
176 | "nodect", | |
177 | "Resource_List.nodect", | |
178 | FieldType.RESOURCE_LIST); | |
179 | ||
180 | /** The number of nodes requested */ | |
181 | ||
182 | 3 | public final static FieldName NODES = |
183 | new FieldName("nodes", "Resource_List.nodes", FieldType.RESOURCE_LIST); | |
184 | ||
185 | /** The wall time requested */ | |
186 | ||
187 | 3 | public final static FieldName WALLTIME_R = |
188 | new FieldName( | |
189 | "walltime", | |
190 | "Resource_List.walltime", | |
191 | FieldType.RESOURCE_LIST); | |
192 | ||
193 | /** The memory requested */ | |
194 | ||
195 | 3 | public final static FieldName MEMORY_R = |
196 | new FieldName("mem", "Resource_List.mem", FieldType.RESOURCE_LIST); | |
197 | ||
198 | /** The cpu time used */ | |
199 | ||
200 | 3 | public final static FieldName CPUTIME = |
201 | new FieldName("cput", "resources_used.cput", FieldType.RESOURCE_USED); | |
202 | ||
203 | /** The memory used */ | |
204 | ||
205 | 3 | public final static FieldName MEM = |
206 | new FieldName("mem", "resources_used.mem", FieldType.RESOURCE_USED); | |
207 | ||
208 | /** The wall time used */ | |
209 | ||
210 | 3 | public final static FieldName WALLTIME = |
211 | new FieldName( | |
212 | "walltime", | |
213 | "resources_used.walltime", | |
214 | FieldType.RESOURCE_USED); | |
215 | ||
216 | /** The virtual memory used */ | |
217 | ||
218 | 3 | public final static FieldName VMEM = |
219 | new FieldName("vmem", "resources_used.vmem", FieldType.RESOURCE_USED); | |
220 | ||
221 | /** The execution host(s) ran on */ | |
222 | ||
223 | 3 | public final static FieldName EXEC_HOST = |
224 | new FieldName("exec_host", "exec_host", FieldType.RESOURCE_USED); | |
225 | ||
226 | /** Container field */ | |
227 | ||
228 | 3 | public final static FieldName RESOURCE_LIST = |
229 | new FieldName( | |
230 | "resource_list", | |
231 | "resource_list", | |
232 | FieldType.RESOURCE_LIST); | |
233 | ||
234 | /** Container field */ | |
235 | ||
236 | 3 | public final static FieldName RESOURCE_USED = |
237 | new FieldName( | |
238 | "resources_used", | |
239 | "resources_used", | |
240 | FieldType.RESOURCE_USED); | |
241 | ||
242 | /** Execution Field */ | |
243 | ||
244 | 3 | public final static FieldName EXECUTION_FIELD = |
245 | new FieldName( | |
246 | "execution_record", | |
247 | "execution_record", | |
248 | FieldType.GENERIC); | |
249 | ||
250 | /** Wait field */ | |
251 | ||
252 | 3 | public final static FieldName QUEUE_FIELD = |
253 | new FieldName("queue_record", "queue_record", FieldType.GENERIC); | |
254 | ||
255 | /** Start Field */ | |
256 | ||
257 | 3 | public final static FieldName START_FIELD = |
258 | new FieldName("start_record", "start_record", FieldType.GENERIC); | |
259 | ||
260 | /** Delete Field */ | |
261 | ||
262 | 3 | public final static FieldName DELETE_FIELD = |
263 | new FieldName("delete_record", "delete_record", FieldType.GENERIC); | |
264 | ||
265 | /** Rerun Field */ | |
266 | ||
267 | 3 | public final static FieldName RERUN_FIELD = |
268 | new FieldName("rerun_record", "rerun_record", FieldType.GENERIC); | |
269 | ||
270 | /** Checkpoint restart Field */ | |
271 | ||
272 | 3 | public final static FieldName CHECKPOINT_RESTART_FIELD = |
273 | new FieldName( | |
274 | "checkpoint_restart_record", | |
275 | "checkpoint_restart_record", | |
276 | FieldType.GENERIC); | |
277 | ||
278 | /** Abort Field */ | |
279 | ||
280 | 3 | public final static FieldName ABORT_FIELD = |
281 | new FieldName("abort_record", "abort_record", FieldType.GENERIC); | |
282 | ||
283 | /** Origin Specific. The number of CPUS requested */ | |
284 | ||
285 | 3 | public final static FieldName NUMCPUS = |
286 | new FieldName("ncpus", "Resource_List.ncpus", FieldType.RESOURCE_LIST); | |
287 | ||
288 | /** Origin Specific. The CPU time requested */ | |
289 | ||
290 | 3 | public final static FieldName CPUT = |
291 | new FieldName("cput", "Resource_List.cput", FieldType.RESOURCE_LIST); | |
292 | ||
293 | /** Origin Specific. The percentage of CPU time used */ | |
294 | ||
295 | 3 | public final static FieldName CPU_PERCENT = |
296 | new FieldName( | |
297 | "cpupercent", | |
298 | "resources_used.cpupercent", | |
299 | FieldType.RESOURCE_USED); | |
300 | ||
301 | /** Added by PBSPro on Linux. The Number of CPU's actually used */ | |
302 | 3 | public final static FieldName CPU_USED = |
303 | new FieldName("ncpus", "resources_used.ncpus", FieldType.RESOURCE_USED); | |
304 | ||
305 | /** KField. PBS Pro specific on Linux */ | |
306 | 3 | public final static FieldName K_FIELD = |
307 | new FieldName("k_record", "k_record", FieldType.GENERIC); | |
308 | ||
309 | /** UField. PBS Pro specific on Linux */ | |
310 | 3 | public final static FieldName U_FIELD = |
311 | new FieldName("u_record", "u_record", FieldType.GENERIC); | |
312 | ||
313 | /** YField. PBS Pro specific on Linux */ | |
314 | 3 | public final static FieldName Y_FIELD = |
315 | new FieldName("y_record", "y_record", FieldType.GENERIC); | |
316 | ||
317 | /** BField. PBS Pro specific on Linux */ | |
318 | 3 | public final static FieldName B_FIELD = |
319 | new FieldName("b_record", "b_record", FieldType.GENERIC); | |
320 | ||
321 | /** Owner, specific to BField. PBS Pro specific on Linux */ | |
322 | 3 | public final static FieldName OWNER = |
323 | new FieldName("owner", "owner", FieldType.GENERIC); | |
324 | ||
325 | /** Duration, specific to BField. PBS Pro specific on Linux */ | |
326 | 3 | public final static FieldName DURATION = |
327 | new FieldName("duration", "duration", FieldType.GENERIC); | |
328 | ||
329 | /** InteractiveField. PBS Pro specific on Linux */ | |
330 | 3 | public final static FieldName INTERACTIVE_FIELD = |
331 | new FieldName("interactive", "Interactive", FieldType.GENERIC); | |
332 | ||
333 | /** The list of nodes, for a BRecord PBS Pro specific on linux */ | |
334 | 3 | public final static FieldName BNODES = |
335 | new FieldName("nodelist", "nodes", FieldType.GENERIC); | |
336 | ||
337 | /** Authorized users is for BRecord, PBS Pro specific on linux */ | |
338 | 3 | public final static FieldName AUTHORIZED_USERS = |
339 | new FieldName( | |
340 | "authorized_users", | |
341 | "Authorized_Users", | |
342 | FieldType.GENERIC); | |
343 | ||
344 | /** Used for optional account parameter for charging job to specific account */ | |
345 | 3 | public final static FieldName ACCOUNT = |
346 | new FieldName("account", "account", FieldType.GENERIC); | |
347 | ||
348 | /** A array of all field names */ | |
349 | ||
350 | 3 | private static FieldName[] allFields = |
351 | new FieldName[] { | |
352 | QUEUE, | |
353 | NEED_NODES, | |
354 | NODE, | |
355 | NODECT, | |
356 | NODES, | |
357 | WALLTIME_R, | |
358 | CPUTIME, | |
359 | MEM, | |
360 | WALLTIME, | |
361 | VMEM, | |
362 | NEED_NODES, | |
363 | EXEC_HOST, | |
364 | EXIT_STATUS, | |
365 | USER, | |
366 | NAME, | |
367 | EXECUTION_FIELD, | |
368 | DATE, | |
369 | GROUP, | |
370 | JOBNAME, | |
371 | CTIME, | |
372 | QTIME, | |
373 | ETIME, | |
374 | START, | |
375 | SESSION, | |
376 | END, | |
377 | JOBID, | |
378 | MEMORY, | |
379 | UNITS, | |
380 | NODENAME, | |
381 | CPU, | |
382 | TIME, | |
383 | DAY, | |
384 | DATE, | |
385 | REQUESTOR, | |
386 | DELETE_FIELD, | |
387 | NUMCPUS, | |
388 | CPUT, | |
389 | CPU_PERCENT, | |
390 | MEMORY_R, | |
391 | CHECKPOINT_RESTART_FIELD, | |
392 | RERUN_FIELD, | |
393 | CPU_USED, | |
394 | K_FIELD, | |
395 | U_FIELD, | |
396 | Y_FIELD, | |
397 | B_FIELD, | |
398 | OWNER, | |
399 | DURATION, | |
400 | BNODES, | |
401 | INTERACTIVE_FIELD, | |
402 | AUTHORIZED_USERS, | |
403 | ACCOUNT }; | |
404 | ||
405 | /** | |
406 | * | |
407 | * Constructor | |
408 | * | |
409 | * @param displayName | |
410 | * the name that will appear in XML tag, like "exec_host" | |
411 | * | |
412 | * @param rawName | |
413 | * the name that PBS uses to describe the field, like | |
414 | * "Exec_Host" | |
415 | * | |
416 | * @param fieldType | |
417 | * Description of the Parameter | |
418 | * | |
419 | */ | |
420 | ||
421 | 267 | public FieldName(String displayName, String rawName, FieldType fieldType) { |
422 | ||
423 | 267 | this.displayName = displayName; |
424 | 267 | this.rawName = rawName; |
425 | 267 | this.fieldType = fieldType; |
426 | 267 | } |
427 | ||
428 | /** | |
429 | * | |
430 | * Compare two FieldName's objects for equality based on their raw fields | |
431 | * | |
432 | * @param fieldName | |
433 | * The field to compare to | |
434 | * | |
435 | * @return true if the raw values are the same | |
436 | * | |
437 | */ | |
438 | ||
439 | public boolean rawequals(FieldName fieldName) { | |
440 | ||
441 | 3018 | if (fieldName == null) { |
442 | 0 | return false; |
443 | } | |
444 | ||
445 | 3018 | if (fieldName.rawName.equals(rawName)) { |
446 | 87 | return true; |
447 | } else { | |
448 | 2931 | return false; |
449 | } | |
450 | } | |
451 | ||
452 | /** | |
453 | * | |
454 | * get all fields | |
455 | * | |
456 | * @return The allFieldNames value | |
457 | * | |
458 | */ | |
459 | ||
460 | public static FieldName[] getAllFieldNames() { | |
461 | 3 | return allFields; |
462 | } | |
463 | ||
464 | /** | |
465 | * | |
466 | * Gets the fieldType attribute of the FieldName object | |
467 | * | |
468 | * @return The fieldType value | |
469 | * | |
470 | */ | |
471 | ||
472 | public FieldType getFieldType() { | |
473 | 303 | return fieldType; |
474 | } | |
475 | ||
476 | /** | |
477 | * Get the open tag name for this field | |
478 | * | |
479 | * @return tagname for this field, like <FOOBAR> | |
480 | */ | |
481 | ||
482 | public String openTag() { | |
483 | 0 | return "<" + displayName + ">"; |
484 | } | |
485 | ||
486 | /** | |
487 | * Get the open tag name for this field including the attributes named by | |
488 | * the List of Attribute objects passed to this method | |
489 | * | |
490 | * @return tagname for this field, like <FOOBAR> | |
491 | */ | |
492 | public String openTag(List attributeList) { | |
493 | ||
494 | 504 | if (attributeList == null) { |
495 | 0 | throw new IllegalArgumentException("attribute list can not be null"); |
496 | } | |
497 | ||
498 | 504 | StringBuffer openTagBuffer = new StringBuffer(); |
499 | 504 | openTagBuffer.append("<"); |
500 | 504 | openTagBuffer.append(displayName); |
501 | ||
502 | 579 | for (int i = 0; i < attributeList.size(); i++) { |
503 | 75 | Attribute attribute = (Attribute) attributeList.get(i); |
504 | 75 | openTagBuffer.append(" "); |
505 | 75 | openTagBuffer.append(attribute.toXML()); |
506 | } | |
507 | ||
508 | 504 | openTagBuffer.append(">"); |
509 | ||
510 | 504 | return openTagBuffer.toString(); |
511 | ||
512 | } | |
513 | ||
514 | /** | |
515 | * | |
516 | * Get the "raw" name, which is the original encoded name | |
517 | * | |
518 | * in the PBS file, like Resource_List.nodect | |
519 | * | |
520 | * @return The rawName value | |
521 | * | |
522 | */ | |
523 | ||
524 | public String getRawName() { | |
525 | 357 | return rawName; |
526 | } | |
527 | ||
528 | /** | |
529 | * | |
530 | * Get the display name, which is the name that is used | |
531 | * | |
532 | * for the XML tag, like display name for Resource_List.nodect | |
533 | * | |
534 | * is nodect | |
535 | * | |
536 | * @return The displayName value | |
537 | * | |
538 | */ | |
539 | ||
540 | public String getDisplayName() { | |
541 | 0 | return displayName; |
542 | } | |
543 | ||
544 | /** | |
545 | * | |
546 | * Get the closed tag name for this field | |
547 | * | |
548 | * @return closed tagname for this field, like </FOOBAR> | |
549 | * | |
550 | */ | |
551 | ||
552 | public String closeTag() { | |
553 | 504 | return "</" + displayName + ">"; |
554 | ||
555 | } | |
556 | ||
557 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |