LISTSERV mailing list manager LISTSERV 16.5

Help for HPS-SVN Archives


HPS-SVN Archives

HPS-SVN Archives


HPS-SVN@LISTSERV.SLAC.STANFORD.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

HPS-SVN Home

HPS-SVN Home

HPS-SVN  September 2015

HPS-SVN September 2015

Subject:

r3533 - /java/trunk/conditions/src/main/java/org/hps/conditions/database/DatabaseConditionsManager.java

From:

[log in to unmask]

Reply-To:

Notification of commits to the hps svn repository <[log in to unmask]>

Date:

Sat, 5 Sep 2015 00:10:54 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (180 lines)

Author: [log in to unmask]
Date: Fri Sep  4 17:10:50 2015
New Revision: 3533

Log:
Cleanup log messages; fix some initialization having to do with test run setup; make sure internal tag collection is managed properly.

Modified:
    java/trunk/conditions/src/main/java/org/hps/conditions/database/DatabaseConditionsManager.java

Modified: java/trunk/conditions/src/main/java/org/hps/conditions/database/DatabaseConditionsManager.java
 =============================================================================
--- java/trunk/conditions/src/main/java/org/hps/conditions/database/DatabaseConditionsManager.java	(original)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/database/DatabaseConditionsManager.java	Fri Sep  4 17:10:50 2015
@@ -11,6 +11,8 @@
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
+import java.util.Collection;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.LinkedHashSet;
 import java.util.List;
