You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ps...@apache.org on 2011/05/13 05:16:49 UTC
svn commit: r1102552 -
/commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/pool/PoolSoak.java
Author: psteitz
Date: Fri May 13 03:16:49 2011
New Revision: 1102552
URL: http://svn.apache.org/viewvc?rev=1102552&view=rev
Log:
Keeping up with pool2 - map 1.x to 2.0 exhausted action config.
Modified:
commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/pool/PoolSoak.java
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=1102552&r1=1102551&r2=1102552&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 Fri May 13 03:16:49 2011
@@ -27,6 +27,7 @@ import org.apache.commons.performance.Co
import org.apache.commons.performance.ClientThread;
import org.apache.commons.performance.LoadGenerator;
import org.apache.commons.performance.Statistics;
+import org.apache.commons.pool2.impl.WhenExhaustedAction;
/**
* Configurable load / performance tester for commons pool.
@@ -171,7 +172,7 @@ public class PoolSoak extends LoadGenera
} else if (poolType.equals("GenericObjectPool2")) {
genericObjectPool2 = new org.apache.commons.pool2.impl.GenericObjectPool<Waiter>(factory2);
genericObjectPool2.setMaxActive(maxActive);
- genericObjectPool2.setWhenExhaustedAction(exhaustedAction);
+ genericObjectPool2.setWhenExhaustedAction(mapExhaustedAction(exhaustedAction));
genericObjectPool2.setMaxWait(maxWait);
genericObjectPool2.setMaxIdle(maxIdle);
genericObjectPool2.setMinIdle(minIdle);
@@ -219,7 +220,7 @@ public class PoolSoak extends LoadGenera
new org.apache.commons.pool2.impl.GenericKeyedObjectPool<Integer, Waiter>(factory2);
genericKeyedObjectPool2.setMaxActive(maxActivePerKey);
genericKeyedObjectPool2.setMaxTotal(maxActive);
- genericKeyedObjectPool2.setWhenExhaustedAction(exhaustedAction);
+ genericKeyedObjectPool2.setWhenExhaustedAction(mapExhaustedAction(exhaustedAction));
genericKeyedObjectPool2.setMaxWait(maxWait);
genericKeyedObjectPool2.setMaxIdle(maxIdle);
genericKeyedObjectPool2.setMinIdle(minIdle);
@@ -246,6 +247,24 @@ public class PoolSoak extends LoadGenera
}
/**
+ * Maps version 1.x byte-coded whenExhaustedAction config to 2.0 enum
+ * @param action 1.x-style specification
+ * @return 2.0 enum value
+ */
+ private WhenExhaustedAction mapExhaustedAction(byte action) {
+ switch (action) {
+ case org.apache.commons.pool.impl.GenericObjectPool.WHEN_EXHAUSTED_BLOCK:
+ return WhenExhaustedAction.BLOCK;
+ case org.apache.commons.pool.impl.GenericObjectPool.WHEN_EXHAUSTED_FAIL:
+ return WhenExhaustedAction.FAIL;
+ case org.apache.commons.pool.impl.GenericObjectPool.WHEN_EXHAUSTED_GROW:
+ return WhenExhaustedAction.GROW;
+ default:
+ throw new IllegalArgumentException("Invalid whenExhaustedAction");
+ }
+ }
+
+ /**
* Close object pool
*/
protected void cleanUp() throws Exception {