commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 22597] New: - minIdle Functionality
Date Wed, 20 Aug 2003 19:25:04 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22597>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22597

minIdle Functionality

           Summary: minIdle Functionality
           Product: Commons
           Version: Nightly Builds
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: Pool
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: wareing@rewc.com


This function allows the pool to maintain a minimum level of idle connections 
in the pool once an instance of the evictor thread is started.  Mainly designed 
for the DBCP package however it should work for any object.  

This really comes in handy for those of you with databases that must go down 
for backup and don't wish to have you first few users delayed by long waits 
(possibly on high latency connections) while the DBCP creates new connections.  
With this patch the object pooler recreate those object automagically as soon 
as the database comes up.

Here's the required patches (against the nightly build on Aug 14, 2003):

--- GenericObjectPool.java.orig	2003-08-14 03:20:32.000000000 -0500
+++ GenericObjectPool.java	2003-08-14 17:34:28.000000000 -0500
@@ -286,13 +286,20 @@
      */
     public static final long DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS = 1000L * 
60L * 30L;
 
+    /**
+     * The default value for {@link #getMinIdle}.
+     * @see #getMinIdle
+     * @see #setMinIdle
+     */
+    public static final int DEFAULT_MIN_IDLE = 0;
+
     //--- constructors -----------------------------------------------
 
     /**
      * Create a new <tt>GenericObjectPool</tt>.
      */
     public GenericObjectPool() {
-        this
(null,DEFAULT_MAX_ACTIVE,DEFAULT_WHEN_EXHAUSTED_ACTION,DEFAULT_MAX_WAIT,DEFAULT_
MAX_IDLE,DEFAULT_TEST_ON_BORROW,DEFAULT_TEST_ON_RETURN,DEFAULT_TIME_BETWEEN_EVIC
TION_RUNS_MILLIS,DEFAULT_NUM_TESTS_PER_EVICTION_RUN,DEFAULT_MIN_EVICTABLE_IDLE_T
IME_MILLIS,DEFAULT_TEST_WHILE_IDLE);
+        this
(null,DEFAULT_MAX_ACTIVE,DEFAULT_WHEN_EXHAUSTED_ACTION,DEFAULT_MAX_WAIT,DEFAULT_
MAX_IDLE,DEFAULT_MIN_IDLE,DEFAULT_TEST_ON_BORROW,DEFAULT_TEST_ON_RETURN,DEFAULT_
TIME_BETWEEN_EVICTION_RUNS_MILLIS,DEFAULT_NUM_TESTS_PER_EVICTION_RUN,DEFAULT_MIN
_EVICTABLE_IDLE_TIME_MILLIS,DEFAULT_TEST_WHILE_IDLE);
     }
 
     /**
@@ -300,7 +307,7 @@
      * @param factory the (possibly <tt>null</tt>)PoolableObjectFactory to use

to create, validate and destroy objects
      */
     public GenericObjectPool(PoolableObjectFactory factory) {
-        this
(factory,DEFAULT_MAX_ACTIVE,DEFAULT_WHEN_EXHAUSTED_ACTION,DEFAULT_MAX_WAIT,DEFAU
LT_MAX_IDLE,DEFAULT_TEST_ON_BORROW,DEFAULT_TEST_ON_RETURN,DEFAULT_TIME_BETWEEN_E
VICTION_RUNS_MILLIS,DEFAULT_NUM_TESTS_PER_EVICTION_RUN,DEFAULT_MIN_EVICTABLE_IDL
E_TIME_MILLIS,DEFAULT_TEST_WHILE_IDLE);
+        this
(factory,DEFAULT_MAX_ACTIVE,DEFAULT_WHEN_EXHAUSTED_ACTION,DEFAULT_MAX_WAIT,DEFAU
LT_MAX_IDLE,DEFAULT_MIN_IDLE,DEFAULT_TEST_ON_BORROW,DEFAULT_TEST_ON_RETURN,DEFAU
LT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,DEFAULT_NUM_TESTS_PER_EVICTION_RUN,DEFAULT_
MIN_EVICTABLE_IDLE_TIME_MILLIS,DEFAULT_TEST_WHILE_IDLE);
     }
 
     /**
@@ -309,7 +316,7 @@
      * @param config a non-<tt>null</tt> {@link GenericObjectPool.Config} 
describing my configuration
      */
     public GenericObjectPool(PoolableObjectFactory factory, 
GenericObjectPool.Config config) {
-        this
(factory,config.maxActive,config.whenExhaustedAction,config.maxWait,config.maxId
le,config.testOnBorrow,config.testOnReturn,config.timeBetweenEvictionRunsMillis,
config.numTestsPerEvictionRun,config.minEvictableIdleTimeMillis,config.testWhile
Idle);
+        this
(factory,config.maxActive,config.whenExhaustedAction,config.maxWait,config.maxId
le,DEFAULT_MIN_IDLE,config.testOnBorrow,config.testOnReturn,config.timeBetweenEv
ictionRunsMillis,config.numTestsPerEvictionRun,config.minEvictableIdleTimeMillis
,config.testWhileIdle);
     }
 
     /**
@@ -318,7 +325,7 @@
      * @param maxActive the maximum number of objects that can be borrowed 
from me at one time (see {@link #setMaxActive})
      */
     public GenericObjectPool(PoolableObjectFactory factory, int maxActive) {
-        this
(factory,maxActive,DEFAULT_WHEN_EXHAUSTED_ACTION,DEFAULT_MAX_WAIT,DEFAULT_MAX_ID
LE,DEFAULT_TEST_ON_BORROW,DEFAULT_TEST_ON_RETURN,DEFAULT_TIME_BETWEEN_EVICTION_R
UNS_MILLIS,DEFAULT_NUM_TESTS_PER_EVICTION_RUN,DEFAULT_MIN_EVICTABLE_IDLE_TIME_MI
LLIS,DEFAULT_TEST_WHILE_IDLE);
+        this
(factory,maxActive,DEFAULT_WHEN_EXHAUSTED_ACTION,DEFAULT_MAX_WAIT,DEFAULT_MAX_ID
LE,DEFAULT_MIN_IDLE,DEFAULT_TEST_ON_BORROW,DEFAULT_TEST_ON_RETURN,DEFAULT_TIME_B
ETWEEN_EVICTION_RUNS_MILLIS,DEFAULT_NUM_TESTS_PER_EVICTION_RUN,DEFAULT_MIN_EVICT
ABLE_IDLE_TIME_MILLIS,DEFAULT_TEST_WHILE_IDLE);
     }
 
     /**
@@ -329,7 +336,7 @@
      * @param maxWait the maximum amount of time to wait for an idle object 
when the pool is exhausted an and <i>whenExhaustedAction</i> is {@link 
#WHEN_EXHAUSTED_BLOCK} (otherwise ignored) (see {@link #getMaxWait})
      */
     public GenericObjectPool(PoolableObjectFactory factory, int maxActive, 
byte whenExhaustedAction, long maxWait) {
-        this
(factory,maxActive,whenExhaustedAction,maxWait,DEFAULT_MAX_IDLE,DEFAULT_TEST_ON_
BORROW,DEFAULT_TEST_ON_RETURN,DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,DEFAULT_
NUM_TESTS_PER_EVICTION_RUN,DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,DEFAULT_TEST_W
HILE_IDLE);
+        this
(factory,maxActive,whenExhaustedAction,maxWait,DEFAULT_MAX_IDLE,DEFAULT_MIN_IDLE
,DEFAULT_TEST_ON_BORROW,DEFAULT_TEST_ON_RETURN,DEFAULT_TIME_BETWEEN_EVICTION_RUN
S_MILLIS,DEFAULT_NUM_TESTS_PER_EVICTION_RUN,DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILL
IS,DEFAULT_TEST_WHILE_IDLE);
     }
 
     /**
@@ -342,7 +349,7 @@
      * @param testOnReturn whether or not to validate objects after they are 
returned to the {@link #returnObject} method (see {@link #getTestOnReturn})
      */
     public GenericObjectPool(PoolableObjectFactory factory, int maxActive, 
byte whenExhaustedAction, long maxWait, boolean testOnBorrow, boolean 
testOnReturn) {
-        this
(factory,maxActive,whenExhaustedAction,maxWait,DEFAULT_MAX_IDLE,testOnBorrow,tes
tOnReturn,DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,DEFAULT_NUM_TESTS_PER_EVICTI
ON_RUN,DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,DEFAULT_TEST_WHILE_IDLE);
+        this
(factory,maxActive,whenExhaustedAction,maxWait,DEFAULT_MAX_IDLE,DEFAULT_MIN_IDLE
,testOnBorrow,testOnReturn,DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,DEFAULT_NUM
_TESTS_PER_EVICTION_RUN,DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,DEFAULT_TEST_WHIL
E_IDLE);
     }
 
     /**
@@ -354,7 +361,7 @@
      * @param maxIdle the maximum number of idle objects in my pool (see 
{@link #getMaxIdle})
      */
     public GenericObjectPool(PoolableObjectFactory factory, int maxActive, 
byte whenExhaustedAction, long maxWait, int maxIdle) {
-        this
(factory,maxActive,whenExhaustedAction,maxWait,maxIdle,DEFAULT_TEST_ON_BORROW,DE
FAULT_TEST_ON_RETURN,DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,DEFAULT_NUM_TESTS
_PER_EVICTION_RUN,DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,DEFAULT_TEST_WHILE_IDLE
);
+        this
(factory,maxActive,whenExhaustedAction,maxWait,maxIdle,DEFAULT_MIN_IDLE,DEFAULT_
TEST_ON_BORROW,DEFAULT_TEST_ON_RETURN,DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,
DEFAULT_NUM_TESTS_PER_EVICTION_RUN,DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,DEFAUL
T_TEST_WHILE_IDLE);
     }
 
     /**
@@ -368,7 +375,7 @@
      * @param testOnReturn whether or not to validate objects after they are 
returned to the {@link #returnObject} method (see {@link #getTestOnReturn})
      */
     public GenericObjectPool(PoolableObjectFactory factory, int maxActive, 
byte whenExhaustedAction, long maxWait, int maxIdle, boolean testOnBorrow, 
boolean testOnReturn) {
-        this
(factory,maxActive,whenExhaustedAction,maxWait,maxIdle,testOnBorrow,testOnReturn
,DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,DEFAULT_NUM_TESTS_PER_EVICTION_RUN,DE
FAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,DEFAULT_TEST_WHILE_IDLE);
+        this
(factory,maxActive,whenExhaustedAction,maxWait,maxIdle,DEFAULT_MIN_IDLE,testOnBo
rrow,testOnReturn,DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,DEFAULT_NUM_TESTS_PE
R_EVICTION_RUN,DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,DEFAULT_TEST_WHILE_IDLE);
     }
 
     /**
@@ -385,7 +392,7 @@
      * @param minEvictableIdleTimeMillis the minimum number of milliseconds an 
object can sit idle in the pool before it is eligable for evcition (see {@link 
#setMinEvictableIdleTimeMillis})
      * @param testWhileIdle whether or not to validate objects in the idle 
object eviction thread, if any (see {@link #setTestWhileIdle})
      */
