commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject svn commit: r668357 - in /commons/sandbox/performance/trunk/src/java/org/apache/commons/performance: LoadGenerator.java dbcp/DBCPSoak.java dbcp/DBCPTest.java pool/PoolSoak.java
Date Tue, 17 Jun 2008 00:17:33 GMT
Author: psteitz
Date: Mon Jun 16 17:17:33 2008
New Revision: 668357

URL: http://svn.apache.org/viewvc?rev=668357&view=rev
Log:
Added cleanUp to LoadGenerator.

Modified:
    commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/LoadGenerator.java
    commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/dbcp/DBCPSoak.java
    commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/dbcp/DBCPTest.java
    commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/pool/PoolSoak.java

Modified: commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/LoadGenerator.java
URL: http://svn.apache.org/viewvc/commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/LoadGenerator.java?rev=668357&r1=668356&r2=668357&view=diff
==============================================================================
--- commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/LoadGenerator.java
(original)
+++ commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/LoadGenerator.java
Mon Jun 16 17:17:33 2008
@@ -82,13 +82,17 @@
     
     /**
      * <p>Invokes {@link #configure()} to load digester rules, then digster.parse,
-     * then {@link #init()} to initialize configuration members. Then spawns and
+     * then {@link #init} to initialize configuration members. Then spawns and
      * executes {@link #numClients} ClientThreads using {@link #makeClientThread}
-     * to create the ClientThread instances.
-     * </p>
+     * to create the ClientThread instances. Waits for all spawned threads to
+     * terminate and then logs accumulated statistics, using 
+     * {@link Statistics#displayOverallSummary}</p>
+     * 
      * <p>Subclasses should not need to override this method, but must implement
-     * makeClientThread and may override configure and init to prepare data to
-     * pass to makeClientThread.</p>
+     * {@link #makeClientThread} and may override {@link #configure} and
+     * {@link #init} to prepare data to pass to <code>makeClientThread</code>,

+     * and {@link #cleanUp} to clean up after all threads terminate.
+     * </p>
      * 
      * @throws Exception
      */
@@ -111,6 +115,9 @@
         
         // Log summary statistics for accumulated metrics
         logger.info(stats.displayOverallSummary());
+        
+        // clean up
+        cleanUp();
 	}
     
     protected abstract ClientThread makeClientThread(
@@ -129,6 +136,35 @@
      */
     protected void init() throws Exception {}
     
+    
+    /**
+     * This method is invoked by {@link #execute()} after all spawned threads
+     * have terminated. Override to clean up any resources allocated in 
+     * {@link #init().
+     * 
+     * @throws Exception
+     */
+    protected void cleanUp() throws Exception {}
+    
+    
+    /**
+     * Configures basic run parameters. Invoked by Digester via a rule defined
+     * in {@link #configure()}.
+     * 
+     * @param iterations number of iterationss
+     * @param clients number of client threads
+     * @param minDelay minimum delay between client thread requests (ms)
+     * @param maxDelay maximimum delay between client thread requests (ms)
+     * @param sigma standard deviation of delay
+     * @param delayType type of delay (constant, gaussian, poisson)
+     * @param rampType type of ramp (none, linear, random)
+     * @param rampPeriod rampup/rampdown time
+     * @param peakPeriod peak period
+     * @param troughPeriod trough period
+     * @param cycleType cycle type (none, oscillating)
+     * @throws ConfigurationException
+     */
+    
     public void configureRun(String iterations, String clients,
             String minDelay, String maxDelay, String sigma,
             String delayType, String rampType, String rampPeriod,

Modified: commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/dbcp/DBCPSoak.java
URL: http://svn.apache.org/viewvc/commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/dbcp/DBCPSoak.java?rev=668357&r1=668356&r2=668357&view=diff
==============================================================================
--- commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/dbcp/DBCPSoak.java
(original)
+++ commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/dbcp/DBCPSoak.java
Mon Jun 16 17:17:33 2008
@@ -168,6 +168,13 @@
         }
     }
     
+    /**
+     * Close connection pool
+     */
+    protected void cleanUp() throws Exception {
+        connectionPool.close();
+    }
+    
     protected ClientThread makeClientThread(
             long iterations, long minDelay, long maxDelay, double sigma,
             String delayType, long rampPeriod, long peakPeriod,

Modified: commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/dbcp/DBCPTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/dbcp/DBCPTest.java?rev=668357&r1=668356&r2=668357&view=diff
==============================================================================
--- commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/dbcp/DBCPTest.java
(original)
+++ commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/dbcp/DBCPTest.java
Mon Jun 16 17:17:33 2008
@@ -25,7 +25,6 @@
     public static void main(String[] args) {
         try {
             soaker.execute();
-            soaker.getConnectionPool().close();
         } catch (Exception ex) {
             ex.printStackTrace();
         }

Modified: commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/pool/PoolSoak.java
URL: http://svn.apache.org/viewvc/commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/pool/PoolSoak.java?rev=668357&r1=668356&r2=668357&view=diff
==============================================================================
--- commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/pool/PoolSoak.java
(original)
+++ commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/pool/PoolSoak.java
Mon Jun 16 17:17:33 2008
@@ -235,6 +235,27 @@
     }
     
     /**
+     * Close object pool
+     */
+    protected void cleanUp() throws Exception {
+        if (genericObjectPool != null) {
+            genericObjectPool.close();
+        }
+        if (genericKeyedObjectPool != null) {
+            genericKeyedObjectPool.close();
+        }
+        if (stackObjectPool != null) {
+            stackObjectPool.close();
+        }
+        if (softReferenceObjectPool != null) {
+            softReferenceObjectPool.close();
+        }
+        if (stackKeyedObjectPool != null) {
+            stackKeyedObjectPool.close();
+        }
+    }
+    
+    /**
      * Create and return a PoolClientThread
      */
     protected ClientThread makeClientThread(long iterations, long minDelay,



Mime
View raw message