Line | Hits | Source |
---|---|---|
1 | package umich.cac.pbs; | |
2 | ||
3 | import java.util.logging.Level; | |
4 | import java.util.logging.Logger; | |
5 | ||
6 | import umich.cac.data.Field; | |
7 | import umich.cac.data.FieldName; | |
8 | import umich.cac.data.FieldType; | |
9 | ||
10 | /** | |
11 | * Process the execution record, "E" record in PBS. | |
12 | * | |
13 | * <pre> | |
14 | * 12/17/2002 10:15:56;E;14862.head;user=ux453679 group=sua248 jobname=maxwell queue=npaci ctime=1039706853 qtime=1039706853 etime=1039706853 start=1040055762 exec_host=node037/0+node036/0 Resource_List.neednodes=node037+node036 Resource_List.nodect=2 Resource_List.nodes=2 Resource_List.walltime=90:00:00 session=7685 end=1040138156 Exit_status=0 resources_used.cput=00:00:00 resources_used.mem=6648kb resources_used.vmem=15848kb resources_used.walltime=22:53:14 | |
15 | * </pre> | |
16 | * | |
17 | * | |
18 | * The corresponding XML is returned inside of <execution_record> tags. | |
19 | * | |
20 | * @author rmach@umich.edu | |
21 | * @version $Header: /cvsroot/pbsaccounting/pbsaccounting/src/umich/cac/pbs/ExecutionRecord.java,v 1.5 2003/10/21 19:39:02 rodmach Exp $ | |
22 | */ | |
23 | ||
24 | 9 | public class ExecutionRecord implements PbsRecordParser { |
25 | ||
26 | /** Logger instance */ | |
27 | 12 | private Logger logger = Logger.getLogger(ExecutionRecord.class.getName()); |
28 | ||
29 | /** | |
30 | * Return the XML representation of an E record, inside | |
31 | * <execution_record> tags. | |
32 | * <p> | |
33 | * | |
34 | * @param rawfields | |
35 | * Array from PBS containing the execution record (E record) | |
36 | * @return The execution record converted to XML | |
37 | */ | |
38 | public String processRecord(String[] rawfields) { | |
39 | ||
40 | 6 | String fieldName = ""; |
41 | 6 | String fieldValue = ""; |
42 | ||
43 | //Execution fields are decribed by 3 main sections, resources listed, | |
44 | // resources used, and then base fields | |
45 | 6 | Field resourceListField = |
46 | new Field( | |
47 | FieldName.RESOURCE_LIST, | |
48 | "resource_list", | |
49 | FieldType.RESOURCE_LIST); | |
50 | 6 | Field resourceUsedField = |
51 | new Field( | |
52 | FieldName.RESOURCE_USED, | |
53 | "resource_used", | |
54 | FieldType.RESOURCE_USED); | |
55 | 6 | Field executionField = |
56 | new Field( | |
57 | FieldName.EXECUTION_FIELD, | |
58 | "execution_field", | |
59 | FieldType.GENERIC); | |
60 | ||
61 | //The job ID for this job from the raw position | |
62 | ||
63 | 6 | Field jobIdField = |
64 | FieldFactory.getInstance().getField( | |
65 | FieldName.JOBID, | |
66 | rawfields[RecordPosition.JOB_ID]); | |
67 | ||
68 | 6 | executionField.addChild(jobIdField); |
69 | ||
70 | //The date for this job from the raw position | |
71 | ||
72 | 6 | Field dateField = |
73 | FieldFactory.getInstance().getField( | |
74 | FieldName.DATE, | |
75 | rawfields[RecordPosition.DATE_TIME]); | |
76 | ||
77 | 6 | executionField.addChild(dateField); |
78 | ||
79 | //Split the message area, which is space separated, into a Array for | |
80 | // processing | |
81 | ||
82 | 6 | String[] fields = rawfields[RecordPosition.MESSAGE_AREA].split(" "); |
83 | ||
84 | //Go through all the fields in the message area, asking the | |
85 | // FieldFactory to return the Field objects | |
86 | ||
87 | 126 | for (int i = 0; i < fields.length; i++) { |
88 | ||
89 | /* | |
90 | * Pairs are encoded as NAME=VALUE in the array most of the time | |
91 | * The FieldFactory will take care of the times where this isn't | |
92 | * the case | |
93 | */ | |
94 | 120 | String nameValue = fields[i]; |
95 | ||
96 | 120 | int indexOfFirstEquals = nameValue.indexOf("="); |
97 | ||
98 | 120 | if (indexOfFirstEquals == -1) { |
99 | //This is just more whitespace, or is not formatted correctly | |
100 | 0 | logger.fine("Could not find = in the field " + nameValue); |
101 | 0 | continue; |
102 | } | |
103 | ||
104 | 120 | fieldName = nameValue.substring(0, indexOfFirstEquals); |
105 | //The add one is to eliminate the first equals | |
106 | 120 | fieldValue = nameValue.substring(indexOfFirstEquals + 1); |
107 | ||
108 | 120 | if (logger.isLoggable(Level.FINE)) { |
109 | 0 | logger.fine( |
110 | "Getting field from factory for field " | |
111 | + fieldName | |
112 | + " and value " | |
113 | + fieldValue); | |
114 | } | |
115 | ||
116 | 120 | Field theField = |
117 | FieldFactory.getInstance().getField(fieldName, fieldValue); | |
118 | ||
119 | 120 | if (theField == null) { |
120 | ||
121 | 0 | logger.warning( |
122 | "No field available for field of name " | |
123 | + fieldName | |
124 | + " and value " | |
125 | + fieldValue | |
126 | + " skipping it..."); | |
127 | ||
128 | } else { | |
129 | ||
130 | /* | |
131 | * | |
132 | * Combine the Fields returned by the FieldFactory based on the | |
133 | * type of Field it is | |
134 | * | |
135 | * (used resource, listed resource, or generic) | |
136 | * | |
137 | */ | |
138 | ||
139 | 120 | if (theField.getFieldType() == FieldType.RESOURCE_LIST) { |
140 | ||
141 | 24 | resourceListField.addChild(theField); |
142 | ||
143 | 96 | } else if ( |
144 | theField.getFieldType() == FieldType.RESOURCE_USED) { | |
145 | ||
146 | 30 | resourceUsedField.addChild(theField); |
147 | ||
148 | 66 | } else if (theField.getFieldType() == FieldType.GENERIC) { |
149 | ||
150 | 66 | executionField.addChild(theField); |
151 | ||
152 | } else { | |
153 | ||
154 | //Do nothing, only care about above fields | |
155 | ||
156 | } | |
157 | ||
158 | } | |
159 | ||
160 | } | |
161 | ||
162 | 6 | executionField.addChild(resourceListField); |
163 | 6 | executionField.addChild(resourceUsedField); |
164 | ||
165 | 6 | return executionField.toXML(); |
166 | ||
167 | } | |
168 | ||
169 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |