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 DELETE record, "D" record in PBS. This is when a user cancels a | |
11 | * job for example | |
12 | * <p> | |
13 | * | |
14 | * An example from PBS accounting file is below | |
15 | * | |
16 | * <pre> | |
17 | * 11/21/2002 13:56:46;D;15094.head;requestor=bwickman@head | |
18 | * </pre> | |
19 | * | |
20 | * @author rmach@umich.edu | |
21 | * @version $Header: /cvsroot/pbsaccounting/pbsaccounting/src/umich/cac/pbs/DeleteRecord.java,v 1.4 2003/10/21 19:39:03 rodmach Exp $ | |
22 | */ | |
23 | ||
24 | 6 | public class DeleteRecord implements PbsRecordParser { |
25 | ||
26 | /** Logger instance */ | |
27 | 9 | private Logger logger = Logger.getLogger(DeleteRecord.class.getName()); |
28 | ||
29 | /** | |
30 | * Return the XML representation of an D record, inside <delete_record> | |
31 | * tags. | |
32 | * <p> | |
33 | * | |
34 | * @param rawfields | |
35 | * Array from PBS containing the delete record (D record) | |
36 | * @return The delete record converted to XML | |
37 | */ | |
38 | public String processRecord(String[] rawfields) { | |
39 | ||
40 | //This field | |
41 | 3 | Field deleteField = |
42 | new Field( | |
43 | FieldName.DELETE_FIELD, | |
44 | "delete_record", | |
45 | FieldType.GENERIC); | |
46 | ||
47 | //The JOB ID | |
48 | 3 | Field jobIdField = |
49 | FieldFactory.getInstance().getField( | |
50 | FieldName.JOBID, | |
51 | rawfields[RecordPosition.JOB_ID]); | |
52 | 3 | deleteField.addChild(jobIdField); |
53 | ||
54 | //The DATE | |
55 | 3 | Field dateField = |
56 | FieldFactory.getInstance().getField( | |
57 | FieldName.DATE, | |
58 | rawfields[RecordPosition.DATE_TIME]); | |
59 | 3 | deleteField.addChild(dateField); |
60 | ||
61 | //Split message area that is space seperated string into an array. | |
62 | 3 | String[] fields = rawfields[RecordPosition.MESSAGE_AREA].split(" "); |
63 | ||
64 | //PBS encodes in FIELD=VALUE pairs | |
65 | 3 | int FIELD_NAME = 0; |
66 | 3 | int FIELD_VALUE = 1; |
67 | ||
68 | 3 | String fieldName = ""; |
69 | 3 | String fieldValue = ""; |
70 | ||
71 | //Go through all the fields, querying FieldFactory for fields | |
72 | 6 | for (int i = 0; i < fields.length; i++) { |
73 | 3 | String[] hashPair = fields[i].split("="); |
74 | ||
75 | 3 | fieldName = hashPair[FIELD_NAME]; |
76 | 3 | fieldValue = hashPair[FIELD_VALUE]; |
77 | ||
78 | 3 | Field theField = |
79 | FieldFactory.getInstance().getField(fieldName, fieldValue); | |
80 | ||
81 | //This type only has GENERIC fields, only requestor field | |
82 | 3 | if (theField.getFieldType() == FieldType.GENERIC) { |
83 | 3 | deleteField.addChild(theField); |
84 | } | |
85 | } | |
86 | ||
87 | 3 | return deleteField.toXML(); |
88 | ||
89 | } | |
90 | ||
91 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |