Line | Hits | Source |
---|---|---|
1 | package umich.cac.pbs; | |
2 | ||
3 | import java.util.logging.Logger; | |
4 | ||
5 | import umich.cac.data.Field; | |
6 | import umich.cac.data.FieldName; | |
7 | import umich.cac.data.FieldType; | |
8 | ||
9 | /** | |
10 | * Process the K record, "K" record in PBSPro. Note there is a bug | |
11 | * in the current version where "K" and "k" are the same record. | |
12 | * <p> | |
13 | * | |
14 | * This option is specific to PBSPro, on linux | |
15 | * | |
16 | * An example from PBS accounting file is below | |
17 | * | |
18 | * <pre> | |
19 | * 4/01/2003 12:54:23;K;R1686.hypnos;requestor=root@hypnos | |
20 | * </pre> | |
21 | * | |
22 | * @author rmach@umich.edu | |
23 | * @version $Header: /cvsroot/pbsaccounting/pbsaccounting/src/umich/cac/pbs/KRecord.java,v 1.2 2003/10/21 19:07:59 rodmach Exp $ | |
24 | */ | |
25 | ||
26 | 3 | public class KRecord implements PbsRecordParser { |
27 | ||
28 | /** | |
29 | * Logger instance | |
30 | */ | |
31 | ||
32 | 6 | private Logger logger = Logger.getLogger(KRecord.class.getName()); |
33 | ||
34 | /** | |
35 | * Return the XML representation of an K record, inside <k_record> | |
36 | * tags. | |
37 | * <p> | |
38 | * | |
39 | * @param rawfields | |
40 | * Array from PBS containing the K record | |
41 | * @return The K record converted to XML | |
42 | */ | |
43 | ||
44 | public String processRecord(String[] rawfields) { | |
45 | ||
46 | //This field | |
47 | 0 | Field kField = |
48 | new Field(FieldName.K_FIELD, "k_record", FieldType.GENERIC); | |
49 | ||
50 | //The JOB ID | |
51 | 0 | Field jobIdField = |
52 | FieldFactory.getInstance().getField( | |
53 | FieldName.JOBID, | |
54 | rawfields[RecordPosition.JOB_ID]); | |
55 | 0 | kField.addChild(jobIdField); |
56 | ||
57 | //The DATE | |
58 | 0 | Field dateField = |
59 | FieldFactory.getInstance().getField( | |
60 | FieldName.DATE, | |
61 | rawfields[RecordPosition.DATE_TIME]); | |
62 | 0 | kField.addChild(dateField); |
63 | ||
64 | //Split message area that is space seperated string into an array. | |
65 | 0 | String[] fields = rawfields[RecordPosition.MESSAGE_AREA].split(" "); |
66 | ||
67 | //PBS encodes in FIELD=VALUE pairs | |
68 | 0 | int FIELD_NAME = 0; |
69 | 0 | int FIELD_VALUE = 1; |
70 | ||
71 | 0 | String fieldName = ""; |
72 | 0 | String fieldValue = ""; |
73 | ||
74 | //Go through all the fields, querying FieldFactory for fields | |
75 | ||
76 | 0 | for (int i = 0; i < fields.length; i++) { |
77 | ||
78 | 0 | String[] hashPair = fields[i].split("="); |
79 | ||
80 | 0 | fieldName = hashPair[FIELD_NAME]; |
81 | 0 | fieldValue = hashPair[FIELD_VALUE]; |
82 | ||
83 | 0 | Field theField = |
84 | FieldFactory.getInstance().getField(fieldName, fieldValue); | |
85 | ||
86 | //This type only has GENERIC fields, only requestor field | |
87 | ||
88 | 0 | if (theField.getFieldType() == FieldType.GENERIC) { |
89 | 0 | kField.addChild(theField); |
90 | } | |
91 | } | |
92 | ||
93 | 0 | return kField.toXML(); |
94 | ||
95 | } | |
96 | ||
97 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |