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 2016

HPS-SVN December 2016

Subject:

r4625 - in /java/trunk: conditions/src/main/java/org/hps/conditions/database/ logging/src/main/resources/org/hps/logging/config/ run-database/src/main/java/org/hps/rundb/

From:

[log in to unmask]

Reply-To:

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

Date:

Mon, 12 Dec 2016 20:11:12 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (179 lines)

Author: [log in to unmask]
Date: Mon Dec 12 12:11:07 2016
New Revision: 4625

Log:
[HPSJAVA-665] Read URL from prop file for run db.

Modified:
    java/trunk/conditions/src/main/java/org/hps/conditions/database/ConnectionParameters.java
    java/trunk/conditions/src/main/java/org/hps/conditions/database/DatabaseConditionsManager.java
    java/trunk/logging/src/main/resources/org/hps/logging/config/test_logging.properties
    java/trunk/run-database/src/main/java/org/hps/rundb/RunManager.java

Modified: java/trunk/conditions/src/main/java/org/hps/conditions/database/ConnectionParameters.java
 =============================================================================
--- java/trunk/conditions/src/main/java/org/hps/conditions/database/ConnectionParameters.java	(original)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/database/ConnectionParameters.java	Mon Dec 12 12:11:07 2016
@@ -20,6 +20,16 @@
  */
 public final class ConnectionParameters {
 
+    /**
+     * Name of system property that can be used to specify custom database connection parameters.
+     */
+    public static final String CONNECTION_PROPERTY_FILE = "org.hps.conditions.connection.file";
+    
+    /**
+     * Connection property resource.
+     */
+    public static final String CONNECTION_PROPERTY_RESOURCE = "org.hps.conditions.connection.resource";
+    
     /**
      * The default port number.
      */
@@ -266,4 +276,17 @@
         return "ConnectionParameters { database: " + database + ", hostname: " + hostname + ", password: " + password
                 + ", port: " + port + ", user: " + user + " }";
     }
+    
+    public void setDatabase(String database) {
+        this.database = database;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    public void setUser(String user) {
+        this.user = user;
+    }
+
 }

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	Mon Dec 12 12:11:07 2016
@@ -43,6 +43,8 @@
 import org.lcsim.geometry.Detector;
 import org.lcsim.geometry.Subdetector;
 import org.lcsim.util.loop.DetectorConditionsConverter;
+import static org.hps.conditions.database.ConnectionParameters.CONNECTION_PROPERTY_FILE;
+import static org.hps.conditions.database.ConnectionParameters.CONNECTION_PROPERTY_RESOURCE;
 
 /**
  * <p>
@@ -57,17 +59,7 @@
  */
 @SuppressWarnings("rawtypes")
 public final class DatabaseConditionsManager extends ConditionsManagerImplementation {
-
-    /**
-     * Name of system property that can be used to specify custom database connection parameters.
-     */
-    private static final String CONNECTION_PROPERTY_FILE = "org.hps.conditions.connection.file";
-
-    /**
-     * Connection property resource.
-     */
-    private static final String CONNECTION_PROPERTY_RESOURCE = "org.hps.conditions.connection.resource";
-
+   
     /**
      * The default XML config.
      */

Modified: java/trunk/logging/src/main/resources/org/hps/logging/config/test_logging.properties
 =============================================================================
--- java/trunk/logging/src/main/resources/org/hps/logging/config/test_logging.properties	(original)
+++ java/trunk/logging/src/main/resources/org/hps/logging/config/test_logging.properties	Mon Dec 12 12:11:07 2016
@@ -27,7 +27,7 @@
 
 # conditions
 org.hps.conditions.api.level = WARNING
-org.hps.conditions.database.level = WARNING
+org.hps.conditions.database.level = INFO
 org.hps.conditions.cli.level = WARNING
 org.hps.conditions.ecal.level = WARNING
 org.hps.conditions.svt.level = WARNING
@@ -68,7 +68,7 @@
 org.hps.recon.tracking.gbl.level = WARNING
 
 # run-database
-org.hps.run.database.level = WARNING
+org.hps.rundb.level = WARNING
 
 # monitoring-application
 org.hps.monitoring.application.model.level = WARNING

Modified: java/trunk/run-database/src/main/java/org/hps/rundb/RunManager.java
 =============================================================================
--- java/trunk/run-database/src/main/java/org/hps/rundb/RunManager.java	(original)
+++ java/trunk/run-database/src/main/java/org/hps/rundb/RunManager.java	Mon Dec 12 12:11:07 2016
@@ -1,8 +1,10 @@
 package org.hps.rundb;
 
+import java.io.File;
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.util.List;
+import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import org.hps.conditions.database.ConnectionParameters;
@@ -22,10 +24,20 @@
 public final class RunManager implements ConditionsListener {
 
     /**
+     * Name of system property that can be used to specify custom database connection parameters.
+     */
+    private static final String CONNECTION_PROPERTY_FILE = "org.hps.conditions.connection.file";
+    
+    /**
      * The default connection parameters for read-only access to the run database.
      */
     private static ConnectionParameters DEFAULT_CONNECTION_PARAMETERS = new ConnectionParameters("hpsuser",
             "darkphoton", "hps_run_db_v2", "hpsdb.jlab.org");
+    
+    /**
+     * Database connection parameters.
+     */
+    private ConnectionParameters connectionParameters = DEFAULT_CONNECTION_PARAMETERS;
 
     /**
      * The singleton instance of the RunManager.
@@ -77,14 +89,30 @@
         }
         this.connection = connection;
         factory = new DaoProvider(this.connection);
+        LOGGER.log(Level.INFO, this.connectionParameters.toString());
     }
     
     /**
      * Class constructor using default connection parameters.
      */
     public RunManager() {
-        this(DEFAULT_CONNECTION_PARAMETERS.createConnection());
-    }
+        
+        /**
+         * Read database URL from system prop setting.
+         * The database, password and user from that file are overridden.
+         */
+        if (System.getProperties().get(CONNECTION_PROPERTY_FILE) != null) {
+            final String propFile = (String) System.getProperties().get(CONNECTION_PROPERTY_FILE);
+            this.connectionParameters = ConnectionParameters.fromProperties(new File(propFile));
+            this.connectionParameters.setDatabase("hps_run_db_v2");
+            this.connectionParameters.setPassword("darkphoton");
+            this.connectionParameters.setUser("hpsuser");
+            
+        }        
+        this.connection = this.connectionParameters.createConnection();
+        factory = new DaoProvider(this.connection);
+        LOGGER.log(Level.INFO, this.connectionParameters.toString());
+    }   
         
     /**
      * Close the database connection.

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