Coverage details for umich.cac.pbs.KRecord

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 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  
263public class KRecord implements PbsRecordParser {
27  
28     /**
29      * Logger instance
30      */
31  
326    private Logger logger = Logger.getLogger(KRecord.class.getName());
33  
34     /**
35      * Return the XML representation of an K record, inside &ltk_record&gt
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
470        Field kField =
48             new Field(FieldName.K_FIELD, "k_record", FieldType.GENERIC);
49  
50         //The JOB ID
510        Field jobIdField =
52             FieldFactory.getInstance().getField(
53                 FieldName.JOBID,
54                 rawfields[RecordPosition.JOB_ID]);
550        kField.addChild(jobIdField);
56  
57         //The DATE
580        Field dateField =
59             FieldFactory.getInstance().getField(
60                 FieldName.DATE,
61                 rawfields[RecordPosition.DATE_TIME]);
620        kField.addChild(dateField);
63  
64         //Split message area that is space seperated string into an array.
650        String[] fields = rawfields[RecordPosition.MESSAGE_AREA].split(" ");
66  
67         //PBS encodes in FIELD=VALUE pairs
680        int FIELD_NAME = 0;
690        int FIELD_VALUE = 1;
70  
710        String fieldName = "";
720        String fieldValue = "";
73  
74         //Go through all the fields, querying FieldFactory for fields
75  
760        for (int i = 0; i < fields.length; i++) {
77  
780            String[] hashPair = fields[i].split("=");
79  
800            fieldName = hashPair[FIELD_NAME];
810            fieldValue = hashPair[FIELD_VALUE];
82  
830            Field theField =
84                 FieldFactory.getInstance().getField(fieldName, fieldValue);
85  
86             //This type only has GENERIC fields, only requestor field
87  
880            if (theField.getFieldType() == FieldType.GENERIC) {
890                kField.addChild(theField);
90             }
91         }
92  
930        return kField.toXML();
94  
95     }
96  
97 }

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.