@@ -150,7 +150,8 @@ protected final MessageDigest initialValue() {
150150
151151 boolean initialized = false ;
152152
153- private int initConn = 1 ;
153+ private int minConn = 8 ;
154+ private int maxConn = 32 ;
154155 private long maxBusyTime = 1000 * 30 ; // max idle time for avail sockets
155156 private long maintSleep = 1000 * 30 ; // maintenance thread sleep time
156157 private int socketTO = 1000 * 30 ; // default timeout of socket reads
@@ -159,7 +160,7 @@ protected final MessageDigest initialValue() {
159160 @ SuppressWarnings ("unused" )
160161 private static int recBufferSize = 128 ;// bufsize
161162
162- private long maxIdle = 1000 * 60 * 5 ; // max idle time for avail sockets
163+ private long maxIdle = 1000 ; // max idle time for avail sockets
163164
164165 private boolean aliveCheck = false ; // default to not check each connection
165166 // for being alive
@@ -193,8 +194,6 @@ protected final MessageDigest initialValue() {
193194
194195 ConcurrentMap <String , Long > hostDeadDur ;
195196
196- private int maxConn = 32 ;
197-
198197 private boolean isTcp ;
199198
200199 private int bufferSize = 1024 * 1025 ;
@@ -311,7 +310,7 @@ private void populateBuckets() {
311310 GenericObjectPool gop ;
312311 SchoonerSockIOFactory factory = new SchoonerSockIOFactory (servers [i ], isTcp , bufferSize , socketTO ,
313312 socketConnectTO , nagle );
314- gop = new GenericObjectPool (factory , maxConn , GenericObjectPool .WHEN_EXHAUSTED_BLOCK , 1000 , maxConn );
313+ gop = new GenericObjectPool (factory , maxConn , GenericObjectPool .WHEN_EXHAUSTED_BLOCK , maxIdle , maxConn );
315314 factory .setSockets (gop );
316315 socketPool .put (servers [i ], gop );
317316 }
@@ -351,7 +350,7 @@ private void populateConsistentBuckets() {
351350 GenericObjectPool gop ;
352351 SchoonerSockIOFactory factory = new SchoonerSockIOFactory (servers [i ], isTcp , bufferSize , socketTO ,
353352 socketConnectTO , nagle );
354- gop = new GenericObjectPool (factory , maxConn , GenericObjectPool .WHEN_EXHAUSTED_BLOCK , 1000 , maxConn );
353+ gop = new GenericObjectPool (factory , maxConn , GenericObjectPool .WHEN_EXHAUSTED_BLOCK , maxIdle , maxConn );
355354 factory .setSockets (gop );
356355 socketPool .put (servers [i ], gop );
357356 }
@@ -558,6 +557,7 @@ protected final void closeSocketPool() {
558557 try {
559558 sockets .close ();
560559 } catch (Exception e ) {
560+ log .error ("++++ failed to close socket pool." );
561561 }
562562 }
563563 }
@@ -577,7 +577,6 @@ public void shutDown() {
577577 buckets = null ;
578578 consistentBuckets = null ;
579579 initialized = false ;
580-
581580 }
582581
583582 /**
@@ -637,7 +636,8 @@ public final Integer[] getWeights() {
637636 * int number of connections
638637 */
639638 public final void setInitConn (int initConn ) {
640- this .initConn = initConn ;
639+ if (initConn < minConn )
640+ minConn = initConn ;
641641 }
642642
643643 /**
@@ -647,7 +647,7 @@ public final void setInitConn(int initConn) {
647647 * @return number of connections
648648 */
649649 public final int getInitConn () {
650- return this .initConn ;
650+ return this .minConn ;
651651 }
652652
653653 /**
@@ -994,11 +994,11 @@ public int getMaxConn() {
994994 }
995995
996996 public void setMinConn (int minConn ) {
997- this .initConn = minConn ;
997+ this .minConn = minConn ;
998998 }
999999
10001000 public int getMinConn () {
1001- return initConn ;
1001+ return minConn ;
10021002 }
10031003
10041004 public void setBufferSize (int bufferSize ) {
0 commit comments