Author: psteitz
Date: Sun Aug 5 10:57:24 2007
New Revision: 562921
URL: http://svn.apache.org/viewvc?view=rev&rev=562921
Log:
Removed unused imports, improved documentation, changed s/setup/setUp
Modified:
commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/ClientThread.java
commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/LoadGenerator.java
commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/dbcp/DBCPClientThread.java
commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/dbcp/DBCPSoak.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/ClientThread.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/ClientThread.java?view=diff&rev=562921&r1=562920&r2=562921
==============================================================================
---
commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/ClientThread.java
(original)
+++
commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/ClientThread.java
Sun Aug 5 10:57:24 2007
@@ -26,16 +26,25 @@
import org.apache.commons.math.stat.descriptive.SummaryStatisticsImpl;
/**
- * Base for performance / load test clients.
- * Run method executes init, then setup-execute-cleanup in a loop, gathering
- * performance statistics, with time between executions determined by nextDelay
- * method. See [EMAIL PROTECTED] for details on interarrival time computation.
+ * <p>Base for performance / load test clients.
+ * The run method executes init, then setup-execute-cleanup in a loop,
+ * gathering performance statistics, with time between executions based
+ * on configuration parameters. See [EMAIL PROTECTED] #nextDelay()} for
details on
+ * inter-arrival time computation.</p>
+ *
+ * <p>Subclasses <strong>must</strong> implement <code>execute</code>, which
+ * is the basic client request action that is executed, and timed,
+ * repeatedly. If per-request setup is required, and you do not want the time
+ * associated with this setup to be included in the reported timings,
implement
+ * <code>setUp</code> and put the setup code there. Similarly for
+ * <code>cleanUp</code>. Initiatlization code that needs to be executed once
+ * only, before any requests are initiated, should be put into
+ * <code>init.</code></p>
*
*/
public abstract class ClientThread implements Runnable {
- /** Number of iterations */
- protected long iterations;
+ // Inter-arrival time configuration parameters
/** Minimum mean time between requests */
protected long minDelay;
/** Maxiimum mean time between requests */
@@ -54,20 +63,17 @@
protected String cycleType;
/** Ramp type */
protected String rampType;
- /** Logger shared by client threads */
- protected Logger logger = null;
- /** List of statistics to which to append stats for this client */
- protected List <SummaryStatistics> statsList = null;
+
+ /** Number of iterations */
+ protected long iterations;
+
+ // State data
/** Start time of run */
protected long startTime;
/** Start time of current period */
protected long periodStart;
/** Last mean delay */
protected double lastMean;
- /** Random data generator */
- protected RandomData randomData = new RandomDataImpl();
- protected SummaryStatistics stats = new SummaryStatisticsImpl();
-
/** Cycle state constants */
protected static final int RAMPING_UP = 0;
protected static final int RAMPING_DOWN = 1;
@@ -76,6 +82,15 @@
/** Cycle state */
protected int cycleState = RAMPING_UP;
+ /** Random data generator */
+ protected RandomData randomData = new RandomDataImpl();
+ /** Statistics accumulator */
+ protected SummaryStatistics stats = new SummaryStatisticsImpl();
+ /** List of statistics to which to append stats for this client */
+ protected List <SummaryStatistics> statsList = null;
+ /** Logger shared by client threads */
+ protected Logger logger = null;
+
/**
* Create a client thread.
*
@@ -126,7 +141,7 @@
lastMean = (double) maxDelay; // Ramp up, if any, starts here
for (int i = 0; i < iterations; i++) {
try {
- setup();
+ setUp();
// Generate next interarrival time. If that is in the
// past, go right away and log a miss; otherwise wait.
long elapsed = System.currentTimeMillis() - lastStart;
@@ -169,7 +184,7 @@
protected void init() throws Exception {}
/** Executed at the beginning of each iteration */
- protected void setup() throws Exception {}
+ protected void setUp() throws Exception {}
/** Executed in finally block of iteration try-catch */
protected void cleanUp() throws Exception {}
@@ -182,58 +197,88 @@
/**
* <p>Computes the next interarrival time (time to wait between requests)
* based on configured values for min/max delay, delay type, cycle type,
- * ramp type and period.
- * </p>
- * <p>Currently supports constant (always returning minDelay delay time),
- * Poisson and Gaussian distributed random time delays, linear and random
- * ramps, and oscillating / non-oscillating cycle types.
- * </p>
- * <p>loadType determines whether returned times are deterministic
- * or random. If loadType is not "constant", a random value with the
- * specified distribution and mean determined by the other parameters
- * is returned. For "gaussian" loadType, sigma is used as used as the
- * standard deviation.
- * </p>
- * <p>cycleType determines how the returned times vary over time.
- * "oscillating", means times ramp up and down between minDelay and
maxDelay.
- * Ramp type is controlled by rampType. Linear rampType means the means
+ * ramp type and period. Currently supports constant (always returning
+ * <code>minDelay</code> delay time), Poisson and Gaussian distributed
+ * random time delays, linear and random ramps, and oscillating /
+ * non-oscillating cycle types.</p>
+ *
+ * <p><strong>loadType</strong> determines whether returned times are
+ * deterministic or random. If <code>loadType</code> is not "constant",
+ * a random value with the specified distribution and mean determined by
+ * the other parameters is returned. For "gaussian" <code>loadType</code>,
+ * <code>sigma</code> is used as used as the standard deviation. </p>
+ *
+ * <p><strong>cycleType</strong> determines how the returned times vary
+ * over time. "oscillating", means times ramp up and down between
+ * <code>minDelay</code> and <code>maxDelay.</code> Ramp type is controlled
+ * by <code>rampType.</code> Linear <code>rampType</code> means the means
* increase or decrease linearly over the time of the period. Random
* makes random jumps up or down toward the next peak or trough. "None" for
- * rampType under oscillating cycleType makes the means alternate between
- * peak (minDelay) and trough (maxDelay) with no ramp between.
- * </p>
+ * <code>rampType</code> under oscillating <code>cycleType</code> makes the
+ * means alternate between peak (<code>minDelay</code>) and trough
+ *(<code>maxDelay</code>) with no ramp between. </p>
+ *
* <p>Oscillating loads cycle through RAMPING_UP, PEAK_LOAD, RAMPING_DOWN
* and TROUGH_LOAD states, with the amount of time spent in each state
- * determined by rampPeriod (time spent increasing on the way up and
- * decreasing on the way down), peakPeriod (time spent at peak load, i.e.,
- * minDelay) and troughPeriod (time spent at minimum load, i.e., maxDelay).
- * All times are specified in milliseconds.
- * </p>
- * <p> For example, given <pre>
- * delayType = "constant"
- * minDelay = 250
- * maxDelay = 500
- * cycleState = "oscillating"
- * rampType = "linear"
- * rampPeriod = 10000
- * peakPeriod = 20000
- * troughPeriod = 30000
- * </pre>
- * load will start at one request every 500 ms, which is "trough load."
- * Load then ramps up linearly over the next 10 seconds unil it reaches
- * one request per 250 milliseconds, which is "peak load." Peak load is
- * sustained for 20 seconds and then load ramps back down, again taking
- * 10 seconds to get down to "trough load," which is sustained for 30
- * seconds. The cycle then repeats. If delayType is "gaussian", things
- * work the same way, but the computed delay value is fed into a gaussian
- * random number generator as the mean - i.e., nextDelay returns
- * random, gaussian distributed values with means moving according to the
- * algorithm above (and standard deviation constantly = sigma).
- * </p>
- * <p>For non-oscillating, non-constant runs, linear and random rampTypes
- * work similarly, but over just one ramp up period at the beginning of
- * the run.
- * </p>
+ * determined by <code>rampPeriod</code> (time spent increasing on the way
+ * up and decreasing on the way down), <code>peakPeriod</code> (time spent
+ * at peak load, i.e., <code>minDelay</code> mean delay) and
+ * <code>troughPeriod</code> (time spent at minimum load, i.e.,
+ * <code>maxDelay</code> mean delay). All times are specified in
+ * milliseconds. </p>
+ *
+ * <p><strong>Examples:</strong><ol>
+ *
+ * <li>Given<pre>
+ * delayType = "constant"
+ * minDelay = 250
+ * maxDelay = 500
+ * cycleType = "oscillating"
+ * rampType = "linear"
+ * rampPeriod = 10000
+ * peakPeriod = 20000
+ * troughPeriod = 30000</pre> load will start at one request every 500 ms,
+ * which is "trough load." Load then ramps up linearly over the next 10
+ * seconds unil it reaches one request per 250 milliseconds, which is
+ * "peak load." Peak load is sustained for 20 seconds and then load ramps
+ * back down, again taking 10 seconds to get down to "trough load," which
+ * is sustained for 30 seconds. The cycle then repeats.</li>
+ *
+ * <li><pre>
+ * delayType = "gaussian"
+ * minDelay = 250
+ * maxDelay = 500
+ * cycleType = "oscillating"
+ * rampType = "linear"
+ * rampPeriod = 10000
+ * peakPeriod = 20000
+ * troughPeriod = 30000
+ * sigma = 100 </pre> produces a load pattern similar to example 1, but in
+ * this case the computed delay value is fed into a gaussian random number
+ * generator as the mean and 100 as the standard deviation - i.e.,
+ * <code>nextDelay</code> returns random, gaussian distributed values with
+ * means moving according to the cyclic pattern in example 1.</li>
+ *
+ * <li><pre>
+ * delayType = "constant"
+ * minDelay = 250
+ * maxDelay = 500
+ * cycleType = "none"
+ * rampType = "linear"
+ * rampPeriod = 10000</pre> produces a load pattern that increases linearly
+ * from one request every 500ms to one request every 250ms and then stays
+ * constant at that level until the run is over. Other parameters are
+ * ignored in this case.</li>
+ *
+ * <li><pre>
+ * delayType = "poisson"
+ * minDelay = 250
+ * maxDelay = 500
+ * cycleType = "none"
+ * rampType = "none"
+ * </pre> produces inter-arrival times that are poisson distributed with
+ * mean 250ms. Note that when rampType is "none," the value of
+ * <code>minDelay</code> is used as the (constant) mean delay.</li></ol>
*
* @param currentTime current time
* @return next value for delay
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?view=diff&rev=562921&r1=562920&r2=562921
==============================================================================
---
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
Sun Aug 5 10:57:24 2007
@@ -24,26 +24,40 @@
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
import org.apache.commons.digester.Digester;
-import org.apache.commons.math.random.RandomData;
-import org.apache.commons.math.random.RandomDataImpl;
import org.apache.commons.math.stat.descriptive.SummaryStatistics;
import org.apache.commons.math.stat.descriptive.SummaryStatisticsImpl;
-import org.apache.commons.performance.ConfigurationException;
/**
* <p>Base class for load / peformance test runners.
* Uses Commons Digester to parse and load configuration and spawns
- * ClientThread instances to generate load and gather statistics.
- * </p>
- * <p>Subclasses must implement [EMAIL PROTECTED] #makeClientThread()} to
create client thread
- * instances to be kicked off by execute.</p>
- * <p> Sublasses may override [EMAIL PROTECTED] #configure()} to load
additional configuration
- * parameters and pass them on to the client in makeClientThread.
- * </p>
+ * [EMAIL PROTECTED] ClientThread} instances to generate load and gather
statistics.</p>
+ *
+ * <p>Subclasses <code>must</code> implement <code>makeClientThread</code> to
+ * create client thread instances to be kicked off by <code>execute.</code>
+ * Sublasses will also in general override <code>configure</code> to load
+ * additional configuration parameters and pass them on to the client in
+ * <code>makeClientThread.</code> Implementations of <code>configure</code>
+ * should start with a <code>super()</code> call so that the base configuration
+ * parameters are loaded. This method should also set the
<code>configFile</code>
+ * property to a valid URI or filespec (suitable argument for Digester's parse
+ * method). Setup code that needs to be executed before any client threads are
+ * spawned should be put in <code>init</code></p>
+ *
+ * <p>See
+ * <a
href="http://svn.apache.org/viewvc/commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/dbcp/DBCPSoak.java?view=markup">
+ * DBCPSoak</a> and its
+ * <a
href="http://svn.apache.org/viewvc/commons/sandbox/performance/trunk/config-dbcp.xml?view=markup">
+ * sample configuration file</a> for an example. As in that example,
additional
+ * sections of the config file should be parsed and loaded in the overridden
+ * <code>configure</code> method. The "run" section is required by the base
+ * implementation. That example also illustrates how <code>init</code>
+ * can be used to set up resources or data structures required by the client
+ * threads.</p>
*
*/
public abstract class LoadGenerator {
- protected static Logger logger =
Logger.getLogger(LoadGenerator.class.getName());
+ protected static final Logger logger =
+ Logger.getLogger(LoadGenerator.class.getName());
private static List <SummaryStatistics> statsList =
new ArrayList <SummaryStatistics>();
@@ -160,8 +174,9 @@
* *this onto the stack and loading rules to configure basic "run"
* parameters.
* </p>
- * <p>Subclasses can override this, using super() to load base parameters
- * and then adding additional addCallMethod sequences for additional
parameters.
+ * <p>Subclasses can override this, using <code>super()</code> to load base
+ * parameters and then adding additional </code>addCallMethod</code>
+ * sequences for additional parameters.
* </p>
*
* @throws Exception
Modified:
commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/dbcp/DBCPClientThread.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/dbcp/DBCPClientThread.java?view=diff&rev=562921&r1=562920&r2=562921
==============================================================================
---
commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/dbcp/DBCPClientThread.java
(original)
+++
commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/dbcp/DBCPClientThread.java
Sun Aug 5 10:57:24 2007
@@ -82,7 +82,7 @@
}
/** Generate a random query */
- public void setup() throws Exception {
+ public void setUp() throws Exception {
if (textQuery) {
currentQuery = queryString +
randomData.nextHexString(20) + "';";
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?view=diff&rev=562921&r1=562920&r2=562921
==============================================================================
---
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
Sun Aug 5 10:57:24 2007
@@ -22,15 +22,12 @@
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.Statement;
-import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.logging.Logger;
-import javax.sql.DataSource;
import org.apache.commons.dbcp.AbandonedConfig;
import org.apache.commons.dbcp.AbandonedObjectPool;
import org.apache.commons.dbcp.ConnectionFactory;
-import org.apache.commons.dbcp.DataSourceConnectionFactory;
import org.apache.commons.dbcp.DriverConnectionFactory;
import org.apache.commons.dbcp.DriverManagerConnectionFactory;
import org.apache.commons.dbcp.PoolableConnectionFactory;
@@ -46,7 +43,6 @@
import org.apache.commons.performance.ConfigurationException;
import org.apache.commons.performance.ClientThread;
import org.apache.commons.performance.LoadGenerator;
-import org.apache.commons.performance.pool.WaiterFactory;
/**
* Configurable load / performance tester for commons dbcp.
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?view=diff&rev=562921&r1=562920&r2=562921
==============================================================================
---
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
Sun Aug 5 10:57:24 2007
@@ -17,16 +17,11 @@
package org.apache.commons.performance.pool;
-import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import org.apache.commons.dbcp.AbandonedConfig;
import org.apache.commons.dbcp.AbandonedObjectPool;
import org.apache.commons.math.stat.descriptive.SummaryStatistics;
-import org.apache.commons.pool.KeyedObjectPoolFactory;
-import org.apache.commons.pool.PoolableObjectFactory;
-import org.apache.commons.pool.impl.GenericKeyedObjectPool;
-import org.apache.commons.pool.impl.GenericKeyedObjectPoolFactory;
import org.apache.commons.pool.impl.GenericObjectPool;
import org.apache.commons.performance.ConfigurationException;
import org.apache.commons.performance.ClientThread;