Coverage details for umich.cac.pbs.ExecutionRecord

LineHitsSource
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 &ltexecution_record&gt 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  
249public class ExecutionRecord implements PbsRecordParser {
25  
26     /** Logger instance */
2712    private Logger logger = Logger.getLogger(ExecutionRecord.class.getName());
28  
29     /**
30      * Return the XML representation of an E record, inside
31      * &ltexecution_record&gt 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  
406        String fieldName = "";
416        String fieldValue = "";
42  
43         //Execution fields are decribed by 3 main sections, resources listed,
44         // resources used, and then base fields
456        Field resourceListField =
46             new Field(
47                 FieldName.RESOURCE_LIST,
48                 "resource_list",
49                 FieldType.RESOURCE_LIST);
506        Field resourceUsedField =
51             new Field(
52                 FieldName.RESOURCE_USED,
53                 "resource_used",
54                 FieldType.RESOURCE_USED);
556        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  
636        Field jobIdField =
64             FieldFactory.getInstance().getField(
65                 FieldName.JOBID,
66                 rawfields[RecordPosition.JOB_ID]);
67  
686        executionField.addChild(jobIdField);
69  
70         //The date for this job from the raw position
71  
726        Field dateField =
73             FieldFactory.getInstance().getField(
74                 FieldName.DATE,
75                 rawfields[RecordPosition.DATE_TIME]);
76  
776        executionField.addChild(dateField);
78  
79         //Split the message area, which is space separated, into a Array for
80         // processing
81  
826        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  
87126        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              */
94120            String nameValue = fields[i];
95  
96120            int indexOfFirstEquals = nameValue.indexOf("=");
97  
98120            if (indexOfFirstEquals == -1) {
99                 //This is just more whitespace, or is not formatted correctly
1000                logger.fine("Could not find = in the field " + nameValue);
1010                continue;
102             }
103  
104120            fieldName = nameValue.substring(0, indexOfFirstEquals);
105             //The add one is to eliminate the first equals
106120            fieldValue = nameValue.substring(indexOfFirstEquals + 1);
107  
108120            if (logger.isLoggable(Level.FINE)) {
1090                logger.fine(
110                     "Getting field from factory for field "
111                         + fieldName
112                         + " and value "
113                         + fieldValue);
114             }
115  
116120            Field theField =
117                 FieldFactory.getInstance().getField(fieldName, fieldValue);
118  
119120            if (theField == null) {
120  
1210                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  
139120                if (theField.getFieldType() == FieldType.RESOURCE_LIST) {
140  
14124                    resourceListField.addChild(theField);
142  
14396                } else if (
144                     theField.getFieldType() == FieldType.RESOURCE_USED) {
145  
14630                    resourceUsedField.addChild(theField);
147  
14866                } else if (theField.getFieldType() == FieldType.GENERIC) {
149  
15066                    executionField.addChild(theField);
151  
152                 } else {
153  
154                     //Do nothing, only care about above fields
155  
156                 }
157  
158             }
159  
160         }
161  
1626        executionField.addChild(resourceListField);
1636        executionField.addChild(resourceUsedField);
164  
1656        return executionField.toXML();
166  
167     }
168  
169 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.