 
| Line | Hits | Source | 
|---|---|---|
| 1 | package umich.cac.data; | |
| 2 | ||
| 3 | import umich.cac.pbs.FieldFactory; | |
| 4 | ||
| 5 | /** | |
| 6 | * | |
| 7 | * This class encapsulates Node fields. A node consists of a nodename, and | |
| 8 | * optionally a cpu. | |
| 9 | * | |
| 10 | * PBS encodes these together in a single field, using different separators. | |
| 11 | * | |
| 12 | * <p> | |
| 13 | * | |
| 14 | * An example rendering output from this Field would be | |
| 15 | * | |
| 16 | * <pre> | |
| 17 | * <node> | |
| 18 | * | |
| 19 | * <nodename>node047</nodename> | |
| 20 | * | |
| 21 | * <cpu>0</cpu> | |
| 22 | * | |
| 23 | * </node> | |
| 24 | * | |
| 25 | * </pre> | |
| 26 | * | |
| 27 | * @author rmach@umich.edu | |
| 28 | * @version $Header: /cvsroot/pbsaccounting/pbsaccounting/src/umich/cac/data/NodeField.java,v 1.3 2003/10/21 19:08:00 rodmach Exp $ | |
| 29 | * | |
| 30 | */ | |
| 31 | ||
| 32 | public class NodeField extends Field { | |
| 33 | ||
| 34 | ||
| 35 | ||
| 36 | /** Nodes and CPU's are seperated by / */ | |
| 37 | 27 | private String NODE_SEPARATOR = "\\/"; | 
| 38 | ||
| 39 | /** Node name is in position zero after split */ | |
| 40 | 27 | private int NODENAME = 0; | 
| 41 | ||
| 42 | /** CPU is in position one after split */ | |
| 43 | 27 | private int CPU = 1; | 
| 44 | ||
| 45 | /** | |
| 46 | * Constructor for NodeField field, for a RESOURCE_USED field type | |
| 47 | * | |
| 48 | * @param fieldName | |
| 49 | * Name of this field | |
| 50 | * @param rawValue | |
| 51 | * the raw value of this field from PBS accounting data | |
| 52 | */ | |
| 53 | ||
| 54 | public NodeField(FieldName fieldName, String rawValue) { | |
| 55 | ||
| 56 | 27 | super(fieldName, rawValue, FieldType.RESOURCE_USED); | 
| 57 | 27 | setupChildren(rawValue); | 
| 58 | ||
| 59 | 27 | } | 
| 60 | ||
| 61 | /** | |
| 62 | * Alternate Constructor for NodeField field | |
| 63 | * | |
| 64 | * @param fieldName | |
| 65 | * Name of this field | |
| 66 | * @param rawValue | |
| 67 | * the raw value of this field from PBS accounting data | |
| 68 | * @param fieldType | |
| 69 | * The field type this should be under= | |
| 70 | */ | |
| 71 | ||
| 72 | public NodeField( | |
| 73 | FieldName fieldName, | |
| 74 | String rawValue, | |
| 75 | FieldType fieldType) { | |
| 76 | ||
| 77 | 0 | super(fieldName, rawValue, fieldType); | 
| 78 | 0 | setupChildren(rawValue); | 
| 79 | ||
| 80 | 0 | } | 
| 81 | ||
| 82 | /** | |
| 83 | * | |
| 84 | * Contains children of type node. If just a hostname is encoded, only the | |
| 85 | * NODENAME field | |
| 86 | * | |
| 87 | * is added. If a CPU and NAME are encoded both NODENAME and CPU fields are | |
| 88 | * added. | |
| 89 | * | |
| 90 | * @param rawValue | |
| 91 | * Description of the Parameter | |
| 92 | * | |
| 93 | */ | |
| 94 | ||
| 95 | private void setupChildren(String rawValue) { | |
| 96 | ||
| 97 | 27 | String[] nodeNameAndCpu = rawValue.split(NODE_SEPARATOR); | 
| 98 | ||
| 99 | //No CPU for this node type if field length is 1, otherwise if 2 we | |
| 100 | // have a CPU added | |
| 101 | ||
| 102 | 27 | if (nodeNameAndCpu.length == 1) { | 
| 103 | ||
| 104 | 0 | Field nameNode = | 
| 105 | FieldFactory.getInstance().getField( | |
| 106 | FieldName.NODENAME, | |
| 107 | nodeNameAndCpu[NODENAME]); | |
| 108 | 0 | addChild(nameNode); | 
| 109 | ||
| 110 | 27 | } else if (nodeNameAndCpu.length == 2) { | 
| 111 | ||
| 112 | 27 | Field nameNode = | 
| 113 | FieldFactory.getInstance().getField( | |
| 114 | FieldName.NODENAME, | |
| 115 | nodeNameAndCpu[NODENAME]); | |
| 116 | ||
| 117 | 27 | addChild(nameNode); | 
| 118 | ||
| 119 | 27 | Field cpuNode = | 
| 120 | FieldFactory.getInstance().getField( | |
| 121 | FieldName.CPU, | |
| 122 | nodeNameAndCpu[CPU]); | |
| 123 | ||
| 124 | 27 | addChild(cpuNode); | 
| 125 | ||
| 126 | } | |
| 127 | ||
| 128 | 27 | } | 
| 129 | ||
| 130 | } | 
| 
this report was generated by version 1.0.5 of jcoverage. | 
copyright © 2003, jcoverage ltd. all rights reserved. |