@@ -114,7 +116,7 @@
 
         // Is there no manager installed yet?
         if (!ConditionsManager.isSetup() || !(ConditionsManager.defaultInstance() instanceof DatabaseConditionsManager)) {
-            LOGGER.finest("creating new DatabaseConditionsManager instance");
+            
             // Create a new instance if necessary, which will install it globally as the default.
             DatabaseConditionsManager dbManager = new DatabaseConditionsManager();
 
@@ -125,7 +127,6 @@
         // Get the instance back from the default conditions system and check that the type is correct now.
         final ConditionsManager manager = ConditionsManager.defaultInstance();
         if (!(manager instanceof DatabaseConditionsManager)) {
-            LOGGER.severe("default conditions manager has wrong type: " + manager.getClass());
             throw new RuntimeException("Default conditions manager has the wrong type: "
                     + ConditionsManager.defaultInstance().getClass().getName());
         }
@@ -156,13 +157,14 @@
      * Reset the global static instance of the conditions manager to a new object.
      */
     public static synchronized void resetInstance() {
-        LOGGER.finest("DatabaseConditionsManager instance is being reset");
-        
+                        
         // Create a new instance if necessary, which will install it globally as the default.
         DatabaseConditionsManager dbManager = new DatabaseConditionsManager();
 
         // Register default conditions manager.
         ConditionsManager.setDefaultConditionsManager(dbManager);
+        
+        LOGGER.info("DatabaseConditionsManager instance is reset");
     }
 
     /**
@@ -286,15 +288,12 @@
     protected DatabaseConditionsManager() {
         
         // Register detector conditions converter.
-        LOGGER.config("registering detector converter");
         this.registerConditionsConverter(new DetectorConditionsConverter());
         
         // Setup connection from system property pointing to a file, if it was set.
-        LOGGER.config("checking for file connection system property");
         this.setupConnectionSystemPropertyFile();
         
         // Setup connection from system property pointing to a resource, if it was set.
-        LOGGER.config("checking for resource connection system property");
         this.setupConnectionSystemPropertyResource();
                 
         // Set run to invalid number.
@@ -302,12 +301,10 @@
         
         // Register conditions converters.
         for (final AbstractConditionsObjectConverter converter : this.converters.values()) {
-            LOGGER.config("registering converter for " + converter.getType());
             this.registerConditionsConverter(converter);
         }
         
         // Add the SVT detector setup object as a listener.
-        LOGGER.config("adding SVT setup");
         this.addConditionsListener(this.svtSetup);
     }
 
@@ -595,13 +592,22 @@
     public SvtConditions getSvtConditions() {
         return this.getCachedConditions(SvtConditions.class, "svt_conditions").getCachedData();
     }
+    
+    /**
+     * Get the currently active conditions tags.
+     * 
+     * @return the currently active conditions tags
+     */
+    public Collection<String> getActiveTags() {
+        return Collections.unmodifiableCollection(this.tags);
+    }
 
     /**
      * Get the set of available conditions tags from the conditions table
      *
      * @return the set of available conditions tags
      */
-    public Set<String> getTags() {
+    public Set<String> getAvailableTags() {
         LOGGER.fine("getting list of available conditions tags");
         final boolean openedConnection = this.openConnection();
         final Set<String> tags = new LinkedHashSet<String>();
@@ -655,10 +661,15 @@
                 
         // Clear the conditions cache.
         this.clearCache();
+                
+        // Set flag if run number is from Test Run 2012 data.
+        if (isTestRun(runNumber)) {
+            this.isTestRun = true;
+        }
 
         // Is not configured yet?
         if (!this.isConfigured) {
-            if (isTestRun(runNumber)) {
+            if (isTestRun()) {
                 // This looks like the Test Run so use the custom configuration for it.
                 this.setXmlConfig(DatabaseConditionsManager.TEST_RUN_CONFIG);
             } else if (runNumber > TEST_RUN_MAX_RUN) {
@@ -671,11 +682,10 @@
         }
 
         // Register the converters for this initialization.
-        LOGGER.fine("registering converters");
         this.registerConverters();
 
         // Enable or disable the setup of the SVT detector.
-        LOGGER.fine("enabling SVT setup: " + this.setupSvtDetector);
+        LOGGER.fine("SVT setup enabled: " + this.setupSvtDetector);
         this.svtSetup.setEnabled(this.setupSvtDetector);
 
         // Open the database connection.
@@ -691,7 +701,7 @@
         // Should all conditions sets be cached?
         if (this.cacheAllConditions) {
             // Cache the conditions sets of all registered converters.
-            LOGGER.fine("caching all conditions sets ...");
+            LOGGER.fine("caching conditions sets");
             this.cacheConditionsSets();
         }
 
@@ -774,11 +784,13 @@
         element = node.getChild("ecalName");
         if (element != null) {
             this.setEcalName(element.getText());
+            LOGGER.config("ecalName = " + this.getEcalName());
         }
 
         element = node.getChild("svtName");
         if (element != null) {
             this.setSvtName(element.getText());
+            LOGGER.config("svtName = " + this.svtName);
         }
 
         element = node.getChild("freezeAfterInitialize");
@@ -1054,9 +1066,13 @@
     public void addTag(final String tag) {
         if (!this.tags.contains(tag)) {
             LOGGER.info("adding tag " + tag);
-            ConditionsTagCollection addConditionsTagCollection = this.getCachedConditions(ConditionsTagCollection.class, tag).getCachedData();
+            ConditionsTagCollection findConditionsTag = this.getCachedConditions(ConditionsTagCollection.class, tag).getCachedData();
+            if (findConditionsTag.size() == 0) {
+                throw new IllegalArgumentException("The tag " + tag + " does not exist in the database.");
+            }
             LOGGER.info("adding conditions tag " + tag + " with " + conditionsTagCollection.size() + " records");
-            this.conditionsTagCollection.addAll(addConditionsTagCollection);                    
+            this.conditionsTagCollection.addAll(findConditionsTag);
+            this.tags.add(tag);
         } else {
             LOGGER.warning("tag " + tag + " is already added");
         }

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

November 2017
August 2017
July 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013

ATOM RSS1 RSS2



LISTSERV.SLAC.STANFORD.EDU

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager

Privacy Notice, Security Notice and Terms of Use