Return-Path:
X-Original-To: apmail-commons-commits-archive@minotaur.apache.org
Delivered-To: apmail-commons-commits-archive@minotaur.apache.org
Received: from mail.apache.org (hermes.apache.org [140.211.11.3])
by minotaur.apache.org (Postfix) with SMTP id B9E1E418C
for ;
Mon, 9 May 2011 06:37:26 +0000 (UTC)
Received: (qmail 12828 invoked by uid 500); 9 May 2011 06:37:26 -0000
Delivered-To: apmail-commons-commits-archive@commons.apache.org
Received: (qmail 12492 invoked by uid 500); 9 May 2011 06:37:25 -0000
Mailing-List: contact commits-help@commons.apache.org; run by ezmlm
Precedence: bulk
List-Help:
List-Unsubscribe:
List-Post:
List-Id:
Reply-To: dev@commons.apache.org
Delivered-To: mailing list commits@commons.apache.org
Received: (qmail 12485 invoked by uid 99); 9 May 2011 06:37:23 -0000
Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136)
by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 May 2011 06:37:23 +0000
X-ASF-Spam-Status: No, hits=-2000.0 required=5.0
tests=ALL_TRUSTED
X-Spam-Check-By: apache.org
Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4)
by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 May 2011 06:37:20 +0000
Received: by eris.apache.org (Postfix, from userid 65534)
id 6A22323889E7; Mon, 9 May 2011 06:37:00 +0000 (UTC)
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: svn commit: r1100894 - in /commons/sandbox/performance/trunk/src:
java/org/apache/commons/performance/pool/ pool/
Date: Mon, 09 May 2011 06:37:00 -0000
To: commits@commons.apache.org
From: psteitz@apache.org
X-Mailer: svnmailer-1.0.8
Message-Id: <20110509063700.6A22323889E7@eris.apache.org>
Author: psteitz
Date: Mon May 9 06:36:59 2011
New Revision: 1100894
URL: http://svn.apache.org/viewvc?rev=1100894&view=rev
Log:
Added support for version 2 GOP, GKOP tests.
Added:
commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/pool/WaiterFactory2.java (with props)
commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/pool/WaiterFactoryBase.java (with props)
commons/sandbox/performance/trunk/src/pool/build.properties.sample
Modified:
commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/pool/PoolClientThread.java
commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/pool/PoolSoak.java
commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/pool/WaiterFactory.java
commons/sandbox/performance/trunk/src/pool/build.xml
commons/sandbox/performance/trunk/src/pool/config-pool.xml
commons/sandbox/performance/trunk/src/pool/logging.properties
Modified: commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/pool/PoolClientThread.java
URL: http://svn.apache.org/viewvc/commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/pool/PoolClientThread.java?rev=1100894&r1=1100893&r2=1100894&view=diff
==============================================================================
--- commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/pool/PoolClientThread.java (original)
+++ commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/pool/PoolClientThread.java Mon May 9 06:36:59 2011
@@ -21,8 +21,10 @@ import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
-import org.apache.commons.pool.ObjectPool;
-import org.apache.commons.pool.KeyedObjectPool;
+//import org.apache.commons.pool.ObjectPool;
+//import org.apache.commons.pool2.ObjectPool;
+//import org.apache.commons.pool.KeyedObjectPool;
+//import org.apache.commons.pool2.KeyedObjectPool;
import org.apache.commons.math.random.RandomData;
import org.apache.commons.math.random.RandomDataImpl;
import org.apache.commons.math.stat.descriptive.SummaryStatistics;
@@ -33,17 +35,24 @@ import org.apache.commons.performance.St
*
Client thread that borrows and returns objects from a pool in a loop.
* See {@link ClientThread ClientThread javadoc} for a description
* of how times between requests are computed. In addition to request latency,
- * pool numIdle and numActive statistics and stats on instance idle time are tracked.
+ * pool numIdle and numActive statistics and stats on instance idle time are tracked.
+ * Constructors are provided for both 1.x and version 2 simple and keyed pools.
*
*
Note that this class is *not* threadsafe.
*/
public class PoolClientThread extends ClientThread {
- /** Object pool (if keyed = false) */
- private final ObjectPool pool;
+ /** Version 1.x object pool (if keyed = false) */
+ private final org.apache.commons.pool.ObjectPool pool;
- /**Keyed pool (if keyed = true) */
- private final KeyedObjectPool keyedPool;
+ /** Version 1.x keyed pool (if keyed = true) */
+ private final org.apache.commons.pool.KeyedObjectPool keyedPool;
+
+ /** Version 2 object pool (if keyed = false) */
+ private final org.apache.commons.pool2.ObjectPool pool2;
+
+ /** Version 2 keyed pool (if keyed = true) */
+ private final org.apache.commons.pool2.KeyedObjectPool keyedPool2;
/** Whether or not pool being tested is keyed */
private boolean keyed;
@@ -70,7 +79,7 @@ public class PoolClientThread extends Cl
private Waiter waiter = null;
/**
- * Create a pool client thread for an ObjectPool.
+ * Create a pool client thread for a version 1.x ObjectPool.
*
* @param iterations number of iterations
* @param minDelay minimum mean time between client requests
@@ -90,19 +99,22 @@ public class PoolClientThread extends Cl
public PoolClientThread(long iterations, long minDelay, long maxDelay,
double sigma, String delayType, long rampPeriod, long peakPeriod,
long troughPeriod, String cycleType, String rampType, Logger logger,
- Statistics stats, ObjectPool pool, double samplingRate) {
+ Statistics stats, org.apache.commons.pool.ObjectPool pool,
+ double samplingRate) {
super(iterations, minDelay, maxDelay, sigma, delayType, rampPeriod,
peakPeriod, troughPeriod, cycleType,rampType, logger,
stats);
this.pool = pool;
+ this.pool2 = null;
+ this.keyedPool2 = null;
this.keyedPool = null;
this.keyed = false;
this.samplingRate = samplingRate;
}
/**
- * Create a pool client thread for a KeyedObjectPool.
+ * Create a pool client thread for a version 1.x KeyedObjectPool.
*
* @param iterations number of iterations
* @param minDelay minimum mean time between client requests
@@ -122,7 +134,8 @@ public class PoolClientThread extends Cl
public PoolClientThread(long iterations, long minDelay, long maxDelay,
double sigma, String delayType, long rampPeriod, long peakPeriod,
long troughPeriod, String cycleType, String rampType, Logger logger,
- Statistics stats, KeyedObjectPool keyedPool, double samplingRate) {
+ Statistics stats, org.apache.commons.pool.KeyedObjectPool keyedPool,
+ double samplingRate) {
super(iterations, minDelay, maxDelay, sigma, delayType, rampPeriod,
peakPeriod, troughPeriod, cycleType,rampType, logger,
@@ -130,6 +143,83 @@ public class PoolClientThread extends Cl
this.keyedPool = keyedPool;
this.pool = null;
+ this.pool2 = null;
+ this.keyedPool2 = null;
+ this.keyed = true;
+ this.samplingRate = samplingRate;
+ keys = new ArrayList();
+ for (int i = 0; i < 20; i++) { //TODO: make number of keys configurable
+ keys.add(new Integer(i));
+ }
+ }
+
+ /**
+ * Create a pool client thread for a version 1.x ObjectPool.
+ *
+ * @param iterations number of iterations
+ * @param minDelay minimum mean time between client requests
+ * @param maxDelay maximum mean time between client requests
+ * @param delayType distribution of time between client requests
+ * @param rampPeriod ramp period of cycle for cyclic load
+ * @param peakPeriod peak period of cycle for cyclic load
+ * @param troughPeriod trough period of cycle for cyclic load
+ * @param cycleType type of cycle for mean delay
+ * @param rampType type of ramp (linear or random jumps)
+ * @param logger common logger shared by all clients
+ * @param stats Statistics container
+ * @param pool ObjectPool
+ * @param samplingRate proportion of requests for which numIdle and numActive
+ * will be sampled for statistical analysis
+ */
+ public PoolClientThread(long iterations, long minDelay, long maxDelay,
+ double sigma, String delayType, long rampPeriod, long peakPeriod,
+ long troughPeriod, String cycleType, String rampType, Logger logger,
+ Statistics stats, org.apache.commons.pool2.ObjectPool pool,
+ double samplingRate) {
+
+ super(iterations, minDelay, maxDelay, sigma, delayType, rampPeriod,
+ peakPeriod, troughPeriod, cycleType,rampType, logger,
+ stats);
+ this.pool2 = pool;
+ this.pool = null;
+ this.keyedPool2 = null;
+ this.keyedPool = null;
+ this.keyed = false;
+ this.samplingRate = samplingRate;
+ }
+
+ /**
+ * Create a pool client thread for a version 1.x KeyedObjectPool.
+ *
+ * @param iterations number of iterations
+ * @param minDelay minimum mean time between client requests
+ * @param maxDelay maximum mean time between client requests
+ * @param delayType distribution of time between client requests
+ * @param rampPeriod ramp period of cycle for cyclic load
+ * @param peakPeriod peak period of cycle for cyclic load
+ * @param troughPeriod trough period of cycle for cyclic load
+ * @param cycleType type of cycle for mean delay
+ * @param rampType type of ramp (linear or random jumps)
+ * @param logger common logger shared by all clients
+ * @param stats Statistics container
+ * @param keyedPool KeyedObjectPool
+ * @param samplingRate proportion of requests for which numIdle and numActive
+ * will be sampled for statistical analysis
+ */
+ public PoolClientThread(long iterations, long minDelay, long maxDelay,
+ double sigma, String delayType, long rampPeriod, long peakPeriod,
+ long troughPeriod, String cycleType, String rampType, Logger logger,
+ Statistics stats, org.apache.commons.pool2.KeyedObjectPool keyedPool,
+ double samplingRate) {
+
+ super(iterations, minDelay, maxDelay, sigma, delayType, rampPeriod,
+ peakPeriod, troughPeriod, cycleType,rampType, logger,
+ stats);
+
+ this.keyedPool2 = keyedPool;
+ this.pool = null;
+ this.pool2 = null;
+ this.keyedPool = null;
this.keyed = true;
this.samplingRate = samplingRate;
keys = new ArrayList();
@@ -142,13 +232,23 @@ public class PoolClientThread extends Cl
public void execute() throws Exception {
if (keyed) {
Integer key = keys.get(randomData.nextInt(0, 19));
- waiter = (Waiter) keyedPool.borrowObject(key);
+ waiter = keyedPool2 == null ? (Waiter) keyedPool.borrowObject(key) :
+ keyedPool2.borrowObject(key);
waiter.doWait();
- keyedPool.returnObject(key, waiter);
+ if (keyedPool2 == null) {
+ keyedPool.returnObject(key, waiter);
+ } else {
+ keyedPool2.returnObject(key, waiter);
+ }
} else {
- waiter = (Waiter) pool.borrowObject();
+ waiter = pool2 == null ? (Waiter) pool.borrowObject() :
+ pool2.borrowObject();
waiter.doWait();
- pool.returnObject(waiter);
+ if (pool2 == null) {
+ pool.returnObject(waiter);
+ } else {
+ pool2.returnObject(waiter);
+ }
}
}
@@ -156,11 +256,15 @@ public class PoolClientThread extends Cl
// Capture pool metrics
if (randomData.nextUniform(0, 1) < samplingRate) {
if (keyed) {
- numIdleStats.addValue(keyedPool.getNumIdle());
- numActiveStats.addValue(keyedPool.getNumActive());
+ numIdleStats.addValue(keyedPool2 == null ? keyedPool.getNumIdle() :
+ keyedPool2.getNumIdle());
+ numActiveStats.addValue(keyedPool2 == null ? keyedPool.getNumActive() :
+ keyedPool2.getNumActive());
} else {
- numIdleStats.addValue(pool.getNumIdle());
- numActiveStats.addValue(pool.getNumActive());
+ numIdleStats.addValue(pool2 == null ? pool.getNumIdle() :
+ pool2.getNumIdle());
+ numActiveStats.addValue(pool2 == null ? pool.getNumActive() :
+ pool2.getNumActive());
}
}
if (waiter != null) {
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=1100894&r1=1100893&r2=1100894&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 May 9 06:36:59 2011
@@ -20,10 +20,8 @@ package org.apache.commons.performance.p
import java.util.logging.Logger;
import org.apache.commons.dbcp.AbandonedConfig;
import org.apache.commons.dbcp.AbandonedObjectPool;
-import org.apache.commons.pool.impl.GenericObjectPool;
import org.apache.commons.pool.impl.StackObjectPool;
import org.apache.commons.pool.impl.SoftReferenceObjectPool;
-import org.apache.commons.pool.impl.GenericKeyedObjectPool;
import org.apache.commons.pool.impl.StackKeyedObjectPool;
import org.apache.commons.performance.ConfigurationException;
import org.apache.commons.performance.ClientThread;
@@ -39,8 +37,10 @@ import org.apache.commons.performance.St
public class PoolSoak extends LoadGenerator {
// Pool instances
- private GenericObjectPool genericObjectPool;
- private GenericKeyedObjectPool genericKeyedObjectPool;
+ private org.apache.commons.pool.impl.GenericObjectPool genericObjectPool;
+ private org.apache.commons.pool.impl.GenericKeyedObjectPool genericKeyedObjectPool;
+ private org.apache.commons.pool2.impl.GenericObjectPool genericObjectPool2;
+ private org.apache.commons.pool2.impl.GenericKeyedObjectPool genericKeyedObjectPool2;
private StackObjectPool stackObjectPool;
private SoftReferenceObjectPool softReferenceObjectPool;
private StackKeyedObjectPool stackKeyedObjectPool;
@@ -148,9 +148,13 @@ public class PoolSoak extends LoadGenera
makeLatency, passivateLatency, validateLatency, waiterLatency,
maxActive, maxActivePerKey, passivateInvalidationProbability);
+ WaiterFactory2 factory2 = new WaiterFactory2(activateLatency, destroyLatency,
+ makeLatency, passivateLatency, validateLatency, waiterLatency,
+ maxActive, maxActivePerKey, passivateInvalidationProbability);
+
// Create object pool
if (poolType.equals("GenericObjectPool")) {
- genericObjectPool = new GenericObjectPool(factory);
+ genericObjectPool = new org.apache.commons.pool.impl.GenericObjectPool(factory);
genericObjectPool.setMaxActive(maxActive);
genericObjectPool.setWhenExhaustedAction(exhaustedAction);
genericObjectPool.setMaxWait(maxWait);
@@ -163,9 +167,24 @@ public class PoolSoak extends LoadGenera
genericObjectPool.setNumTestsPerEvictionRun(testsPerEviction);
genericObjectPool.setMinEvictableIdleTimeMillis(idleTimeout);
genericObjectPool.setTestWhileIdle(testWhileIdle);
- //genericObjectPool.setLifo(lifo);
+ genericObjectPool.setLifo(lifo);
+ } else if (poolType.equals("GenericObjectPool2")) {
+ genericObjectPool2 = new org.apache.commons.pool2.impl.GenericObjectPool(factory2);
+ genericObjectPool2.setMaxActive(maxActive);
+ genericObjectPool2.setWhenExhaustedAction(exhaustedAction);
+ genericObjectPool2.setMaxWait(maxWait);
+ genericObjectPool2.setMaxIdle(maxIdle);
+ genericObjectPool2.setMinIdle(minIdle);
+ genericObjectPool2.setTestOnBorrow(testOnBorrow);
+ genericObjectPool2.setTestOnReturn(testOnReturn);
+ genericObjectPool2.setTimeBetweenEvictionRunsMillis(
+ timeBetweenEvictions);
+ genericObjectPool2.setNumTestsPerEvictionRun(testsPerEviction);
+ genericObjectPool2.setMinEvictableIdleTimeMillis(idleTimeout);
+ genericObjectPool2.setTestWhileIdle(testWhileIdle);
+ genericObjectPool2.setLifo(lifo);
} else if (poolType.equals("AbandonedObjectPool")) {
- genericObjectPool = new AbandonedObjectPool(null,abandonedConfig);
+ genericObjectPool = new AbandonedObjectPool(factory,abandonedConfig);
genericObjectPool.setMaxActive(maxActive);
genericObjectPool.setWhenExhaustedAction(exhaustedAction);
genericObjectPool.setMaxWait(maxWait);
@@ -178,10 +197,9 @@ public class PoolSoak extends LoadGenera
genericObjectPool.setNumTestsPerEvictionRun(testsPerEviction);
genericObjectPool.setMinEvictableIdleTimeMillis(idleTimeout);
genericObjectPool.setTestWhileIdle(testWhileIdle);
- //genericObjectPool.setLifo(lifo);
- genericObjectPool.setFactory(factory);
+ genericObjectPool.setLifo(lifo);
} else if (poolType.equals("GenericKeyedObjectPool")) {
- genericKeyedObjectPool = new GenericKeyedObjectPool();
+ genericKeyedObjectPool = new org.apache.commons.pool.impl.GenericKeyedObjectPool(factory);
genericKeyedObjectPool.setMaxActive(maxActivePerKey);
genericKeyedObjectPool.setMaxTotal(maxActive);
genericKeyedObjectPool.setWhenExhaustedAction(exhaustedAction);
@@ -195,17 +213,30 @@ public class PoolSoak extends LoadGenera
genericKeyedObjectPool.setNumTestsPerEvictionRun(testsPerEviction);
genericKeyedObjectPool.setMinEvictableIdleTimeMillis(idleTimeout);
genericKeyedObjectPool.setTestWhileIdle(testWhileIdle);
- //genericKeyedObjectPool.setLifo(lifo);
- genericKeyedObjectPool.setFactory(factory);
+ genericKeyedObjectPool.setLifo(lifo);
+ } else if (poolType.equals("GenericKeyedObjectPool2")) {
+ genericKeyedObjectPool2 =
+ new org.apache.commons.pool2.impl.GenericKeyedObjectPool(factory2);
+ genericKeyedObjectPool2.setMaxActive(maxActivePerKey);
+ genericKeyedObjectPool2.setMaxTotal(maxActive);
+ genericKeyedObjectPool2.setWhenExhaustedAction(exhaustedAction);
+ genericKeyedObjectPool2.setMaxWait(maxWait);
+ genericKeyedObjectPool2.setMaxIdle(maxIdle);
+ genericKeyedObjectPool2.setMinIdle(minIdle);
+ genericKeyedObjectPool2.setTestOnBorrow(testOnBorrow);
+ genericKeyedObjectPool2.setTestOnReturn(testOnReturn);
+ genericKeyedObjectPool2.setTimeBetweenEvictionRunsMillis(
+ timeBetweenEvictions);
+ genericKeyedObjectPool2.setNumTestsPerEvictionRun(testsPerEviction);
+ genericKeyedObjectPool2.setMinEvictableIdleTimeMillis(idleTimeout);
+ genericKeyedObjectPool2.setTestWhileIdle(testWhileIdle);
+ genericKeyedObjectPool2.setLifo(lifo);
} else if (poolType.equals("StackObjectPool")) {
- stackObjectPool = new StackObjectPool();
- stackObjectPool.setFactory(factory);
+ stackObjectPool = new StackObjectPool(factory);
} else if (poolType.equals("SoftReferenceObjectPool")) {
- softReferenceObjectPool = new SoftReferenceObjectPool();
- softReferenceObjectPool.setFactory(factory);
+ softReferenceObjectPool = new SoftReferenceObjectPool(factory);
} else if (poolType.equals("StackKeyedObjectPool")) {
- stackKeyedObjectPool = new StackKeyedObjectPool();
- stackKeyedObjectPool.setFactory(factory);
+ stackKeyedObjectPool = new StackKeyedObjectPool(factory);
} else {
throw new ConfigurationException(
"invalid pool type configuration: " + poolType);
@@ -224,6 +255,12 @@ public class PoolSoak extends LoadGenera
if (genericKeyedObjectPool != null) {
genericKeyedObjectPool.close();
}
+ if (genericObjectPool2 != null) {
+ genericObjectPool2.close();
+ }
+ if (genericKeyedObjectPool2 != null) {
+ genericKeyedObjectPool2.close();
+ }
if (stackObjectPool != null) {
stackObjectPool.close();
}
@@ -254,6 +291,18 @@ public class PoolSoak extends LoadGenera
cycleType, rampType, logger, stats,
genericKeyedObjectPool, samplingRate);
}
+ if (poolType.equals("GenericObjectPool2")) {
+ return new PoolClientThread(iterations, minDelay, maxDelay,
+ sigma, delayType, rampPeriod, peakPeriod, troughPeriod,
+ cycleType, rampType, logger, stats, genericObjectPool2,
+ samplingRate);
+ }
+ if (poolType.equals("GenericKeyedObjectPool2")) {
+ return new PoolClientThread(iterations, minDelay, maxDelay,
+ sigma, delayType, rampPeriod, peakPeriod, troughPeriod,
+ cycleType, rampType, logger, stats,
+ genericKeyedObjectPool2, samplingRate);
+ }
if (poolType.equals("StackKeyedObjectPool")) {
return new PoolClientThread(iterations, minDelay, maxDelay,
sigma, delayType, rampPeriod, peakPeriod, troughPeriod,
@@ -314,11 +363,11 @@ public class PoolSoak extends LoadGenera
this.lifo = Boolean.parseBoolean(lifo);
this.poolType = type;
if (exhaustedAction.equals("block")) {
- this.exhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_BLOCK;
+ this.exhaustedAction = org.apache.commons.pool.impl.GenericObjectPool.WHEN_EXHAUSTED_BLOCK;
} else if (exhaustedAction.equals("fail")) {
- this.exhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_FAIL;
+ this.exhaustedAction = org.apache.commons.pool.impl.GenericObjectPool.WHEN_EXHAUSTED_FAIL;
} else if (exhaustedAction.equals("grow")) {
- this.exhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_GROW;
+ this.exhaustedAction = org.apache.commons.pool.impl.GenericObjectPool.WHEN_EXHAUSTED_GROW;
} else {
throw new ConfigurationException(
"Bad configuration setting for exhausted action: "
@@ -337,11 +386,11 @@ public class PoolSoak extends LoadGenera
}
// Pool getters for unit tests
- protected GenericObjectPool getGenericObjectPool() {
+ protected org.apache.commons.pool.impl.GenericObjectPool getGenericObjectPool() {
return genericObjectPool;
}
- protected GenericKeyedObjectPool getGenericKeyedObjectPool() {
+ protected org.apache.commons.pool.impl.GenericKeyedObjectPool getGenericKeyedObjectPool() {
return genericKeyedObjectPool;
}
Modified: commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/pool/WaiterFactory.java
URL: http://svn.apache.org/viewvc/commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/pool/WaiterFactory.java?rev=1100894&r1=1100893&r2=1100894&view=diff
==============================================================================
--- commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/pool/WaiterFactory.java (original)
+++ commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/pool/WaiterFactory.java Mon May 9 06:36:59 2011
@@ -17,74 +17,22 @@
package org.apache.commons.performance.pool;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Iterator;
-import java.util.logging.Logger;
-import java.util.logging.Level;
import java.util.concurrent.atomic.AtomicInteger;
-
import org.apache.commons.pool.PoolableObjectFactory;
import org.apache.commons.pool.KeyedPoolableObjectFactory;
/**
- * Object factory with configurable latencies for object lifecycle methods.
- *
+ * Version 1.x object factory with configurable latencies for object lifecycle methods.
*/
-public class WaiterFactory implements PoolableObjectFactory,
-KeyedPoolableObjectFactory {
-
- // TODO: implement protected getters so these can be stochastic
- /** Latency of activateObject */
- private final long activateLatency;
-
- /** Latency of destroyObject */
- private final long destroyLatency;
-
- /** Latency of makeObject */
- private final long makeLatency;
-
- /** Latency of passivateObject */
- private final long passivateLatency;
-
- /** Latency of validateObject */
- private final long validateLatency;
-
- /** Latency of doWait for Waiter instances created by this factory */
- private final long waiterLatency;
-
- /** Probability that passivation will invalidate Waiter instances */
- private final double passivateInvalidationProbability;
-
- /** Count of (makes - destroys) since last reset */
- private long activeCount = 0;
-
- /** Count of (makes - destroys) per key since last reset */
- private Map