ASF Bugzilla – Attachment 33387 Details for
Bug 58786
JDBC Sampler : Replace Excalibur DataSource by more up to date library commons-dbcp2
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Implementation of Bug
BUG_58786.patch (text/plain), 29.37 KB, created by
Philippe Mouawad
on 2015-12-30 18:46:30 UTC
(
hide
)
Description:
Implementation of Bug
Filename:
MIME Type:
Creator:
Philippe Mouawad
Created:
2015-12-30 18:46:30 UTC
Size:
29.37 KB
patch
obsolete
>Index: build.properties >=================================================================== >--- build.properties (revision 1721032) >+++ build.properties (working copy) >@@ -139,38 +139,11 @@ > dnsjava.loc = ${maven2.repo}/dnsjava/dnsjava/${dnsjava.version} > dnsjava.md5 = 11363bd58696feae207a992da2ce7a90 > >-excalibur-instrument.version = 1.0 >-excalibur-instrument.jar = excalibur-instrument-${excalibur-instrument.version}.jar >-excalibur-instrument.loc = ${maven2.repo}/excalibur-instrument/excalibur-instrument/${excalibur-instrument.version} >-excalibur-instrument.md5 = 81BF95737C97A46836EA5F21F7C82719 >- > excalibur-logger.version = 1.1 > excalibur-logger.jar = excalibur-logger-${excalibur-logger.version}.jar > excalibur-logger.loc = ${maven2.repo}/excalibur-logger/excalibur-logger/${excalibur-logger.version} > excalibur-logger.md5 = E8246C546B7B0CAFD65947E9B80BB884 > >-excalibur-datasource.version = 2.1 >-excalibur-datasource.jar = excalibur-datasource-${excalibur-datasource.version}.jar >-excalibur-datasource.loc = ${maven2.repo}/excalibur-datasource/excalibur-datasource/${excalibur-datasource.version} >-excalibur-datasource.md5 = 7a57ccdfeda3a4f157016f5a9270a4f9 >- >-# pool has been split into 3 parts >-excalibur-pool.version = 2.1 >-excalibur-pool-api.version = ${excalibur-pool.version} >-excalibur-pool-api.jar = excalibur-pool-api-${excalibur-pool-api.version}.jar >-excalibur-pool-api.loc = ${maven2.repo}/excalibur-pool/excalibur-pool-api/${excalibur-pool-api.version} >-excalibur-pool-api.md5 = f9a224e1ee0896764aadbf7ddd253acc >- >-excalibur-pool-impl.version = ${excalibur-pool.version} >-excalibur-pool-impl.jar = excalibur-pool-impl-${excalibur-pool-impl.version}.jar >-excalibur-pool-impl.loc = ${maven2.repo}/excalibur-pool/excalibur-pool-impl/${excalibur-pool-impl.version} >-excalibur-pool-impl.md5 = 8be9c177894998090b4662326d7f22de >- >-excalibur-pool-instrumented.version = ${excalibur-pool.version} >-excalibur-pool-instrumented.jar = excalibur-pool-instrumented-${excalibur-pool-instrumented.version}.jar >-excalibur-pool-instrumented.loc = ${maven2.repo}/excalibur-pool/excalibur-pool-instrumented/${excalibur-pool-instrumented.version} >-excalibur-pool-instrumented.md5 = 1b5425fe0fe63dc67da6fe995db6be31 >- > # Freemarker > freemarker.version = 2.3.23 > freemarker.loc = ${maven2.repo}/org/freemarker/freemarker/${freemarker.version} >@@ -312,6 +285,16 @@ > tika-parsers.loc = ${maven2.repo}/org/apache/tika/tika-parsers/${tika-parsers.version} > tika-parsers.md5 = 8008cfa48ebc5caa350af235c05e9b67 > >+tomcat-juli.version = 8.0.30 >+tomcat-juli.jar = tomcat-juli-${tomcat-juli.version}.jar >+tomcat-juli.loc = ${maven2.repo}/org/apache/tomcat/tomcat-juli/${tomcat-juli.version} >+tomcat-juli.md5 = d872df1032dc3a7bb9e0fe39b2db3a7d >+ >+tomcat-jdbc.version = 8.0.30 >+tomcat-jdbc.jar = tomcat-jdbc-${tomcat-jdbc.version}.jar >+tomcat-jdbc.loc = ${maven2.repo}//org/apache/tomcat/tomcat-jdbc/${tomcat-jdbc.version} >+tomcat-jdbc.md5 = 3f440d76d14263eae15cfe394d792cec >+ > # XStream can be found at: http://x-stream.github.io > xstream.version = 1.4.8 > xstream.jar = xstream-${xstream.version}.jar >Index: build.xml >=================================================================== >--- build.xml (revision 1719635) >+++ build.xml (working copy) >@@ -375,12 +375,7 @@ > <include name="${lib.dir}/${commons-net.jar}"/> > <include name="${lib.dir}/${commons-pool2.jar}"/> > <include name="${lib.dir}/${dnsjava.jar}"/> >- <include name="${lib.dir}/${excalibur-datasource.jar}"/> >- <include name="${lib.dir}/${excalibur-instrument.jar}"/> > <include name="${lib.dir}/${excalibur-logger.jar}"/> >- <include name="${lib.dir}/${excalibur-pool-api.jar}"/> >- <include name="${lib.dir}/${excalibur-pool-impl.jar}"/> >- <include name="${lib.dir}/${excalibur-pool-instrumented.jar}"/> > <include name="${lib.dir}/${freemarker.jar}"/> > <include name="${lib.dir}/${htmllexer.jar}"/> > <include name="${lib.dir}/${htmlparser.jar}"/> >@@ -411,6 +406,8 @@ > <include name="${lib.dir}/${jtidy.jar}"/> > <include name="${lib.dir}/${tika-core.jar}"/> > <include name="${lib.dir}/${tika-parsers.jar}"/> >+ <include name="${lib.dir}/${tomcat-juli.jar}"/> >+ <include name="${lib.dir}/${tomcat-jdbc.jar}"/> > <include name="${lib.dir}/${xalan.jar}"/> > <include name="${lib.dir}/${xerces.jar}"/> > <include name="${lib.dir}/${xml-apis.jar}"/> >@@ -452,12 +449,7 @@ > <pathelement location="${lib.dir}/${commons-net.jar}"/> > <pathelement location="${lib.dir}/${commons-pool2.jar}"/> > <pathelement location="${lib.dir}/${dnsjava.jar}"/> >- <pathelement location="${lib.dir}/${excalibur-datasource.jar}"/> >- <pathelement location="${lib.dir}/${excalibur-instrument.jar}"/> > <pathelement location="${lib.dir}/${excalibur-logger.jar}"/> >- <pathelement location="${lib.dir}/${excalibur-pool-api.jar}"/> >- <pathelement location="${lib.dir}/${excalibur-pool-impl.jar}"/> >- <pathelement location="${lib.dir}/${excalibur-pool-instrumented.jar}"/> > <pathelement location="${lib.dir}/${freemarker.jar}"/> > <pathelement location="${lib.dir}/${htmllexer.jar}"/> > <pathelement location="${lib.dir}/${htmlparser.jar}"/> >@@ -488,7 +480,9 @@ > <pathelement location="${lib.dir}/${jtidy.jar}"/> > <pathelement location="${lib.dir}/${tika-core.jar}"/> > <pathelement location="${lib.dir}/${tika-parsers.jar}"/> >- <pathelement location="${lib.dir}/${xalan.jar}"/> >+ <pathelement location="${lib.dir}/${tomcat-juli.jar}"/> >+ <pathelement location="${lib.dir}/${tomcat-jdbc.jar}"/> >+ <pathelement location="${lib.dir}/${xalan.jar}"/> > <pathelement location="${lib.dir}/${xerces.jar}"/> > <pathelement location="${lib.dir}/${xml-apis.jar}"/> > <pathelement location="${lib.dir}/${xmlgraphics-commons.jar}"/> >@@ -2853,12 +2847,7 @@ > <process_jarfile jarname="commons-net"/> > <process_jarfile jarname="commons-pool2"/> > <process_jarfile jarname="dnsjava"/> >- <process_jarfile jarname="excalibur-datasource"/> >- <process_jarfile jarname="excalibur-instrument"/> > <process_jarfile jarname="excalibur-logger"/> >- <process_jarfile jarname="excalibur-pool-api"/> >- <process_jarfile jarname="excalibur-pool-impl"/> >- <process_jarfile jarname="excalibur-pool-instrumented"/> > <process_jarfile jarname="freemarker"/> > <process_jarfile jarname="htmllexer"/> > <process_jarfile jarname="htmlparser"/> >@@ -2889,6 +2878,8 @@ > <process_jarfile jarname="jtidy"/> > <process_jarfile jarname="tika-core"/> > <process_jarfile jarname="tika-parsers"/> >+ <process_jarfile jarname="tomcat-juli"/> >+ <process_jarfile jarname="tomcat-jdbc"/> > <process_jarfile jarname="velocity" dest.dir="${lib.doc}"/> > <process_jarfile jarname="commons-lang" dest.dir="${lib.doc}"/> > <process_jarfile jarname="xalan"/> >@@ -2925,7 +2916,6 @@ > <delete verbose="true"> > <fileset dir="${lib.api}" includes="bcmail-jdk15-*.jar bcprov-jdk15-*.jar"/> > <!-- tidy up old pool jar --> >- <fileset dir="${lib.dir}" includes="excalibur-pool-1.2.jar"/> > </delete> > <antcall target="_process_all_jars"> > <param name="_get_file" value="true"/> >Index: eclipse.classpath >=================================================================== >--- eclipse.classpath (revision 1721032) >+++ eclipse.classpath (working copy) >@@ -58,12 +58,7 @@ > <classpathentry kind="lib" path="lib/commons-net-3.4.jar"/> > <classpathentry kind="lib" path="lib/commons-pool2-2.4.2.jar"/> > <classpathentry kind="lib" path="lib/dnsjava-2.1.7.jar"/> >- <classpathentry kind="lib" path="lib/excalibur-datasource-2.1.jar"/> >- <classpathentry kind="lib" path="lib/excalibur-instrument-1.0.jar"/> > <classpathentry kind="lib" path="lib/excalibur-logger-1.1.jar"/> >- <classpathentry kind="lib" path="lib/excalibur-pool-api-2.1.jar"/> >- <classpathentry kind="lib" path="lib/excalibur-pool-impl-2.1.jar"/> >- <classpathentry kind="lib" path="lib/excalibur-pool-instrumented-2.1.jar"/> > <classpathentry kind="lib" path="lib/freemarker-2.3.23.jar"/> > <classpathentry kind="lib" path="lib/geronimo-jms_1.1_spec-1.1.1.jar"/> > <classpathentry kind="lib" path="lib/htmllexer-2.1.jar"/> >Index: lib/aareadme.txt >=================================================================== >--- lib/aareadme.txt (revision 1720926) >+++ lib/aareadme.txt (working copy) >@@ -91,22 +91,10 @@ > http://www.dnsjava.org/download/ > - DNSCacheManager > >-excalibur-datasource-1.1.1 (org.apache.avalon.excalibur.datasource) >--------------------------- >-- DataSourceElement (JDBC) >- >-excalibur-instrument-1.0 (org.apache.excalibur.instrument) >------------------------- >-- used by excalibur-datasource >- > excalibur-logger-1.1 (org.apache.avalon.excalibur.logger) > -------------------- > - LoggingManager > >-excalibur-pool-1.2 (org.apache.avalon.excalibur.pool) >------------------- >-- used by excalibur-datasource >- > freemarker-2.3.23.jar > ---------------------- > - used by Report/Dashboard feature >@@ -227,6 +215,14 @@ > http://tika.apache.org/ > - Regular Expression Extractor > >+tomcat-juli-8.0.30 (org.apache.juli) >+-------------------------- >+- used by tomcat-jdbc >+ >+tomcat-jdbc-8.0.30 (org.apache.tomcat.jdbc) >+-------------------------- >+- DataSourceElement (JDBC) >+ > velocity-1.7 > -------------- > http://velocity.apache.org/download.cgi >Index: licenses/bin/README.txt >=================================================================== >--- licenses/bin/README.txt (revision 1721032) >+++ licenses/bin/README.txt (working copy) >@@ -16,12 +16,7 @@ > commons-math3-3.5.jar > commons-net-3.4.jar > commons-pool2-2.4.2.jar >-excalibur-datasource-2.1.jar >-excalibur-instrument-1.0.jar > excalibur-logger-1.1.jar >-excalibur-pool-api-2.1.jar >-excalibur-pool-impl-2.1.jar >-excalibur-pool-instrumented-2.1.jar > geronimo-jms_1.1_spec-1.1.1.jar > httpclient-4.5.1.jar > httpcore-4.4.4.jar >@@ -33,6 +28,8 @@ > soap-2.3.1.jar > tika-core-1.11.jar > tika-parsers-1.11.jar >+tomcat-juli-8.0.30.jar >+tomcat-jdbc-8.0.30.jar > xalan-2.7.2.jar > xercesImpl-2.11.0.jar > xml-apis-1.4.01.jar >Index: res/maven/ApacheJMeter_parent.pom >=================================================================== >--- res/maven/ApacheJMeter_parent.pom (revision 1721032) >+++ res/maven/ApacheJMeter_parent.pom (working copy) >@@ -70,13 +70,7 @@ > <commons-net.version>3.4</commons-net.version> > <commons-pool2.version>2.4.2</commons-pool2.version> > <dnsjava.version>2.1.7</dnsjava.version> >- <excalibur-datasource.version>2.1</excalibur-datasource.version> >- <excalibur-instrument.version>1.0</excalibur-instrument.version> > <excalibur-logger.version>1.1</excalibur-logger.version> >- <excalibur-pool.version>2.1</excalibur-pool.version> >- <excalibur-pool-api.version>${excalibur-pool.version}</excalibur-pool-api.version> >- <excalibur-pool-impl.version>${excalibur-pool.version}</excalibur-pool-impl.version> >- <excalibur-pool-instrumented.version>${excalibur-pool.version}</excalibur-pool-instrumented.version> > <freemarker.version>2.3.23</freemarker.version> > <htmlparser.version>2.1</htmlparser.version> > <httpclient.version>4.5.1</httpclient.version> >@@ -102,6 +96,8 @@ > <jtidy.version>r938</jtidy.version> > <tika-core.version>1.11</tika-core.version> > <tika-parsers.version>1.11</tika-parsers.version> >+ <tomcat-juli.version>8.0.30</tomcat-juli.version> >+ <tomcat-jdbc.version>8.0.30</tomcat-jdbc.version> > <xstream.version>1.4.8</xstream.version> > <xalan.version>2.7.2</xalan.version> > <serializer.version>2.7.2</serializer.version> >@@ -205,46 +201,11 @@ > <version>${dnsjava.version}</version> > </dependency> > <dependency> >- <groupId>excalibur-datasource</groupId> >- <artifactId>excalibur-datasource</artifactId> >- <version>${excalibur-datasource.version}</version> >- <exclusions> >- <exclusion> >- <groupId>excalibur-fortress</groupId> >- <artifactId>excalibur-fortress-container-api</artifactId> >- </exclusion> >- <exclusion> >- <groupId>excalibur-fortress</groupId> >- <artifactId>excalibur-fortress-meta</artifactId> >- </exclusion> >- </exclusions> >- </dependency> >- <dependency> >- <groupId>excalibur-instrument</groupId> >- <artifactId>excalibur-instrument</artifactId> >- <version>${excalibur-instrument.version}</version> >- </dependency> >- <dependency> > <groupId>excalibur-logger</groupId> > <artifactId>excalibur-logger</artifactId> > <version>${excalibur-logger.version}</version> > </dependency> > <dependency> >- <groupId>excalibur-pool</groupId> >- <artifactId>excalibur-pool-api</artifactId> >- <version>${excalibur-pool-api.version}</version> >- </dependency> >- <dependency> >- <groupId>excalibur-pool</groupId> >- <artifactId>excalibur-pool-impl</artifactId> >- <version>${excalibur-pool-impl.version}</version> >- </dependency> >- <dependency> >- <groupId>excalibur-pool</groupId> >- <artifactId>excalibur-pool-instrumented</artifactId> >- <version>${excalibur-pool-instrumented.version}</version> >- </dependency> >- <dependency> > <groupId>org.htmlparser</groupId> > <artifactId>htmllexer</artifactId> > <version>${htmlparser.version}</version> >@@ -327,6 +288,16 @@ > <version>${tika-parsers.version}</version> > </dependency> > <dependency> >+ <groupId>org.apache.tomcat</groupId> >+ <artifactId>tomcat-juli</artifactId> >+ <version>${tomcat-juli.version}</version> >+ </dependency> >+ <dependency> >+ <groupId>org.apache.tomcat</groupId> >+ <artifactId>tomcat-jdbc</artifactId> >+ <version>${tomcat-jdbc.version}</version> >+ </dependency> >+ <dependency> > <groupId>com.thoughtworks.xstream</groupId> > <artifactId>xstream</artifactId> > <version>${xstream.version}</version> >Index: src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/config/DataSourceElement.java >=================================================================== >--- src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/config/DataSourceElement.java (revision 1721822) >+++ src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/config/DataSourceElement.java (working copy) >@@ -24,12 +24,6 @@ > import java.util.Map; > import java.util.Set; > >-import org.apache.avalon.excalibur.datasource.DataSourceComponent; >-import org.apache.avalon.excalibur.datasource.ResourceLimitingJdbcDataSource; >-import org.apache.avalon.framework.configuration.Configuration; >-import org.apache.avalon.framework.configuration.ConfigurationException; >-import org.apache.avalon.framework.configuration.DefaultConfiguration; >-import org.apache.avalon.framework.logger.LogKitLogger; > import org.apache.jmeter.config.ConfigElement; > import org.apache.jmeter.testbeans.TestBean; > import org.apache.jmeter.testbeans.TestBeanHelper; >@@ -40,28 +34,40 @@ > import org.apache.jorphan.logging.LoggingManager; > import org.apache.jorphan.util.JOrphanUtils; > import org.apache.log.Logger; >+import org.apache.tomcat.jdbc.pool.DataSource; >+import org.apache.tomcat.jdbc.pool.DataSourceProxy; >+import org.apache.tomcat.jdbc.pool.PoolProperties; > > public class DataSourceElement extends AbstractTestElement >- implements ConfigElement, TestStateListener, TestBean >- { >+ implements ConfigElement, TestStateListener, TestBean { > private static final Logger log = LoggingManager.getLoggerForClass(); > >- private static final long serialVersionUID = 233L; >+ private static final long serialVersionUID = 234L; > >- private transient String dataSource, driver, dbUrl, username, password, checkQuery, poolMax, connectionAge, timeout, >- trimInterval,transactionIsolation; >+ private transient String dataSource; >+ private transient String driver; >+ private transient String dbUrl; >+ private transient String username; >+ private transient String password; >+ private transient String checkQuery; >+ private transient String poolMax; >+ private transient String connectionAge; >+ private transient String timeout; >+ private transient String trimInterval; >+ private transient String transactionIsolation; > >- private transient boolean keepAlive, autocommit; >+ private transient boolean keepAlive; >+ private transient boolean autocommit; > > /* > * The datasource is set up by testStarted and cleared by testEnded. > * These are called from different threads, so access must be synchronized. > * The same instance is called in each case. > */ >- private transient ResourceLimitingJdbcDataSource excaliburSource; >+ private transient DataSource tomcatPoolDataSource; > > // Keep a record of the pre-thread pools so that they can be disposed of at the end of a test >- private transient Set<ResourceLimitingJdbcDataSource> perThreadPoolSet; >+ private transient Set<DataSource> perThreadPoolSet; > > public DataSourceElement() { > } >@@ -69,15 +75,15 @@ > @Override > public void testEnded() { > synchronized (this) { >- if (excaliburSource != null) { >- excaliburSource.dispose(); >+ if (tomcatPoolDataSource != null) { >+ tomcatPoolDataSource.close(true); > } >- excaliburSource = null; >+ tomcatPoolDataSource = null; > } > if (perThreadPoolSet != null) {// in case >- for(ResourceLimitingJdbcDataSource dsc : perThreadPoolSet){ >- log.debug("Disposing pool: "+dsc.getInstrumentableName()+" @"+System.identityHashCode(dsc)); >- dsc.dispose(); >+ for(DataSource dsc : perThreadPoolSet){ >+ log.debug("Closing pool: "+dsc.getName()+" @"+System.identityHashCode(dsc)); >+ dsc.close(true); > } > perThreadPoolSet=null; > } >@@ -100,14 +106,14 @@ > log.error("JDBC data source already defined for: "+poolName); > } else { > String maxPool = getPoolMax(); >- perThreadPoolSet = Collections.synchronizedSet(new HashSet<ResourceLimitingJdbcDataSource>()); >+ perThreadPoolSet = Collections.synchronizedSet(new HashSet<DataSource>()); > if (maxPool.equals("0")){ // i.e. if we want per thread pooling > variables.putObject(poolName, new DataSourceComponentImpl()); // pool will be created later > } else { >- ResourceLimitingJdbcDataSource src=initPool(maxPool); >+ DataSource src=initPool(maxPool); > synchronized(this){ >- excaliburSource = src; >- variables.putObject(poolName, new DataSourceComponentImpl(excaliburSource)); >+ tomcatPoolDataSource = src; >+ variables.putObject(poolName, new DataSourceComponentImpl(tomcatPoolDataSource)); > } > } > } >@@ -122,7 +128,7 @@ > public Object clone() { > DataSourceElement el = (DataSourceElement) super.clone(); > synchronized (this) { >- el.excaliburSource = excaliburSource; >+ el.tomcatPoolDataSource = tomcatPoolDataSource; > el.perThreadPoolSet = perThreadPoolSet; > } > return el; >@@ -140,8 +146,8 @@ > if (poolObject == null) { > throw new SQLException("No pool found named: '" + poolName + "', ensure Variable Name matches Variable Name of JDBC Connection Configuration"); > } else { >- if(poolObject instanceof DataSourceComponent) { >- DataSourceComponent pool = (DataSourceComponent) poolObject; >+ if(poolObject instanceof DataSourceProxy) { >+ DataSourceProxy pool = (DataSourceProxy) poolObject; > return pool.getConnection(); > } else { > String errorMsg = "Found object stored under variable:'"+poolName >@@ -156,10 +162,8 @@ > * Set up the DataSource - maxPool is a parameter, so the same code can > * also be used for setting up the per-thread pools. > */ >- private ResourceLimitingJdbcDataSource initPool(String maxPool) { >- ResourceLimitingJdbcDataSource source = null; >- source = new ResourceLimitingJdbcDataSource(); >- DefaultConfiguration config = new DefaultConfiguration("rl-jdbc"); // $NON-NLS-1$ >+ private DataSource initPool(String maxPool) { >+ PoolProperties poolProperties = new PoolProperties(); > > if (log.isDebugEnabled()) { > StringBuilder sb = new StringBuilder(40); >@@ -173,17 +177,15 @@ > sb.append(isAutocommit()); > log.debug(sb.toString()); > } >- DefaultConfiguration poolController = new DefaultConfiguration("pool-controller"); // $NON-NLS-1$ >- poolController.setAttribute("max", maxPool); // $NON-NLS-1$ >- poolController.setAttribute("max-strict", "true"); // $NON-NLS-1$ $NON-NLS-2$ >- poolController.setAttribute("blocking", "true"); // $NON-NLS-1$ $NON-NLS-2$ >- poolController.setAttribute("timeout", getTimeout()); // $NON-NLS-1$ >- poolController.setAttribute("trim-interval", getTrimInterval()); // $NON-NLS-1$ >- config.addChild(poolController); >+ poolProperties.setJmxEnabled(true); >+ int poolSize = Integer.parseInt(maxPool); >+ poolProperties.setMinIdle(0); >+ poolProperties.setInitialSize(poolSize); >+ poolProperties.setMaxIdle(poolSize); >+ poolProperties.setMaxActive(poolSize); >+ poolProperties.setMaxWait(Integer.parseInt(getTimeout())); > >- DefaultConfiguration autoCommit = new DefaultConfiguration("auto-commit"); // $NON-NLS-1$ >- autoCommit.setValue(String.valueOf(isAutocommit())); >- config.addChild(autoCommit); >+ poolProperties.setDefaultAutoCommit(Boolean.valueOf(isAutocommit())); > > if (log.isDebugEnabled()) { > StringBuilder sb = new StringBuilder(40); >@@ -195,11 +197,22 @@ > sb.append(getCheckQuery()); > log.debug(sb.toString()); > } >- DefaultConfiguration cfgKeepAlive = new DefaultConfiguration("keep-alive"); // $NON-NLS-1$ >- cfgKeepAlive.setAttribute("disable", String.valueOf(!isKeepAlive())); // $NON-NLS-1$ >- cfgKeepAlive.setAttribute("age", getConnectionAge()); // $NON-NLS-1$ >- cfgKeepAlive.setValue(getCheckQuery()); >- poolController.addChild(cfgKeepAlive); >+ poolProperties.setTestOnBorrow(false); >+ poolProperties.setTestOnReturn(false); >+ poolProperties.setTestOnConnect(false); >+ >+ if(isKeepAlive()) { >+ poolProperties.setTestWhileIdle(true); >+ poolProperties.setValidationQuery(getCheckQuery()); >+ // Not sure it is equivalent >+ poolProperties.setMaxAge(Integer.parseInt(getConnectionAge())); >+ poolProperties.setTimeBetweenEvictionRunsMillis(Integer.parseInt(getTrimInterval())); >+ } >+ >+ int transactionIsolation = DataSourceElementBeanInfo.getTransactionIsolationMode(getTransactionIsolation()); >+ if (transactionIsolation >= 0) { >+ poolProperties.setDefaultTransactionIsolation(transactionIsolation); >+ } > > String _username = getUsername(); > if (log.isDebugEnabled()) { >@@ -212,38 +225,29 @@ > sb.append(_username); > log.debug(sb.toString()); > } >- DefaultConfiguration cfgDriver = new DefaultConfiguration("driver"); // $NON-NLS-1$ >- cfgDriver.setValue(getDriver()); >- config.addChild(cfgDriver); >- DefaultConfiguration cfgDbUrl = new DefaultConfiguration("dburl"); // $NON-NLS-1$ >- cfgDbUrl.setValue(getDbUrl()); >- config.addChild(cfgDbUrl); >+ poolProperties.setDriverClassName(getDriver()); >+ poolProperties.setUrl(getDbUrl()); > > if (_username.length() > 0){ >- DefaultConfiguration cfgUsername = new DefaultConfiguration("user"); // $NON-NLS-1$ >- cfgUsername.setValue(_username); >- config.addChild(cfgUsername); >- DefaultConfiguration cfgPassword = new DefaultConfiguration("password"); // $NON-NLS-1$ >- cfgPassword.setValue(getPassword()); >- config.addChild(cfgPassword); >+ poolProperties.setUsername(_username); >+ poolProperties.setPassword(getPassword()); > } > > // log is required to ensure errors are available >- source.enableLogging(new LogKitLogger(log)); >- try { >- source.configure(config); >- source.setInstrumentableName(getDataSource()); >- } catch (ConfigurationException e) { >- log.error("Could not configure datasource for pool: "+getDataSource(),e); >+ //source.enableLogging(new LogKitLogger(log)); >+ DataSource dataSource = new DataSource(); >+ if(log.isDebugEnabled()) { >+ log.debug("PoolConfiguration:"+poolProperties); > } >- return source; >+ dataSource.setPoolProperties(poolProperties); >+ return dataSource; > } > > // used to hold per-thread singleton connection pools >- private static final ThreadLocal<Map<String, ResourceLimitingJdbcDataSource>> perThreadPoolMap = >- new ThreadLocal<Map<String, ResourceLimitingJdbcDataSource>>(){ >+ private static final ThreadLocal<Map<String, DataSource>> perThreadPoolMap = >+ new ThreadLocal<Map<String, DataSource>>(){ > @Override >- protected Map<String, ResourceLimitingJdbcDataSource> initialValue() { >+ protected Map<String, DataSource> initialValue() { > return new HashMap<>(); > } > }; >@@ -253,31 +257,31 @@ > * and per-thread pools. > * > */ >- private class DataSourceComponentImpl implements DataSourceComponent{ >+ private class DataSourceComponentImpl extends DataSourceProxy { > >- private final ResourceLimitingJdbcDataSource sharedDSC; >+ private final DataSource sharedDSC; > > DataSourceComponentImpl(){ > sharedDSC=null; > } > >- DataSourceComponentImpl(ResourceLimitingJdbcDataSource p_dsc){ >+ DataSourceComponentImpl(DataSource p_dsc){ > sharedDSC=p_dsc; > } > > @Override > public Connection getConnection() throws SQLException { > Connection conn = null; >- ResourceLimitingJdbcDataSource dsc = null; >+ DataSource dsc = null; > if (sharedDSC != null){ // i.e. shared pool > dsc = sharedDSC; > } else { >- Map<String, ResourceLimitingJdbcDataSource> poolMap = perThreadPoolMap.get(); >- dsc = poolMap.get(getDataSource()); >+ Map<String, DataSource> poolMap = perThreadPoolMap.get(); >+ dsc = poolMap.get(getDataSourceName()); > if (dsc == null){ > dsc = initPool("1"); >- poolMap.put(getDataSource(),dsc); >- log.debug("Storing pool: "+dsc.getInstrumentableName()+" @"+System.identityHashCode(dsc)); >+ poolMap.put(getDataSourceName(),dsc); >+ log.debug("Storing pool: "+dsc.getName()+" @"+System.identityHashCode(dsc)); > perThreadPoolSet.add(dsc); > } > } >@@ -298,11 +302,6 @@ > } > return conn; > } >- >- @Override >- public void configure(Configuration arg0) throws ConfigurationException { >- } >- > } > > @Override >@@ -358,6 +357,10 @@ > public void setDataSource(String dataSource) { > this.dataSource = dataSource; > } >+ >+ private String getDataSourceName() { >+ return getDataSource(); >+ } > > /** > * @return Returns the dbUrl. >Index: xdocs/usermanual/component_reference.xml >=================================================================== >--- xdocs/usermanual/component_reference.xml (revision 1722342) >+++ xdocs/usermanual/component_reference.xml (working copy) >@@ -4143,7 +4143,7 @@ > </property> > <property name="Pool timeout" required="Yes">Pool throws an error if the timeout period is exceeded in the > process of trying to retrieve a connection</property> >- <property name="Idle Cleanup Interval (ms)" required="Yes">This is used to specify how long idle connections will be maintained in the pool before being closed. For a complete explanation on how this works, see <a href="http://excalibur.apache.org/apidocs/org/apache/avalon/excalibur/pool/ResourceLimitingPool.html#trim%28%29">ResourceLimitingPool.trim()</a> (Defaults to "<code>60000</code>", 1 minute)</property> >+ <property name="Idle Cleanup Interval (ms)" required="Yes">This is used to specify how long idle connections will be maintained in the pool before being closed. (Defaults to "<code>60000</code>", 1 minute)</property> > <property name="Auto Commit" required="Yes">Turn auto commit on or off for the connections.</property> > <property name="Keep-alive" required="Yes">The keep-alive is used enable a mechanism to monitor the health of connections. If a connection has not been used for Max Connection Age (ms) then before returning the connection from a call to <code>getConnection()</code>, the connection is first used to ping the database to make sure that it is still alive. > Setting the age allows the 5 second age to be overridden. Validation Query will be used to test it.</property>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 58786
: 33387 |
33388
|
33389