| Line | Hits | Source |
|---|---|---|
| 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 | ||
| 25 | 3 | public class YRecord implements PbsRecordParser { |
| 26 | ||
| 27 | ||
| 28 | /** | |
| 29 | * Logger instance | |
| 30 | */ | |
| 31 | 6 | private Logger logger = Logger.getLogger(YRecord.class.getName()); |
| 32 | ||
| 33 | /** | |
| 34 | * Return the XML representation of an Y record, inside <y_record> | |
| 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 | |
| 46 | 0 | Field yField = |
| 47 | new Field(FieldName.Y_FIELD, "y_record", FieldType.GENERIC); | |
| 48 | ||
| 49 | //The JOB ID | |
| 50 | 0 | Field jobIdField = |
| 51 | FieldFactory.getInstance().getField( | |
| 52 | FieldName.JOBID, | |
| 53 | rawfields[RecordPosition.JOB_ID]); | |
| 54 | 0 | yField.addChild(jobIdField); |
| 55 | ||
| 56 | //The DATE | |
| 57 | 0 | Field dateField = |
| 58 | FieldFactory.getInstance().getField( | |
| 59 | FieldName.DATE, | |
| 60 | rawfields[RecordPosition.DATE_TIME]); | |
| 61 | 0 | yField.addChild(dateField); |
| 62 | ||
| 63 | //Split message area that is space seperated string into an array. | |
| 64 | 0 | String[] fields = rawfields[RecordPosition.MESSAGE_AREA].split(" "); |
| 65 | ||
| 66 | //PBS encodes in FIELD=VALUE pairs | |
| 67 | 0 | int FIELD_NAME = 0; |
| 68 | 0 | int FIELD_VALUE = 1; |
| 69 | ||
| 70 | 0 | String fieldName = ""; |
| 71 | 0 | String fieldValue = ""; |
| 72 | ||
| 73 | //Go through all the fields, querying FieldFactory for fields | |
| 74 | ||
| 75 | 0 | for (int i = 0; i < fields.length; i++) { |
| 76 | ||
| 77 | 0 | String[] hashPair = fields[i].split("="); |
| 78 | ||
| 79 | 0 | fieldName = hashPair[FIELD_NAME]; |
| 80 | 0 | fieldValue = hashPair[FIELD_VALUE]; |
| 81 | ||
| 82 | 0 | Field theField = |
| 83 | FieldFactory.getInstance().getField(fieldName, fieldValue); | |
| 84 | ||
| 85 | //This type only has GENERIC fields, only requestor field | |
| 86 | ||
| 87 | 0 | if (theField.getFieldType() == FieldType.GENERIC) { |
| 88 | 0 | yField.addChild(theField); |
| 89 | } | |
| 90 | } | |
| 91 | ||
| 92 | 0 | return yField.toXML(); |
| 93 | ||
| 94 | } | |
| 95 | ||
| 96 | } |
|
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |