Commit in hps-java/src/main/java/org/lcsim/hps/conditions on MAIN | |||
DatabaseConditionsReader.java | +12 | -43 | 1.20 -> 1.21 |
remove check on run range as well as checking the detector name; these don't seem relevant for HPS (for now)
diff -u -r1.20 -r1.21 --- DatabaseConditionsReader.java 15 Oct 2013 23:24:47 -0000 1.20 +++ DatabaseConditionsReader.java 18 Oct 2013 06:08:55 -0000 1.21 @@ -38,7 +38,7 @@
* </p> * * @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: DatabaseConditionsReader.java,v 1.20 2013/10/15 23:24:47 jeremy Exp $
+ * @version $Id: DatabaseConditionsReader.java,v 1.21 2013/10/18 06:08:55 jeremy Exp $
*/ public class DatabaseConditionsReader extends ConditionsReader {
@@ -48,14 +48,8 @@
/** Base ConditionsReader for getting the Detector. */ private final ConditionsReader reader;
- /** Name of the detector. */ - private String detectorName; - - /** Current minimum run number. This is updated as conditions are loaded. */ - private int minRun = Integer.MAX_VALUE; - - /** Current maximum run number. This is updated as conditions are loaded. */ - private int maxRun = Integer.MIN_VALUE;
+ /** The current run number to determine if conditions are already loaded. */ + private int currentRun = Integer.MIN_VALUE;
/** Converter for making ConditionsRecord objects from the database. */ ConditionsRecordConverter conditionsRecordConverter = new ConditionsRecordConverter();
@@ -110,32 +104,22 @@
*/ public boolean update(ConditionsManager manager, String detectorName, int run) throws IOException {
- logger.info("update ..."); - logger.info("detectorName: " + detectorName); - logger.info("run: " + run);
+ logger.info("updating detector <" + detectorName + "> for run <" + run + "> ...");
- // Setup detector. - if (this.detectorName == null) { - this.detectorName = detectorName; - logger.info("set detectorName: " + this.detectorName); - } else { - if (!this.detectorName.equals(detectorName)) - throw new IllegalArgumentException(); - } - - // Check if conditions for this run are already loaded. - if (run <= maxRun && run >= minRun) { - logger.warning("Conditions already cached for this run.");
+ // Check if conditions are already cached for the run. + if (run == currentRun) { + logger.warning("Conditions already cached for run <" + run + ">.");
return false; }
-
+
// Register the converters on the manager.
+ // FIXME: This should really only happen once instead of being called here every time.
ConditionsConverterRegister.register(manager); // Open a connection to the database. connection = ConnectionManager.getConnectionManager().createConnection();
- // Cache the run numbers.
+ // Cache the ConditionsRecords.
try { setup(run); } catch (Exception e) {
@@ -169,27 +153,12 @@
} /**
- * This will cache the run number range. More could happen here but conditions - * data is generally loaded lazily (as needed).
+ * This will cache the ConditionsRecords for the run.
* @param run The run number. * @throws SQLException * @throws IOException */ private final void setup(int run) throws SQLException, IOException {
- - ConditionsRecordCollection records = ConditionsRecord.find(run); - - for (ConditionsRecord record : records) { - - if (record.getRunStart() < minRun) { - minRun = record.getRunStart(); - logger.info("set min run: " + minRun); - } - - if (record.getRunEnd() > maxRun) { - maxRun = record.getRunEnd(); - logger.info("set max run: " + maxRun); - } - }
+ ConditionsRecord.find(run);
} }
Use REPLY-ALL to reply to list
To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1