You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by fh...@apache.org on 2009/04/23 18:40:28 UTC
svn commit: r767969 - in
/tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test:
CheckOutThreadTest.java FairnessTest.java
Author: fhanik
Date: Thu Apr 23 16:40:28 2009
New Revision: 767969
URL: http://svn.apache.org/viewvc?rev=767969&view=rev
Log:
Add c3p0 as a comparison in the fairness test
Modified:
tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/CheckOutThreadTest.java
tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/FairnessTest.java
Modified: tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/CheckOutThreadTest.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/CheckOutThreadTest.java?rev=767969&r1=767968&r2=767969&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/CheckOutThreadTest.java (original)
+++ tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/CheckOutThreadTest.java Thu Apr 23 16:40:28 2009
@@ -118,6 +118,7 @@
public void testPoolThreads20Connections10() throws Exception {
init();
this.datasource.getPoolProperties().setMaxActive(10);
+ this.datasource.getPoolProperties().setFairQueue(false);
this.threadcount = 20;
this.transferProperties();
this.datasource.getConnection().close();
Modified: tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/FairnessTest.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/FairnessTest.java?rev=767969&r1=767968&r2=767969&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/FairnessTest.java (original)
+++ tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/FairnessTest.java Thu Apr 23 16:40:28 2009
@@ -25,7 +25,6 @@
import javax.sql.DataSource;
-import org.apache.tomcat.jdbc.pool.DataSourceFactory;
import org.apache.tomcat.jdbc.pool.DataSourceProxy;
/**
@@ -106,7 +105,7 @@
for (int i=0; i<threadcount; i++) {
threads[i] = new TestThread();
threads[i].setName("tomcat-pool-"+i);
- threads[i].d = DataSourceFactory.getDataSource(this.datasource);
+ threads[i].d = this.datasource;
}
for (int i=0; i<threadcount; i++) {
@@ -136,7 +135,7 @@
for (int i=0; i<threadcount; i++) {
threads[i] = new TestThread();
threads[i].setName("tomcat-pool-"+i);
- threads[i].d = DataSourceFactory.getDataSource(this.datasource);
+ threads[i].d = this.datasource;
}
for (int i=0; i<threadcount; i++) {
@@ -166,7 +165,7 @@
threads[i] = new TestThread();
threads[i].setName("tomcat-pool-"+i);
threads[i].async = true;
- threads[i].d = DataSourceFactory.getDataSource(this.datasource);
+ threads[i].d = this.datasource;
}
for (int i=0; i<threadcount; i++) {
@@ -181,6 +180,37 @@
tearDown();
}
+ public void testC3P0Threads20Connections10() throws Exception {
+ System.out.println("[testC3P0Threads20Connections10] Starting fairness - C3P0");
+ init();
+ this.datasource.getPoolProperties().setMaxActive(10);
+ this.datasource.getPoolProperties().setFairQueue(false);
+ this.threadcount = 20;
+ this.transferPropertiesToC3P0();
+ this.datasource.getConnection().close();
+ latch = new CountDownLatch(threadcount);
+ long start = System.currentTimeMillis();
+ TestThread[] threads = new TestThread[threadcount];
+ for (int i=0; i<threadcount; i++) {
+ threads[i] = new TestThread();
+ threads[i].setName("tomcat-pool-"+i);
+ threads[i].d = this.c3p0Datasource;
+
+ }
+ for (int i=0; i<threadcount; i++) {
+ threads[i].start();
+ }
+ if (!latch.await(complete+1000,TimeUnit.MILLISECONDS)) {
+ System.out.println("Latch timed out.");
+ }
+ this.run = false;
+ long delta = System.currentTimeMillis() - start;
+ printThreadResults(threads,"testC3P0Threads20Connections10");
+ tearDown();
+
+ }
+
+
public class TestThread extends Thread {
protected DataSource d;
protected String query = null;
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org