Coverage details for umich.cac.pbs.YRecord

LineHitsSource
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 Y record, "Y" record in PBSPro
11  * <p>
12  *
13  * This option is specific to PBSPro, on linux
14  *
15  * An example from PBS accounting file is below
16  *
17  * <pre>
18  * 09:57:46;Y;R1570.hypnos;requestor=root@hypnos Interactive=100
19  * </pre>
20  *
21  * @author rmach@umich.edu
22  * @version $Header: /cvsroot/pbsaccounting/pbsaccounting/src/umich/cac/pbs/YRecord.java,v 1.2 2003/10/21 19:07:59 rodmach Exp $
23  */
24  
253public class YRecord implements PbsRecordParser {
26  
27     
28     /**
29      * Logger instance
30      */
316    private Logger logger = Logger.getLogger(YRecord.class.getName());
32  
33     /**
34      * Return the XML representation of an Y record, inside &lty_record&gt
35      * tags.
36      * <p>
37      *
38      * @param rawfields
39      * Array from PBSPro containing the Y record
40      * @return The Y record converted to XML
41      */
42  
43     public String processRecord(String[] rawfields) {
44  
45         //This field
460        Field yField =
47             new Field(FieldName.Y_FIELD, "y_record", FieldType.GENERIC);
48  
49         //The JOB ID
500        Field jobIdField =
51             FieldFactory.getInstance().getField(
52                 FieldName.JOBID,
53                 rawfields[RecordPosition.JOB_ID]);
540        yField.addChild(jobIdField);
55  
56         //The DATE
570        Field dateField =
58             FieldFactory.getInstance().getField(
59                 FieldName.DATE,
60                 rawfields[RecordPosition.DATE_TIME]);
610        yField.addChild(dateField);
62  
63         //Split message area that is space seperated string into an array.
640        String[] fields = rawfields[RecordPosition.MESSAGE_AREA].split(" ");
65  
66         //PBS encodes in FIELD=VALUE pairs
670        int FIELD_NAME = 0;
680        int FIELD_VALUE = 1;
69  
700        String fieldName = "";
710        String fieldValue = "";
72  
73         //Go through all the fields, querying FieldFactory for fields
74  
750        for (int i = 0; i < fields.length; i++) {
76  
770            String[] hashPair = fields[i].split("=");
78  
790            fieldName = hashPair[FIELD_NAME];
800            fieldValue = hashPair[FIELD_VALUE];
81  
820            Field theField =
83                 FieldFactory.getInstance().getField(fieldName, fieldValue);
84  
85             //This type only has GENERIC fields, only requestor field
86  
870            if (theField.getFieldType() == FieldType.GENERIC) {
880                yField.addChild(theField);
89             }
90         }
91  
920        return yField.toXML();
93  
94     }
95  
96 }

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.