| Line | Hits | Source |
|---|---|---|
| 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 | ||
| 26 | 6 | public class StartRecord implements PbsRecordParser { |
| 27 | ||
| 28 | ||
| 29 | /** Logger instance */ | |
| 30 | ||
| 31 | 9 | private Logger logger = Logger.getLogger(StartRecord.class.getName()); |
| 32 | ||
| 33 | /** | |
| 34 | * Return the XML representation of an S record, inside <start_record> | |
| 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 | ||
| 47 | 3 | String[] fields = rawfields[RecordPosition.MESSAGE_AREA].split(" "); |
| 48 | ||
| 49 | ||
| 50 | ||
| 51 | 3 | String fieldName = ""; |
| 52 | ||
| 53 | 3 | String fieldValue = ""; |
| 54 | ||
| 55 | //Start fields only have a resource_list type field besides the | |
| 56 | // generic fields | |
| 57 | ||
| 58 | 3 | Field resourceListField = |
| 59 | new Field( | |
| 60 | FieldName.RESOURCE_LIST, | |
| 61 | "resource_list", | |
| 62 | FieldType.RESOURCE_LIST); | |
| 63 | ||
| 64 | //Start FIELD | |
| 65 | ||
| 66 | 3 | Field startField = |
| 67 | new Field(FieldName.START_FIELD, "start_field", FieldType.GENERIC); | |
| 68 | ||
| 69 | //JOB ID | |
| 70 | ||
| 71 | 3 | Field jobIdField = |
| 72 | FieldFactory.getInstance().getField( | |
| 73 | FieldName.JOBID, | |
| 74 | rawfields[RecordPosition.JOB_ID]); | |
| 75 | ||
| 76 | 3 | startField.addChild(jobIdField); |
| 77 | ||
| 78 | //DATE | |
| 79 | ||
| 80 | 3 | Field dateField = |
| 81 | FieldFactory.getInstance().getField( | |
| 82 | FieldName.DATE, | |
| 83 | rawfields[RecordPosition.DATE_TIME]); | |
| 84 | ||
| 85 | 3 | startField.addChild(dateField); |
| 86 | ||
| 87 | //Go through all the fields, modifying them to be appropriate XML | |
| 88 | // representation | |
| 89 | ||
| 90 | 42 | 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 | */ | |
| 97 | 39 | String nameValue = fields[i]; |
| 98 | ||
| 99 | 39 | int indexOfFirstEquals = nameValue.indexOf("="); |
| 100 | ||
| 101 | 39 | if (indexOfFirstEquals == -1) { |
| 102 | //This is just more whitespace, or is not formatted correctly | |
| 103 | 0 | logger.fine("Could not find = in the field " + nameValue); |
| 104 | 0 | continue; |
| 105 | } | |
| 106 | ||
| 107 | 39 | fieldName = nameValue.substring(0, indexOfFirstEquals); |
| 108 | //The add one is to eliminate the first equals | |
| 109 | 39 | fieldValue = nameValue.substring(indexOfFirstEquals + 1); |
| 110 | ||
| 111 | 39 | Field theField = |
| 112 | FieldFactory.getInstance().getField(fieldName, fieldValue); | |
| 113 | ||
| 114 | 39 | if (theField == null) { |
| 115 | ||
| 116 | 0 | if (logger.isLoggable(Level.WARNING)) { |
| 117 | ||
| 118 | 0 | 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 | ||
| 129 | 39 | if (theField.getFieldType() == FieldType.RESOURCE_LIST) { |
| 130 | ||
| 131 | 12 | resourceListField.addChild(theField); |
| 132 | ||
| 133 | 27 | } else if (theField.getFieldType() == FieldType.GENERIC) { |
| 134 | ||
| 135 | 24 | startField.addChild(theField); |
| 136 | ||
| 137 | } | |
| 138 | ||
| 139 | } | |
| 140 | ||
| 141 | } | |
| 142 | ||
| 143 | 3 | startField.addChild(resourceListField); |
| 144 | ||
| 145 | 3 | return startField.toXML(); |
| 146 | ||
| 147 | } | |
| 148 | ||
| 149 | } |
|
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |