# HG changeset patch # User "Tom Gottfried " # Date 1417188880 -3600 # Node ID 026f4c684ee5251eab2f28a320c1fed887c15dd9 # Parent 8c615d738e84e8eae73c967afc873335b7afec1e Make maxWait configurable and wait for 30 seconds diff -r 8c615d738e84 -r 026f4c684ee5 artifacts/doc/conf/backend-db.xml --- a/artifacts/doc/conf/backend-db.xml Fri Nov 28 10:21:40 2014 +0100 +++ b/artifacts/doc/conf/backend-db.xml Fri Nov 28 16:34:40 2014 +0100 @@ -7,4 +7,5 @@ org.postgresql.Driver jdbc:postgresql://localhost:5432/d4e select 1 from rivers + 30000 diff -r 8c615d738e84 -r 026f4c684ee5 artifacts/doc/conf/seddb-db.xml --- a/artifacts/doc/conf/seddb-db.xml Fri Nov 28 10:21:40 2014 +0100 +++ b/artifacts/doc/conf/seddb-db.xml Fri Nov 28 16:34:40 2014 +0100 @@ -7,6 +7,7 @@ org.postgresql.Driver jdbc:postgresql://localhost:5432/seddb select 1 from gewaesser + 30000 diff -r 8c615d738e84 -r 026f4c684ee5 backend/src/main/java/org/dive4elements/river/backend/Credentials.java --- a/backend/src/main/java/org/dive4elements/river/backend/Credentials.java Fri Nov 28 10:21:40 2014 +0100 +++ b/backend/src/main/java/org/dive4elements/river/backend/Credentials.java Fri Nov 28 16:34:40 2014 +0100 @@ -17,6 +17,7 @@ protected String url; protected String connectionInitSqls; protected String validationQuery; + protected String maxWait; protected Class [] classes; public Credentials() { @@ -30,6 +31,7 @@ String url, String connectionInitSqls, String validationQuery, + String maxWait, Class [] classes ) { this.user = user; @@ -39,6 +41,7 @@ this.url = url; this.connectionInitSqls = connectionInitSqls; this.validationQuery = validationQuery; + this.maxWait = maxWait; this.classes = classes; } @@ -90,6 +93,14 @@ this.validationQuery = validationQuery; } + public String getMaxWait() { + return maxWait; + } + + public void setMaxWait(String maxWait) { + this.maxWait = maxWait; + } + public String getConnectionInitSqls() { return connectionInitSqls; } diff -r 8c615d738e84 -r 026f4c684ee5 backend/src/main/java/org/dive4elements/river/backend/FLYSCredentials.java --- a/backend/src/main/java/org/dive4elements/river/backend/FLYSCredentials.java Fri Nov 28 10:21:40 2014 +0100 +++ b/backend/src/main/java/org/dive4elements/river/backend/FLYSCredentials.java Fri Nov 28 16:34:40 2014 +0100 @@ -111,6 +111,9 @@ public static final String XPATH_VALIDATION_QUERY = "/artifact-database/backend-database/validation-query/text()"; + public static final String XPATH_MAX_WAIT = + "/artifact-database/backend-database/max-wait/text()"; + public static final String DEFAULT_USER = System.getProperty("flys.backend.user", "flys"); @@ -140,6 +143,9 @@ System.getProperty( "flys.backend.connection.validation.query"); + public static final String DEFAULT_MAX_WAIT = + System.getProperty("flys.backend.connection.max.wait"); + public static final Class [] CLASSES = { Annotation.class, AnnotationType.class, @@ -229,11 +235,12 @@ String driver, String url, String connectionInitSqls, - String validationQuery + String validationQuery, + String maxWait ) { super( user, password, dialect, driver, url, - connectionInitSqls, validationQuery, CLASSES); + connectionInitSqls, validationQuery, maxWait, CLASSES); } private static Credentials instance; @@ -258,9 +265,12 @@ Config.getStringXPath( XPATH_VALIDATION_QUERY, DEFAULT_VALIDATION_QUERY); + String maxWait = + Config.getStringXPath(XPATH_MAX_WAIT, DEFAULT_MAX_WAIT); instance = new FLYSCredentials( - user, password, dialect, driver, url, connectionInitSqls, validationQuery); + user, password, dialect, driver, url, connectionInitSqls, + validationQuery, maxWait); } return instance; } @@ -273,7 +283,9 @@ DEFAULT_DRIVER, DEFAULT_URL, DEFAULT_CONNECTION_INIT_SQLS, - DEFAULT_VALIDATION_QUERY); + DEFAULT_VALIDATION_QUERY, + DEFAULT_MAX_WAIT + ); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 8c615d738e84 -r 026f4c684ee5 backend/src/main/java/org/dive4elements/river/backend/SedDBCredentials.java --- a/backend/src/main/java/org/dive4elements/river/backend/SedDBCredentials.java Fri Nov 28 10:21:40 2014 +0100 +++ b/backend/src/main/java/org/dive4elements/river/backend/SedDBCredentials.java Fri Nov 28 16:34:40 2014 +0100 @@ -87,6 +87,9 @@ public static final String XPATH_VALIDATION_QUERY = "/artifact-database/seddb-database/validation-query/text()"; + public static final String XPATH_MAX_WAIT = + "/artifact-database/seddb-database/max-wait/text()"; + public static final String DEFAULT_USER = System.getProperty("flys.seddb.user", "seddb"); @@ -116,6 +119,9 @@ System.getProperty( "flys.seddb.connection.validation.query"); + public static final String DEFAULT_MAX_WAIT = + System.getProperty("flys.seddb.connection.max.wait"); + public static final Class [] CLASSES = { BezugspegelgewId.class, Bezugspegelgew.class, @@ -183,11 +189,12 @@ String driver, String url, String connectionInitSqls, - String validationQuery + String validationQuery, + String maxWait ) { super( user, password, dialect, driver, url, - connectionInitSqls, validationQuery, CLASSES); + connectionInitSqls, validationQuery, maxWait, CLASSES); } public static synchronized Credentials getInstance() { @@ -210,10 +217,12 @@ Config.getStringXPath( XPATH_VALIDATION_QUERY, DEFAULT_VALIDATION_QUERY); + String maxWait = + Config.getStringXPath(XPATH_MAX_WAIT, DEFAULT_MAX_WAIT); instance = new SedDBCredentials( user, password, dialect, driver, url, - connectionInitSqls, validationQuery); + connectionInitSqls, validationQuery, maxWait); } return instance; } @@ -226,7 +235,9 @@ DEFAULT_DRIVER, DEFAULT_URL, DEFAULT_CONNECTION_INIT_SQLS, - DEFAULT_VALIDATION_QUERY); + DEFAULT_VALIDATION_QUERY, + DEFAULT_MAX_WAIT + ); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 8c615d738e84 -r 026f4c684ee5 backend/src/main/java/org/dive4elements/river/backend/SessionFactoryProvider.java --- a/backend/src/main/java/org/dive4elements/river/backend/SessionFactoryProvider.java Fri Nov 28 10:21:40 2014 +0100 +++ b/backend/src/main/java/org/dive4elements/river/backend/SessionFactoryProvider.java Fri Nov 28 16:34:40 2014 +0100 @@ -148,6 +148,10 @@ if (validationQuery != null) { props.setProperty("validationQuery", validationQuery); } + String maxWait = credentials.getMaxWait(); + if (maxWait != null) { + props.setProperty("maxWait", maxWait); + } cfg.mergeProperties(props); diff -r 8c615d738e84 -r 026f4c684ee5 backend/src/main/java/org/dive4elements/river/backend/utils/DBCPConnectionProvider.java --- a/backend/src/main/java/org/dive4elements/river/backend/utils/DBCPConnectionProvider.java Fri Nov 28 10:21:40 2014 +0100 +++ b/backend/src/main/java/org/dive4elements/river/backend/utils/DBCPConnectionProvider.java Fri Nov 28 16:34:40 2014 +0100 @@ -217,7 +217,17 @@ ds.setValidationQuery(validationQuery); } - ds.setMaxWait(1000); //TODO: make it configurable + String maxWait = props.getProperty("maxWait"); + if (maxWait != null) { + try { + ds.setMaxWait(Integer.parseInt(maxWait)); + } + catch (NumberFormatException nfe) { + log.error( + "Property maxWait could not be parsed as integer." + ); + } + } // The BasicDataSource has lazy initialization // borrowing a connection will start the DataSource diff -r 8c615d738e84 -r 026f4c684ee5 contrib/make_flys_release/make_release.sh --- a/contrib/make_flys_release/make_release.sh Fri Nov 28 10:21:40 2014 +0100 +++ b/contrib/make_flys_release/make_release.sh Fri Nov 28 16:34:40 2014 +0100 @@ -383,6 +383,7 @@ oracle.jdbc.driver.OracleDriver jdbc:oracle:thin:@//$BACKENDURL:$BACKENDPORT/$BACKENDBACK select 1 from rivers + 30000 $INITSQLS EOF @@ -396,6 +397,7 @@ oracle.jdbc.driver.OracleDriver jdbc:oracle:thin:@//$SEDDBURL:$SEDDBPORT/$SEDDBBACK select 1 from gewaesser + 30000 $SEDINITSQLS EOF