Coverage details for umich.cac.pbs.StartRecord

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  *
12  * Process the start record, "S" record in PBS. An example is below
13  *
14  * <pre>
15  *
16  * 12/17/2002 10:15:57;S;15037.head;user=ux453909 group=mia259 jobname=Silica_555sro queue=npaci
17  * ctime=1040095430 qtime=1040095430 etime=1040095430 start=1040138157 exec_host=node037/0 Resource_List.neednodes=node037
18  * Resource_List.nodect=1 Resource_List.nodes=1 Resource_List.walltime=100:00:00
19  *
20  * </pre>
21  *
22  * @author rmach@umich.edu
23  * @Version $Header: /cvsroot/pbsaccounting/pbsaccounting/src/umich/cac/pbs/StartRecord.java,v 1.4 2003/10/21 19:07:59 rodmach Exp $
24  */
25  
266public class StartRecord implements PbsRecordParser {
27  
28  
29     /** Logger instance */
30  
319    private Logger logger = Logger.getLogger(StartRecord.class.getName());
32  
33     /**
34      * Return the XML representation of an S record, inside &ltstart_record&gt
35      * tags.
36      * <p>
37      *
38      * @param rawfields
39      * Array from PBS containing the start record (S record)
40      * @return The startrecord converted to XML
41      */
42  
43     public String processRecord(String[] rawfields) {
44  
45         //Split space seperated string into an array.
46  
473        String[] fields = rawfields[RecordPosition.MESSAGE_AREA].split(" ");
48  
49     
50  
513        String fieldName = "";
52  
533        String fieldValue = "";
54  
55         //Start fields only have a resource_list type field besides the
56         // generic fields
57  
583        Field resourceListField =
59             new Field(
60                 FieldName.RESOURCE_LIST,
61                 "resource_list",
62                 FieldType.RESOURCE_LIST);
63  
64         //Start FIELD
65  
663        Field startField =
67             new Field(FieldName.START_FIELD, "start_field", FieldType.GENERIC);
68  
69         //JOB ID
70  
713        Field jobIdField =
72             FieldFactory.getInstance().getField(
73                 FieldName.JOBID,
74                 rawfields[RecordPosition.JOB_ID]);
75  
763        startField.addChild(jobIdField);
77  
78         //DATE
79  
803        Field dateField =
81             FieldFactory.getInstance().getField(
82                 FieldName.DATE,
83                 rawfields[RecordPosition.DATE_TIME]);
84  
853        startField.addChild(dateField);
86  
87         //Go through all the fields, modifying them to be appropriate XML
88         // representation
89  
9042        for (int i = 0; i < fields.length; i++) {
91  
92             /*
93              * Pairs are encoded as NAME=VALUE in the array most of the time
94              * The FieldFactory will take care of the times where this isn't
95              * the case
96              */
9739            String nameValue = fields[i];
98  
9939            int indexOfFirstEquals = nameValue.indexOf("=");
100  
10139            if (indexOfFirstEquals == -1) {
102                 //This is just more whitespace, or is not formatted correctly
1030                logger.fine("Could not find = in the field " + nameValue);
1040                continue;
105             }
106  
10739            fieldName = nameValue.substring(0, indexOfFirstEquals);
108             //The add one is to eliminate the first equals
10939            fieldValue = nameValue.substring(indexOfFirstEquals + 1);
110  
11139            Field theField =
112                 FieldFactory.getInstance().getField(fieldName, fieldValue);
113  
11439            if (theField == null) {
115  
1160                if (logger.isLoggable(Level.WARNING)) {
117  
1180                    logger.warning(
119                         "No field available for field of name "
120                             + fieldName
121                             + " and value "
122                             + fieldValue
123                             + " skipping it...");
124  
125                 }
126  
127             } else {
128  
12939                if (theField.getFieldType() == FieldType.RESOURCE_LIST) {
130  
13112                    resourceListField.addChild(theField);
132  
13327                } else if (theField.getFieldType() == FieldType.GENERIC) {
134  
13524                    startField.addChild(theField);
136  
137                 }
138  
139             }
140  
141         }
142  
1433        startField.addChild(resourceListField);
144  
1453        return startField.toXML();
146  
147     }
148  
149 }

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.