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  December 2014

HPS-SVN December 2014

Subject:

r1791 - in /java/trunk/conditions/src/main: java/org/hps/conditions/database/DatabaseConditionsManager.java resources/org/hps/conditions/config/jlab_connection.prop resources/org/hps/conditions/config/slac_connection.prop

From:

[log in to unmask]

Reply-To:

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

Date:

Fri, 19 Dec 2014 21:43:06 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (127 lines)

Author: [log in to unmask]
Date: Fri Dec 19 13:43:01 2014
New Revision: 1791

Log:
Change over to using the centrall managed SLAC MySQL database.  Add and use default connection properties files for the read only accounts.

Added:
    java/trunk/conditions/src/main/resources/org/hps/conditions/config/jlab_connection.prop
    java/trunk/conditions/src/main/resources/org/hps/conditions/config/slac_connection.prop
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 Dec 19 13:43:01 2014
@@ -78,7 +78,8 @@
     protected List<TableMetaData> tableMetaData;
     protected List<ConditionsConverter> converters;
     protected File connectionPropertiesFile;
-    protected ConnectionParameters connectionParameters = new DefaultConnectionParameters();
+    protected ConnectionParameters connectionParameters;
+    //= new DefaultConnectionParameters();
     protected Connection connection;
     protected boolean isConnected = false;
     protected ConditionsSeriesConverter conditionsSeriesConverter = new ConditionsSeriesConverter(this);
@@ -92,42 +93,7 @@
     protected TestRunSvtDetectorSetup testRunSvtloader = new TestRunSvtDetectorSetup();
     protected SvtDetectorSetup svtLoader = new SvtDetectorSetup();
     protected String tag = null;
-    //protected boolean dryRun = false;
-    
-    /**
-     * Default connection parameters which will use the SLAC database by default,
-     * as it is publicly accessible.  If running on the JLAB network, the jmysql
-     * URL will be used instead, as the host computer is most likely on the 
-     * batch farm, in the counting house, etc.
-     */
-    static class DefaultConnectionParameters extends ConnectionParameters {
-        DefaultConnectionParameters() {
-            
-            // This is the default port for MySQL connections.
-            this.port = 3306;
-            
-            // By default, connect to the publicly accessible SLAC database.
-            this.hostname = "ppa-jeremym-l.slac.stanford.edu";
-            this.database = "hps_conditions";
-            
-            try {
-                // Are we running inside the JLAB network?
-                if (InetAddress.getLocalHost().getCanonicalHostName().contains("jlab.org")) {
-                    // Use the JLAB database.
-                    this.hostname = "jmysql.jlab.org";                                      
-                    logger.config("found JLAB hostname " + InetAddress.getLocalHost().getCanonicalHostName());
-                } 
-            } catch (UnknownHostException e) {
-                // Something wrong with the user's host name, but try to continue anyways.
-                logger.log(Level.WARNING, e.getMessage(), e);
-            }
-            
-            // This user name and password are setup for read-only access on both databases.
-            this.user = "hpsuser";
-            this.password = "darkphoton";
-        }
-    }
-
+        
     /**
      * Class constructor.
      */
@@ -171,8 +137,10 @@
      * Open the database connection.
      */
     public void openConnection() {
+        // Do the connection parameters need to be figured out automatically?
         if (connectionParameters == null) {
-            throw new RuntimeException("The connection parameters are null.");
+            // Setup the default read-only connection, which will choose a SLAC or JLab database.
+            connectionParameters = ConnectionParameters.fromResource(chooseConnectionPropertiesResource());
         }
         logger.config("opening connection to " + connectionParameters.getConnectionString());
         logger.config("host " + connectionParameters.getHostname());
@@ -730,6 +698,22 @@
     
     public Logger getLogger() {
         return logger;
+    }
+        
+    private String chooseConnectionPropertiesResource() {
+        String connectionName = "slac";
+        try {
+            // Are we running inside the JLAB network?
+            if (InetAddress.getLocalHost().getCanonicalHostName().contains("jlab.org")) {
+                connectionName = "jlab";
+                logger.config("found JLAB hostname " + InetAddress.getLocalHost().getCanonicalHostName());
+            } 
+        } catch (UnknownHostException e) {
+            // Something wrong with the user's host name, but we will try to continue anyways.
+            logger.log(Level.WARNING, e.getMessage(), e);
+        }
+        logger.config("connection " + connectionName + " will be used");
+        return "/org/hps/conditions/config/" + connectionName + "_connection.prop";
     }
 
     /**

Added: java/trunk/conditions/src/main/resources/org/hps/conditions/config/jlab_connection.prop
 =============================================================================
--- java/trunk/conditions/src/main/resources/org/hps/conditions/config/jlab_connection.prop	(added)
+++ java/trunk/conditions/src/main/resources/org/hps/conditions/config/jlab_connection.prop	Fri Dec 19 13:43:01 2014
@@ -0,0 +1,4 @@
+hostname = jmysql.jlab.org
+user = hpsuser
+password = darkphoton
+database = hps_conditions

Added: java/trunk/conditions/src/main/resources/org/hps/conditions/config/slac_connection.prop
 =============================================================================
--- java/trunk/conditions/src/main/resources/org/hps/conditions/config/slac_connection.prop	(added)
+++ java/trunk/conditions/src/main/resources/org/hps/conditions/config/slac_connection.prop	Fri Dec 19 13:43:01 2014
@@ -0,0 +1,4 @@
+hostname = mysql-node03.slac.stanford.edu
+user = rd_hps_cond_ro
+password = 2jumpinphotons.
+database = rd_hps_cond

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