Author: fhanik Date: Tue Apr 21 01:14:36 2009 New Revision: 766936 URL: http://svn.apache.org/viewvc?rev=766936&view=rev Log: not sure what went wrong, my SVN is going ape #!$
Added: tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/TestException.java Modified: 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/FairnessTest.java URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/FairnessTest.java?rev=766936&r1=766935&r2=766936&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 Tue Apr 21 01:14:36 2009 @@ -38,25 +38,34 @@ } protected boolean run = true; - protected long sleep = 10; - protected long complete = 20000; + protected long sleep = Long.getLong("sleep", 10); + protected long complete = Long.getLong("complete",20000); + protected boolean printthread = Boolean.getBoolean("printthread"); CountDownLatch latch = null; protected void printThreadResults(TestThread[] threads, String name) { long minfetch = Long.MAX_VALUE, maxfetch = Long.MIN_VALUE, totalfetch = 0; + long maxwait = 0, minwait = Long.MAX_VALUE, averagewait = 0, totalwait = 0; float avgfetch = 0; for (int i=0; i<threads.length; i++) { TestThread t = threads[i]; totalfetch += t.nroffetch; + totalwait += t.totalwait; + maxwait = Math.max(maxwait,t.maxwait); + minwait = Math.min(minwait, t.minwait); minfetch = Math.min(minfetch, t.nroffetch); maxfetch = Math.max(maxfetch, t.nroffetch); - System.out.println(t.getName()+" : Nr-of-fetch:"+t.nroffetch+ " Max fetch Time:"+(((float)t.max)/1000000f)+"ms. :Max close time:"+(((float)t.cmax)/1000000f)+"ms."); + if (FairnessTest.this.printthread) + System.out.println(t.getName()+" : Nr-of-fetch:"+t.nroffetch+ " Max fetch Time:"+(((float)t.maxwait)/1000000f)+"ms. :Max close time:"+(((float)t.cmax)/1000000f)+"ms."); } System.out.println("["+name+"] Max fetch:"+(maxfetch)+" Min fetch:"+(minfetch)+" Average fetch:"+ (((float)totalfetch))/(float)threads.length); + System.out.println("["+name+"] Max wait:"+(((float)maxwait)/1000000f)+"ms. Min wait:"+(((float)minwait)/1000000f)+"ms. Average wait:"+(((((float)totalwait))/(float)totalfetch)/1000000f)+" ms."); + + } public void testDBCPThreads20Connections10() throws Exception { - System.out.println("Starting fairness - DBCP"); + System.out.println("[testDBCPThreads20Connections10] Starting fairness - DBCP"); init(); this.datasource.getPoolProperties().setMaxActive(10); this.threadcount = 20; @@ -80,14 +89,14 @@ this.run = false; long delta = System.currentTimeMillis() - start; printThreadResults(threads,"testDBCPThreads20Connections10"); - System.out.println("Completed fairness - DBCP"); tearDown(); } public void testPoolThreads20Connections10() throws Exception { - System.out.println("Starting fairness - Tomcat JDBC - Non Fair"); + System.out.println("[testPoolThreads20Connections10] Starting fairness - Tomcat JDBC - Non Fair"); init(); this.datasource.getPoolProperties().setMaxActive(10); + this.datasource.getPoolProperties().setFairQueue(false); this.threadcount = 20; this.transferProperties(); this.datasource.getConnection().close(); @@ -109,13 +118,12 @@ this.run = false; long delta = System.currentTimeMillis() - start; printThreadResults(threads,"testPoolThreads20Connections10"); - System.out.println("Completed fairness - Tomcat JDBC - Non Fair"); tearDown(); } public void testPoolThreads20Connections10Fair() throws Exception { - System.out.println("Starting fairness - Tomcat JDBC - Fair"); + System.out.println("[testPoolThreads20Connections10Fair] Starting fairness - Tomcat JDBC - Fair"); init(); this.datasource.getPoolProperties().setMaxActive(10); this.datasource.getPoolProperties().setFairQueue(true); @@ -140,12 +148,11 @@ this.run = false; long delta = System.currentTimeMillis() - start; printThreadResults(threads,"testPoolThreads20Connections10Fair"); - System.out.println("Completed fairness - Tomcat JDBC - Fair"); tearDown(); } - + public void testPoolThreads20Connections10FairAsync() throws Exception { - System.out.println("Starting fairness - Tomcat JDBC - Fair - Async"); + System.out.println("[testPoolThreads20Connections10FairAsync] Starting fairness - Tomcat JDBC - Fair - Async"); init(); this.datasource.getPoolProperties().setMaxActive(10); this.datasource.getPoolProperties().setFairQueue(true); @@ -171,7 +178,6 @@ this.run = false; long delta = System.currentTimeMillis() - start; printThreadResults(threads,"testPoolThreads20Connections10FairAsync"); - System.out.println("Completed fairness - Tomcat JDBC - Fair - Async"); tearDown(); } @@ -180,7 +186,7 @@ protected String query = null; protected long sleep = 10; protected boolean async = false; - long max = -1, totalmax=0, totalcmax=0, cmax = -1, nroffetch = 0, totalruntime = 0; + long minwait = Long.MAX_VALUE, maxwait = -1, totalwait=0, totalcmax=0, cmax = -1, nroffetch = 0, totalruntime = 0; public void run() { try { long now = System.currentTimeMillis(); @@ -196,8 +202,9 @@ con = d.getConnection(); } long delta = System.nanoTime() - start; - totalmax += delta; - max = Math.max(delta, max); + totalwait += delta; + maxwait = Math.max(delta, maxwait); + minwait = Math.min(delta, minwait); nroffetch++; if (query!=null) { Statement st = con.createStatement(); @@ -208,7 +215,7 @@ st.close(); } try { - sleep(FairnessTest.this.sleep); + if (FairnessTest.this.sleep>0) sleep(FairnessTest.this.sleep); } catch (InterruptedException x) { interrupted(); } @@ -229,9 +236,9 @@ } if (System.getProperty("print-thread-stats")!=null) { System.out.println("["+getName()+"] "+ - "\n\tMax time to retrieve connection:"+(((float)max)/1000f/1000f)+" ms."+ - "\n\tTotal time to retrieve connection:"+(((float)totalmax)/1000f/1000f)+" ms."+ - "\n\tAverage time to retrieve connection:"+(((float)totalmax)/1000f/1000f)/(float)nroffetch+" ms."+ + "\n\tMax time to retrieve connection:"+(((float)maxwait)/1000f/1000f)+" ms."+ + "\n\tTotal time to retrieve connection:"+(((float)totalwait)/1000f/1000f)+" ms."+ + "\n\tAverage time to retrieve connection:"+(((float)totalwait)/1000f/1000f)/(float)nroffetch+" ms."+ "\n\tMax time to close connection:"+(((float)cmax)/1000f/1000f)+" ms."+ "\n\tTotal time to close connection:"+(((float)totalcmax)/1000f/1000f)+" ms."+ "\n\tAverage time to close connection:"+(((float)totalcmax)/1000f/1000f)/(float)nroffetch+" ms."+ @@ -241,3 +248,4 @@ } } } + Added: tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/TestException.java URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/TestException.java?rev=766936&view=auto ============================================================================== --- tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/TestException.java (added) +++ tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/TestException.java Tue Apr 21 01:14:36 2009 @@ -0,0 +1,42 @@ +package org.apache.tomcat.jdbc.test; + +import java.lang.reflect.Method; +import java.sql.Connection; +import java.sql.SQLException; + +import org.apache.tomcat.jdbc.pool.ConnectionPool; +import org.apache.tomcat.jdbc.pool.JdbcInterceptor; +import org.apache.tomcat.jdbc.pool.PooledConnection; +import org.apache.tomcat.jdbc.pool.interceptor.AbstractCreateStatementInterceptor; +import org.apache.tomcat.jdbc.pool.interceptor.AbstractQueryReport; + +public class TestException extends DefaultTestCase { + + public TestException(String name) { + super(name); + } + + public void testException() throws Exception { + init(); + datasource.getPoolProperties().setJdbcInterceptors(TestInterceptor.class.getName()); + Connection con = datasource.getConnection(); + try { + con.createStatement(); + }catch (Exception x) { + + } + } + + + public static class TestInterceptor extends JdbcInterceptor { + + @Override + public void reset(ConnectionPool parent, PooledConnection con) { + // TODO Auto-generated method stub + + } + + + } + +} --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org