-    public GenericObjectPool(PoolableObjectFactory factory, int maxActive, 
byte whenExhaustedAction, long maxWait, int maxIdle, boolean testOnBorrow, 
boolean testOnReturn, long timeBetweenEvictionRunsMillis, int 
numTestsPerEvictionRun, long minEvictableIdleTimeMillis, boolean testWhileIdle) 
{
+    public GenericObjectPool(PoolableObjectFactory factory, int maxActive, 
byte whenExhaustedAction, long maxWait, int maxIdle, int minIdle, boolean 
testOnBorrow, boolean testOnReturn, long timeBetweenEvictionRunsMillis, int 
numTestsPerEvictionRun, long minEvictableIdleTimeMillis, boolean testWhileIdle) 
{
         _factory = factory;
         _maxActive = maxActive;
         switch(whenExhaustedAction) {
@@ -399,6 +406,7 @@
         }
         _maxWait = maxWait;
         _maxIdle = maxIdle;
+        _minIdle = minIdle;
         _testOnBorrow = testOnBorrow;
         _testOnReturn = testOnReturn;
         _timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
@@ -532,6 +540,21 @@
     }
 
     /**
+     * Sets the cap on the number of "idle" instances in the pool.
+     * @param minIdle The minimum number of connections The cap on the number 
of "idle" instances in the pool.
+     *                Use a negative value to indicate an unlimited number
+     *                of idle instances.
+     * @see #getMaxIdle
+     */
+    public void setMinIdle(int minIdle) {
+        _minIdle = minIdle;
+        synchronized(this) {
+            notifyAll();
+        }
+    }
+    
+    
+    /**
      * When <tt>true</tt>, objects will be
      * {@link PoolableObjectFactory#validateObject validated}
      * before being returned by the {@link #borrowObject}
@@ -647,6 +670,19 @@
     }
 
     /**
+     * Returns the minimum number of objects allowed in the pool
+     * before the evictor thread (if active) spawns new objects.
+     * (if any).
+     *
+     * @see #setMinIdle
+     * @see #getMinIdle
+     */
+    public synchronized int getMinIdle() {
+        return _minIdle;
+    }
+    
+    
+    /**
      * Sets the minimum amount of time an object may sit idle in the pool
      * before it is eligable for eviction by the idle object evictor
      * (if any).
@@ -968,8 +1004,18 @@
                         }
                     }
                 }
-            }
-        }
+            } 
+        } 
+
+        // Check to see if we are below our minimum number of objects
+        // if so enough to bring us back to our minimum.
+        int objectDeficit = getNumIdle() - _minIdle;
+        if ( objectDeficit < 0 ) {
+            for ( int j = 0; j < Math.abs(objectDeficit); j++ ) {
+                addObject();
+            } // for
+        } // if
+
     }
 
     /**
@@ -1092,6 +1138,7 @@
      */
     public static class Config {
         public int maxIdle = GenericObjectPool.DEFAULT_MAX_IDLE;
+        public int minIdle = GenericObjectPool.DEFAULT_MIN_IDLE;
         public int maxActive = GenericObjectPool.DEFAULT_MAX_ACTIVE;
         public long maxWait = GenericObjectPool.DEFAULT_MAX_WAIT;
         public byte whenExhaustedAction = 
GenericObjectPool.DEFAULT_WHEN_EXHAUSTED_ACTION;
@@ -1113,6 +1160,14 @@
     private int _maxIdle = DEFAULT_MAX_IDLE;
 
     /**
+     * The cap on the minimum number of idle instances in the pool.
+     * @see #setMinIdle
+     * @see #getMinIdle
+     */
+    private int _minIdle = DEFAULT_MIN_IDLE;
+    
+    
+    /**
      * The cap on the total number of active instances from the pool.
      * @see #setMaxActive
      * @see #getMaxActive


--- GenericObjectPoolFactory.java.orig	2003-08-14 03:20:32.000000000 -0500
+++ GenericObjectPoolFactory.java	2003-08-14 15:30:52.000000000 -0500
@@ -76,35 +76,36 @@
  */
 public class GenericObjectPoolFactory implements ObjectPoolFactory {
     public GenericObjectPoolFactory(PoolableObjectFactory factory) {
-        this
(factory,GenericObjectPool.DEFAULT_MAX_ACTIVE,GenericObjectPool.DEFAULT_WHEN_EXH
AUSTED_ACTION,GenericObjectPool.DEFAULT_MAX_WAIT,GenericObjectPool.DEFAULT_MAX_I
DLE,GenericObjectPool.DEFAULT_TEST_ON_BORROW,GenericObjectPool.DEFAULT_TEST_ON_R
ETURN,GenericObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,GenericObjectP
ool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN,GenericObjectPool.DEFAULT_MIN_EVICTABLE_I
DLE_TIME_MILLIS,GenericObjectPool.DEFAULT_TEST_WHILE_IDLE);
+        this
(factory,GenericObjectPool.DEFAULT_MAX_ACTIVE,GenericObjectPool.DEFAULT_WHEN_EXH
AUSTED_ACTION,GenericObjectPool.DEFAULT_MAX_WAIT,GenericObjectPool.DEFAULT_MAX_I
DLE,GenericObjectPool.DEFAULT_MIN_IDLE,GenericObjectPool.DEFAULT_TEST_ON_BORROW,
GenericObjectPool.DEFAULT_TEST_ON_RETURN,GenericObjectPool.DEFAULT_TIME_BETWEEN_
EVICTION_RUNS_MILLIS,GenericObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN,Generi
cObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,GenericObjectPool.DEFAULT_TES
T_WHILE_IDLE);
     }
 
     public GenericObjectPoolFactory(PoolableObjectFactory factory, 
GenericObjectPool.Config config) {
-        this
(factory,config.maxActive,config.whenExhaustedAction,config.maxWait,config.maxId
le,config.testOnBorrow,config.testOnReturn,config.timeBetweenEvictionRunsMillis,
config.numTestsPerEvictionRun,config.minEvictableIdleTimeMillis,config.testWhile
Idle);
+        this
(factory,config.maxActive,config.whenExhaustedAction,config.maxWait,config.maxId
le,GenericObjectPool.DEFAULT_MAX_IDLE,config.testOnBorrow,config.testOnReturn,co
nfig.timeBetweenEvictionRunsMillis,config.numTestsPerEvictionRun,config.minEvict
ableIdleTimeMillis,config.testWhileIdle);
     }
 
     public GenericObjectPoolFactory(PoolableObjectFactory factory, int 
maxActive) {
-        this
(factory,maxActive,GenericObjectPool.DEFAULT_WHEN_EXHAUSTED_ACTION,GenericObject
Pool.DEFAULT_MAX_WAIT,GenericObjectPool.DEFAULT_MAX_IDLE,GenericObjectPool.DEFAU
LT_TEST_ON_BORROW,GenericObjectPool.DEFAULT_TEST_ON_RETURN,GenericObjectPool.DEF
AULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,GenericObjectPool.DEFAULT_NUM_TESTS_PER_E
VICTION_RUN,GenericObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,GenericObje
ctPool.DEFAULT_TEST_WHILE_IDLE);
+        this
(factory,maxActive,GenericObjectPool.DEFAULT_WHEN_EXHAUSTED_ACTION,GenericObject
Pool.DEFAULT_MAX_WAIT,GenericObjectPool.DEFAULT_MAX_IDLE,GenericObjectPool.DEFAU
LT_MAX_IDLE,GenericObjectPool.DEFAULT_TEST_ON_BORROW,GenericObjectPool.DEFAULT_T
EST_ON_RETURN,GenericObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,Generi
cObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN,GenericObjectPool.DEFAULT_MIN_EVI
CTABLE_IDLE_TIME_MILLIS,GenericObjectPool.DEFAULT_TEST_WHILE_IDLE);
     }
 
     public GenericObjectPoolFactory(PoolableObjectFactory factory, int 
maxActive, byte whenExhaustedAction, long maxWait) {
-        this
(factory,maxActive,whenExhaustedAction,maxWait,GenericObjectPool.DEFAULT_MAX_IDL
E,GenericObjectPool.DEFAULT_TEST_ON_BORROW,GenericObjectPool.DEFAULT_TEST_ON_RET
URN,GenericObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,GenericObjectPoo
l.DEFAULT_NUM_TESTS_PER_EVICTION_RUN,GenericObjectPool.DEFAULT_MIN_EVICTABLE_IDL
E_TIME_MILLIS,GenericObjectPool.DEFAULT_TEST_WHILE_IDLE);
+        this
(factory,maxActive,whenExhaustedAction,maxWait,GenericObjectPool.DEFAULT_MAX_IDL
E,GenericObjectPool.DEFAULT_MAX_IDLE,GenericObjectPool.DEFAULT_TEST_ON_BORROW,Ge
nericObjectPool.DEFAULT_TEST_ON_RETURN,GenericObjectPool.DEFAULT_TIME_BETWEEN_EV
ICTION_RUNS_MILLIS,GenericObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN,GenericO
bjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,GenericObjectPool.DEFAULT_TEST_
WHILE_IDLE);
     }
 
     public GenericObjectPoolFactory(PoolableObjectFactory factory, int 
maxActive, byte whenExhaustedAction, long maxWait, boolean testOnBorrow, 
boolean testOnReturn) {
-        this
(factory,maxActive,whenExhaustedAction,maxWait,GenericObjectPool.DEFAULT_MAX_IDL
E,testOnBorrow,testOnReturn,GenericObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS
_MILLIS,GenericObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN,GenericObjectPool.D
EFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,GenericObjectPool.DEFAULT_TEST_WHILE_IDLE)
;
+        this
(factory,maxActive,whenExhaustedAction,maxWait,GenericObjectPool.DEFAULT_MAX_IDL
E,GenericObjectPool.DEFAULT_MAX_IDLE,testOnBorrow,testOnReturn,GenericObjectPool
.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,GenericObjectPool.DEFAULT_NUM_TESTS_P
ER_EVICTION_RUN,GenericObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,Generic
ObjectPool.DEFAULT_TEST_WHILE_IDLE);
     }
 
     public GenericObjectPoolFactory(PoolableObjectFactory factory, int 
maxActive, byte whenExhaustedAction, long maxWait, int maxIdle) {
-        this
(factory,maxActive,whenExhaustedAction,maxWait,maxIdle,GenericObjectPool.DEFAULT
_TEST_ON_BORROW,GenericObjectPool.DEFAULT_TEST_ON_RETURN,GenericObjectPool.DEFAU
LT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,GenericObjectPool.DEFAULT_NUM_TESTS_PER_EVI
CTION_RUN,GenericObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,GenericObject
Pool.DEFAULT_TEST_WHILE_IDLE);
+        this
(factory,maxActive,whenExhaustedAction,maxWait,maxIdle,GenericObjectPool.DEFAULT
_MAX_IDLE,GenericObjectPool.DEFAULT_TEST_ON_BORROW,GenericObjectPool.DEFAULT_TES
T_ON_RETURN,GenericObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,GenericO
bjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN,GenericObjectPool.DEFAULT_MIN_EVICT
ABLE_IDLE_TIME_MILLIS,GenericObjectPool.DEFAULT_TEST_WHILE_IDLE);
     }
 
     public GenericObjectPoolFactory(PoolableObjectFactory factory, int 
maxActive, byte whenExhaustedAction, long maxWait, int maxIdle, boolean 
testOnBorrow, boolean testOnReturn) {
-        this
(factory,maxActive,whenExhaustedAction,maxWait,maxIdle,testOnBorrow,testOnReturn
,GenericObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,GenericObjectPool.D
EFAULT_NUM_TESTS_PER_EVICTION_RUN,GenericObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_T
IME_MILLIS,GenericObjectPool.DEFAULT_TEST_WHILE_IDLE);
+        this
(factory,maxActive,whenExhaustedAction,maxWait,maxIdle,GenericObjectPool.DEFAULT
_MAX_IDLE,testOnBorrow,testOnReturn,GenericObjectPool.DEFAULT_TIME_BETWEEN_EVICT
ION_RUNS_MILLIS,GenericObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN,GenericObje
ctPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,GenericObjectPool.DEFAULT_TEST_WHI
LE_IDLE);
     }
 
-    public GenericObjectPoolFactory(PoolableObjectFactory factory, int 
maxActive, byte whenExhaustedAction, long maxWait, int maxIdle, boolean 
testOnBorrow, boolean testOnReturn, long timeBetweenEvictionRunsMillis, int 
numTestsPerEvictionRun, long minEvictableIdleTimeMillis, boolean testWhileIdle) 
{
+    public GenericObjectPoolFactory(PoolableObjectFactory factory, int 
maxActive, byte whenExhaustedAction, long maxWait, int maxIdle,  int minIdle, 
boolean testOnBorrow, boolean testOnReturn, long timeBetweenEvictionRunsMillis, 
int numTestsPerEvictionRun, long minEvictableIdleTimeMillis, boolean 
testWhileIdle) {
         _maxIdle = maxIdle;
+        _minIdle = minIdle;
         _maxActive = maxActive;
         _maxWait = maxWait;
         _whenExhaustedAction = whenExhaustedAction;
@@ -118,10 +119,11 @@
     }
 
     public ObjectPool createPool() {
-        return new GenericObjectPool
(_factory,_maxActive,_whenExhaustedAction,_maxWait,_maxIdle,_testOnBorrow,_testO
nReturn,_timeBetweenEvictionRunsMillis,_numTestsPerEvictionRun,_minEvictableIdle
TimeMillis,_testWhileIdle);
+        return new GenericObjectPool
(_factory,_maxActive,_whenExhaustedAction,_maxWait,_maxIdle,_minIdle,_testOnBorr
ow,_testOnReturn,_timeBetweenEvictionRunsMillis,_numTestsPerEvictionRun,_minEvic
tableIdleTimeMillis,_testWhileIdle);
     }
 
     protected int _maxIdle = GenericObjectPool.DEFAULT_MAX_IDLE;
+    protected int _minIdle = GenericObjectPool.DEFAULT_MIN_IDLE;
     protected int _maxActive = GenericObjectPool.DEFAULT_MAX_ACTIVE;
     protected long _maxWait = GenericObjectPool.DEFAULT_MAX_WAIT;
     protected byte _whenExhaustedAction = 
GenericObjectPool.DEFAULT_WHEN_EXHAUSTED_ACTION;

Mime
View raw message