| Line | Hits | Source |
|---|---|---|
| 1 | package umich.cac.pbs; | |
| 2 | ||
| 3 | import java.util.logging.Level; | |
| 4 | import java.util.logging.Logger; | |
| 5 | ||
| 6 | /** | |
| 7 | * RecordFactory to return the right kind of PbsRecord processor based on the | |
| 8 | * RecordType. | |
| 9 | * <P> | |
| 10 | * | |
| 11 | * Processors are available for the following RecordTypes Types available for | |
| 12 | * OpenPBS | |
| 13 | * <UL> | |
| 14 | * <LI>EXECUTION_RECORD</LI> | |
| 15 | * <LI>START_RECORD</LI> | |
| 16 | * <LI>QUEUE_RECORD</LI> | |
| 17 | * <LI>DELETE_RECORD</LI> | |
| 18 | * <LI>RERUN_RECORD</LI> | |
| 19 | * <LI>CHECKPOINT_RESTART_RECORD</LI> | |
| 20 | * <LI>ABORT_RECORD</LI> | |
| 21 | * </UL> | |
| 22 | * | |
| 23 | * This is the list of PbsPro extended records supported | |
| 24 | * <UL> | |
| 25 | * <LI>K_RECORD</LI> | |
| 26 | * <LI>U_RECORD</LI> | |
| 27 | * <LI>Y_RECORD</LI> | |
| 28 | * </UL> | |
| 29 | * This is ignored for PbsPro | |
| 30 | * <UL> | |
| 31 | * <LI>L_RECORD</LI> | |
| 32 | * </UL> | |
| 33 | * | |
| 34 | * Parsers for C records (checkpoint), are not yet created as I didn't have | |
| 35 | * examples to work off of for these records. If you have an example entry | |
| 36 | * please email me the examples and I can add those record types to the next | |
| 37 | * release. | |
| 38 | * | |
| 39 | * @author rmach@umich.edu | |
| 40 | * @version $Header: /cvsroot/pbsaccounting/pbsaccounting/src/umich/cac/pbs/RecordFactory.java,v 1.4 2003/10/21 19:07:59 rodmach Exp $ | |
| 41 | */ | |
| 42 | ||
| 43 | public class RecordFactory { | |
| 44 | ||
| 45 | /** | |
| 46 | * Logger | |
| 47 | */ | |
| 48 | ||
| 49 | 6 | private Logger logger = Logger.getLogger(RecordFactory.class.getName()); |
| 50 | ||
| 51 | /** | |
| 52 | * Parser to parse execution records | |
| 53 | */ | |
| 54 | ||
| 55 | 3 | private ExecutionRecord executionRecordParser = new ExecutionRecord(); |
| 56 | ||
| 57 | /** | |
| 58 | * Parser to parse start records | |
| 59 | */ | |
| 60 | ||
| 61 | 3 | private StartRecord startRecordParser = new StartRecord(); |
| 62 | ||
| 63 | /** | |
| 64 | * Parser to parse Queue records | |
| 65 | */ | |
| 66 | ||
| 67 | 3 | private QueueRecord queueRecordParser = new QueueRecord(); |
| 68 | ||
| 69 | /** | |
| 70 | * Parser to parse Delete records | |
| 71 | */ | |
| 72 | ||
| 73 | 3 | private DeleteRecord deleteRecordParser = new DeleteRecord(); |
| 74 | ||
| 75 | /** | |
| 76 | * Parser to parse Rerun records | |
| 77 | */ | |
| 78 | ||
| 79 | 3 | private RerunRecord rerunRecordParser = new RerunRecord(); |
| 80 | ||
| 81 | /** | |
| 82 | * Parser to parse Abort records | |
| 83 | */ | |
| 84 | ||
| 85 | 3 | private AbortRecord abortRecordParser = new AbortRecord(); |
| 86 | ||
| 87 | /** | |
| 88 | * Parser to parse K records (PbsPro specific) | |
| 89 | */ | |
| 90 | 3 | private KRecord kRecordParser = new KRecord(); |
| 91 | ||
| 92 | /** | |
| 93 | * Parser to parse U records (PbsPro specific) | |
| 94 | */ | |
| 95 | 3 | private URecord uRecordParser = new URecord(); |
| 96 | ||
| 97 | /** | |
| 98 | * Parser specific to Y records (PbsPro specific) | |
| 99 | * | |
| 100 | */ | |
| 101 | 3 | private YRecord yRecordParser = new YRecord(); |
| 102 | ||
| 103 | /** | |
| 104 | * Parser specific to L (license) records (PbsPro specific, Ignored) | |
| 105 | * | |
| 106 | */ | |
| 107 | 3 | private LRecord lRecordParser = new LRecord(); |
| 108 | ||
| 109 | /** | |
| 110 | * Parser specific to B records (PbsPro specific) | |
| 111 | * | |
| 112 | */ | |
| 113 | 3 | private BRecord bRecordParser = new BRecord(); |
| 114 | ||
| 115 | /** | |
| 116 | * Parser to parse Checkpoint Restart records | |
| 117 | */ | |
| 118 | ||
| 119 | 3 | private CheckpointRestartRecord checkpointRestartParser = |
| 120 | new CheckpointRestartRecord(); | |
| 121 | ||
| 122 | //The singleton instance | |
| 123 | 3 | private static RecordFactory thisInstance = null; |
| 124 | ||
| 125 | /** | |
| 126 | * Get singleton instance | |
| 127 | * | |
| 128 | * @return The instance value | |
| 129 | */ | |
| 130 | ||
| 131 | public static synchronized RecordFactory getInstance() { | |
| 132 | ||
| 133 | 21 | if (thisInstance == null) { |
| 134 | 3 | thisInstance = new RecordFactory(); |
| 135 | } | |
| 136 | ||
| 137 | 21 | return thisInstance; |
| 138 | } | |
| 139 | ||
| 140 | /** | |
| 141 | * private constructor | |
| 142 | */ | |
| 143 | ||
| 144 | 3 | private RecordFactory() { |
| 145 | //Empty constructor, no overriding | |
| 146 | 3 | } |
| 147 | ||
| 148 | /** | |
| 149 | * Return a PbsRecord processor based on the record type, or NULL if the | |
| 150 | * recordType is not known. The check is not case sensitive because it | |
| 151 | * appears PbsPro returns lower and upper case for record types. | |
| 152 | * | |
| 153 | * @param recordType | |
| 154 | * type of record | |
| 155 | * @return PbsRecord that can process the given recordType | |
| 156 | */ | |
| 157 | ||
| 158 | public PbsRecordParser getRecordParser(RecordType recordType) { | |
| 159 | ||
| 160 | 21 | if (recordType.equals(RecordType.EXECUTION_RECORD)) { |
| 161 | ||
| 162 | 3 | return executionRecordParser; |
| 163 | 18 | } else if (recordType.equals(RecordType.START_RECORD)) { |
| 164 | ||
| 165 | 3 | return startRecordParser; |
| 166 | 15 | } else if (recordType.equals(RecordType.QUEUE_RECORD)) { |
| 167 | ||
| 168 | 6 | return queueRecordParser; |
| 169 | 9 | } else if (recordType.equals(RecordType.DELETE_RECORD)) { |
| 170 | ||
| 171 | 3 | return deleteRecordParser; |
| 172 | 6 | } else if (recordType.equals(RecordType.RERUN_RECORD)) { |
| 173 | ||
| 174 | 0 | return rerunRecordParser; |
| 175 | 6 | } else if (recordType.equals(RecordType.ABORT_RECORD)) { |
| 176 | ||
| 177 | 0 | return abortRecordParser; |
| 178 | 6 | } else if (recordType.equals(RecordType.CHECKPOINT_RESTART_RECORD)) { |
| 179 | ||
| 180 | 0 | return checkpointRestartParser; |
| 181 | 6 | } else if (recordType.equals(RecordType.K_RECORD)) { |
| 182 | 0 | return kRecordParser; |
| 183 | 6 | } else if (recordType.equals(RecordType.U_RECORD)) { |
| 184 | 0 | return uRecordParser; |
| 185 | 6 | } else if (recordType.equals(RecordType.Y_RECORD)) { |
| 186 | 0 | return yRecordParser; |
| 187 | 6 | } else if (recordType.equals(RecordType.B_RECORD)) { |
| 188 | 0 | return bRecordParser; |
| 189 | 6 | } else if (recordType.equals(RecordType.L_RECORD)) { |
| 190 | 0 | return lRecordParser; |
| 191 | } else { | |
| 192 | 6 | if (logger.isLoggable(Level.WARNING)) { |
| 193 | 6 | logger.log(Level.WARNING, "Unknown Record Type" + recordType); |
| 194 | } | |
| 195 | ||
| 196 | 6 | return null; |
| 197 | } | |
| 198 | ||
| 199 | } | |
| 200 | ||
| 201 | } |
|
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |