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 119784214
for ;
Sun, 5 Jun 2011 01:00:10 +0000 (UTC)
Received: (qmail 885 invoked by uid 500); 5 Jun 2011 01:00:09 -0000
Delivered-To: apmail-commons-commits-archive@commons.apache.org
Received: (qmail 615 invoked by uid 500); 5 Jun 2011 01:00:09 -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 608 invoked by uid 99); 5 Jun 2011 01:00:09 -0000
Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136)
by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 05 Jun 2011 01:00:09 +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; Sun, 05 Jun 2011 01:00:07 +0000
Received: by eris.apache.org (Postfix, from userid 65534)
id 73FE923889D5; Sun, 5 Jun 2011 00:59:47 +0000 (UTC)
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: svn commit: r1131510 - in /commons/proper/pool/trunk/src:
java/org/apache/commons/pool2/impl/ test/org/apache/commons/pool2/impl/
Date: Sun, 05 Jun 2011 00:59:47 -0000
To: commits@commons.apache.org
From: psteitz@apache.org
X-Mailer: svnmailer-1.0.8
Message-Id: <20110605005947.73FE923889D5@eris.apache.org>
Author: psteitz
Date: Sun Jun 5 00:59:46 2011
New Revision: 1131510
URL: http://svn.apache.org/viewvc?rev=1131510&view=rev
Log:
Renamed GKOP maxIdle, minIdle to *perKey; removed maxTotal, maxIdle, minIdle from BaseObjectPoolConfig.
Modified:
commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/BaseObjectPoolConfig.java
commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPoolConfig.java
commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPoolFactory.java
Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/BaseObjectPoolConfig.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/BaseObjectPoolConfig.java?rev=1131510&r1=1131509&r2=1131510&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/BaseObjectPoolConfig.java (original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/BaseObjectPoolConfig.java Sun Jun 5 00:59:46 2011
@@ -23,11 +23,6 @@ package org.apache.commons.pool2.impl;
public abstract class BaseObjectPoolConfig {
/**
- * The default cap on the total number of active instances from the pool.
- */
- public static final int DEFAULT_MAX_TOTAL = 8;
-
- /**
* The default LIFO status. True means that borrowObject returns the most
* recently used ("last in") idle object in the pool (if there are idle
* instances available). False means that the pool behaves as a FIFO queue -
@@ -44,10 +39,6 @@ public abstract class BaseObjectPoolConf
*/
public static final long DEFAULT_MAX_WAIT = -1L;
- /**
- * The default cap on the number of "sleeping" instances in the pool.
- */
- public static final int DEFAULT_MAX_IDLE = 8;
/**
* The default value for {@link #getMinEvictableIdleTimeMillis}.
@@ -56,12 +47,6 @@ public abstract class BaseObjectPoolConf
1000L * 60L * 30L;
/**
- * The default minimum number of "sleeping" instances in the pool before
- * before the evictor thread (if active) spawns new objects.
- */
- public static final int DEFAULT_MIN_IDLE = 0;
-
- /**
* The default number of objects to examine per run in the idle object
* evictor.
*/
@@ -93,20 +78,13 @@ public abstract class BaseObjectPoolConf
public static final WhenExhaustedAction DEFAULT_WHEN_EXHAUSTED_ACTION =
WhenExhaustedAction.BLOCK;
-
- private int maxTotal = DEFAULT_MAX_TOTAL;
-
private boolean lifo = DEFAULT_LIFO;
- private int maxIdle = DEFAULT_MAX_IDLE;
-
private long maxWait = DEFAULT_MAX_WAIT;
private long minEvictableIdleTimeMillis =
DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS;
- private int minIdle = DEFAULT_MIN_IDLE;
-
private int numTestsPerEvictionRun =
DEFAULT_NUM_TESTS_PER_EVICTION_RUN;
@@ -122,15 +100,6 @@ public abstract class BaseObjectPoolConf
private WhenExhaustedAction whenExhaustedAction =
DEFAULT_WHEN_EXHAUSTED_ACTION;
-
- public int getMaxTotal() {
- return maxTotal;
- }
-
- public void setMaxTotal(int maxTotal) {
- this.maxTotal = maxTotal;
- }
-
public boolean getLifo() {
return lifo;
}
@@ -139,14 +108,6 @@ public abstract class BaseObjectPoolConf
this.lifo = lifo;
}
- public int getMaxIdle() {
- return maxIdle;
- }
-
- public void setMaxIdle(int maxIdle) {
- this.maxIdle = maxIdle;
- }
-
public long getMaxWait() {
return maxWait;
}
@@ -163,14 +124,6 @@ public abstract class BaseObjectPoolConf
this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
}
- public int getMinIdle() {
- return minIdle;
- }
-
- public void setMinIdle(int minIdle) {
- this.minIdle = minIdle;
- }
-
public int getNumTestsPerEvictionRun() {
return numTestsPerEvictionRun;
}
Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java?rev=1131510&r1=1131509&r2=1131510&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java (original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java Sun Jun 5 00:59:46 2011
@@ -72,7 +72,7 @@ import org.apache.commons.pool2.PoolUtil
* pools. The default setting for this parameter is -1 (no limit).
*
*
- * {@link #setMaxIdle maxIdle} controls the maximum number of objects that can
+ * {@link #setMaxIdlePerKey maxIdlePerKey} controls the maximum number of objects that can
* sit idle in the pool (per key) at any time. When negative, there
* is no limit to the number of objects that may be idle per key. The
* default setting for this parameter is 8.
@@ -155,7 +155,7 @@ import org.apache.commons.pool2.PoolUtil
* for this parameter is false.
*
*
- * {@link #setMinIdle minIdle} sets a target value for the minimum number of
+ * {@link #setMinIdlePerKey minIdlePerKey} sets a target value for the minimum number of
* idle objects (per key) that should always be available. If this parameter
* is set to a positive number and
* timeBetweenEvictionRunsMillis > 0, each time the idle object
@@ -226,13 +226,13 @@ public class GenericKeyedObjectPool
// Copy the settings from the config
this._factory = config.getFactory();
this._lifo = config.getLifo();
- this._maxIdle = config.getMaxIdle();
+ this.maxIdlePerKey = config.getMaxIdlePerKey();
this._maxTotal = config.getMaxTotal();
this._maxTotalPerKey = config.getMaxTotalPerKey();
this._maxWait = config.getMaxWait();
this._minEvictableIdleTimeMillis =
config.getMinEvictableIdleTimeMillis();
- this._minIdle = config.getMinIdle();
+ this.minIdlePerKey = config.getMinIdlePerKey();
this._numTestsPerEvictionRun = config.getNumTestsPerEvictionRun();
this._testOnBorrow = config.getTestOnBorrow();
this._testOnReturn = config.getTestOnReturn();
@@ -362,10 +362,10 @@ public class GenericKeyedObjectPool
* Returns the cap on the number of "idle" instances per key.
* @return the maximum number of "idle" instances that can be held
* in a given keyed pool.
- * @see #setMaxIdle
+ * @see #setMaxIdlePerKey
*/
- public int getMaxIdle() {
- return _maxIdle;
+ public int getMaxIdlePerKey() {
+ return maxIdlePerKey;
}
/**
@@ -379,11 +379,10 @@ public class GenericKeyedObjectPool
* point.
* @param maxIdle the maximum number of "idle" instances that can be held
* in a given keyed pool. Use a negative value for no limit.
- * @see #getMaxIdle
- * @see BaseObjectPoolConfig#DEFAULT_MAX_IDLE
+ * @see #getMaxIdlePerKey
*/
- public void setMaxIdle(int maxIdle) {
- _maxIdle = maxIdle;
+ public void setMaxIdlePerKey(int maxIdle) {
+ maxIdlePerKey = maxIdle;
}
/**
@@ -394,11 +393,11 @@ public class GenericKeyedObjectPool
* made during idle object eviction runs.
* @param poolSize - The minimum size of the each keyed pool
* @since Pool 1.3
- * @see #getMinIdle
+ * @see #getMinIdlePerKey
* @see #setTimeBetweenEvictionRunsMillis
*/
- public void setMinIdle(int poolSize) {
- _minIdle = poolSize;
+ public void setMinIdlePerKey(int poolSize) {
+ minIdlePerKey = poolSize;
}
/**
@@ -411,8 +410,8 @@ public class GenericKeyedObjectPool
* @since Pool 1.3
* @see #setTimeBetweenEvictionRunsMillis
*/
- public int getMinIdle() {
- return _minIdle;
+ public int getMinIdlePerKey() {
+ return minIdlePerKey;
}
/**
@@ -592,10 +591,10 @@ public class GenericKeyedObjectPool
* @see GenericKeyedObjectPoolConfig
*/
public void setConfig(GenericKeyedObjectPoolConfig conf) {
- setMaxIdle(conf.getMaxIdle());
+ setMaxIdlePerKey(conf.getMaxIdlePerKey());
setMaxTotalPerKey(conf.getMaxTotalPerKey());
setMaxTotal(conf.getMaxTotal());
- setMinIdle(conf.getMinIdle());
+ setMinIdlePerKey(conf.getMinIdlePerKey());
setMaxWait(conf.getMaxWait());
setWhenExhaustedAction(conf.getWhenExhaustedAction());
setTestOnBorrow(conf.getTestOnBorrow());
@@ -781,7 +780,7 @@ public class GenericKeyedObjectPool
* the same object/key pair (with no borrowObject calls in between) will result in multiple
* references to the object in the idle instance pool.
*
- *
If {@link #getMaxIdle() maxIdle} is set to a positive value and the number of idle instances under the given
+ *
If {@link #getMaxIdlePerKey() maxIdle} is set to a positive value and the number of idle instances under the given
* key has reached this value, the returning instance is destroyed.
*
*
If {@link #getTestOnReturn() testOnReturn} == true, the returning instance is validated before being returned
@@ -829,7 +828,7 @@ public class GenericKeyedObjectPool
// TODO - Should not happen;
}
- int maxIdle = getMaxIdle();
+ int maxIdle = getMaxIdlePerKey();
LinkedBlockingDeque> idleObjects =
objectDeque.getIdleObjects();
@@ -1331,7 +1330,7 @@ public class GenericKeyedObjectPool
* @throws Exception If there was an error whilst creating the pooled objects.
*/
private void ensureMinIdle() throws Exception {
- int minIdle = getMinIdle();
+ int minIdle = getMinIdlePerKey();
if (minIdle < 1) {
return;
}
@@ -1354,7 +1353,7 @@ public class GenericKeyedObjectPool
* @throws Exception If there was an error whilst creating the pooled objects
*/
private void ensureMinIdle(K key) throws Exception {
- int minIdle = getMinIdle();
+ int minIdle = getMinIdlePerKey();
if (minIdle < 1) {
return;
}
@@ -1428,7 +1427,7 @@ public class GenericKeyedObjectPool
}
/**
- * Registers a key for pool control and ensures that {@link #getMinIdle()}
+ * Registers a key for pool control and ensures that {@link #getMinIdlePerKey()}
* idle instances are created.
*
* @param key - The key to register for pool control.
@@ -1504,13 +1503,13 @@ public class GenericKeyedObjectPool
private synchronized int calculateDeficit(ObjectDeque objectDeque) {
if (objectDeque == null) {
- return getMinIdle();
+ return getMinIdlePerKey();
}
int objectDefecit = 0;
// Calculate no of objects needed to be created, in order to have
// the number of pooled objects < maxTotalPerKey();
- objectDefecit = getMinIdle() - objectDeque.getIdleObjects().size();
+ objectDefecit = getMinIdlePerKey() - objectDeque.getIdleObjects().size();
if (getMaxTotalPerKey() > 0) {
int growLimit = Math.max(0,
getMaxTotalPerKey() - objectDeque.getIdleObjects().size());
@@ -1596,15 +1595,15 @@ public class GenericKeyedObjectPool
* @see #setMaxIdle
* @see #getMaxIdle
*/
- private int _maxIdle = GenericKeyedObjectPoolConfig.DEFAULT_MAX_IDLE;
+ private int maxIdlePerKey = GenericKeyedObjectPoolConfig.DEFAULT_MAX_IDLE_PER_KEY;
/**
* The minimum no of idle objects per key.
* @see #setMinIdle
* @see #getMinIdle
*/
- private volatile int _minIdle =
- GenericKeyedObjectPoolConfig.DEFAULT_MIN_IDLE;
+ private volatile int minIdlePerKey =
+ GenericKeyedObjectPoolConfig.DEFAULT_MIN_IDLE_PER_KEY;
/**
* The cap on the number of active instances from the pool.
Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPoolConfig.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPoolConfig.java?rev=1131510&r1=1131509&r2=1131510&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPoolConfig.java (original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPoolConfig.java Sun Jun 5 00:59:46 2011
@@ -29,20 +29,37 @@ public class GenericKeyedObjectPoolConfi
public static final int DEFAULT_MAX_TOTAL_PER_KEY = 8;
+ /**
+ * The default maximum number of instances under management
+ * (idle or checked out) across all keyed pools.
+ */
public static final int DEFAULT_MAX_TOTAL = -1;
-
+
+ /**
+ * The default minimum number of idle instances that the maintenance
+ * thread (if enabled) will try to maintain per key.
+ */
+ public static final int DEFAULT_MIN_IDLE_PER_KEY = 0;
+
+ /**
+ * The default maximum number of idle instances per key.
+ */
+ public static final int DEFAULT_MAX_IDLE_PER_KEY = 8;
+
+
+ private int minIdlePerKey = DEFAULT_MIN_IDLE_PER_KEY;
+
+ private int maxIdlePerKey = DEFAULT_MAX_IDLE_PER_KEY;
private int maxTotalPerKey = DEFAULT_MAX_TOTAL_PER_KEY;
+ private int maxTotal = DEFAULT_MAX_TOTAL;
+
private KeyedPoolableObjectFactory factory = null;
-
public GenericKeyedObjectPoolConfig() {
- // Uses a different default for maxTotal
- setMaxTotal(DEFAULT_MAX_TOTAL);
}
-
public KeyedPoolableObjectFactory getFactory() {
return factory;
}
@@ -51,6 +68,14 @@ public class GenericKeyedObjectPoolConfi
this.factory = factory;
}
+ public int getMaxTotal() {
+ return maxTotal;
+ }
+
+ public void setMaxTotal(int maxTotal) {
+ this.maxTotal = maxTotal;
+ }
+
public int getMaxTotalPerKey() {
return maxTotalPerKey;
}
@@ -59,6 +84,22 @@ public class GenericKeyedObjectPoolConfi
this.maxTotalPerKey = maxTotalPerKey;
}
+ public int getMinIdlePerKey() {
+ return minIdlePerKey;
+ }
+
+ public void setMinIdlePerKey(int minIdlePerKey) {
+ this.minIdlePerKey = minIdlePerKey;
+ }
+
+ public int getMaxIdlePerKey() {
+ return maxIdlePerKey;
+ }
+
+ public void setMaxIdlePerKey(int maxIdlePerKey) {
+ this.maxIdlePerKey = maxIdlePerKey;
+ }
+
@SuppressWarnings("unchecked")
@Override
public GenericKeyedObjectPoolConfig clone() {
Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java?rev=1131510&r1=1131509&r2=1131510&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java (original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java Sun Jun 5 00:59:46 2011
@@ -73,7 +73,7 @@ public class TestGenericKeyedObjectPool
new GenericKeyedObjectPool