You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ma...@apache.org on 2012/04/29 22:37:19 UTC
svn commit: r1331991 - in /commons/proper/pool/trunk/src:
main/java/org/apache/commons/pool2/impl/
test/java/org/apache/commons/pool2/impl/
Author: markt
Date: Sun Apr 29 20:37:19 2012
New Revision: 1331991
URL: http://svn.apache.org/viewvc?rev=1331991&view=rev
Log:
More maxWait -> maxWaitMillis
Modified:
commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPoolMBean.java
commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
Modified: commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java?rev=1331991&r1=1331990&r2=1331991&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java (original)
+++ commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java Sun Apr 29 20:37:19 2012
@@ -305,8 +305,8 @@ public class GenericKeyedObjectPool<K,T>
* @see #setBlockWhenExhausted
*/
@Override
- public long getMaxWait() {
- return maxWait;
+ public long getMaxWaitMillis() {
+ return maxWaitMillis;
}
/**
@@ -318,12 +318,13 @@ public class GenericKeyedObjectPool<K,T>
* When less than 0, the {@link #borrowObject} method
* may block indefinitely.
*
- * @param maxWait the maximum number of milliseconds borrowObject will block or negative for indefinitely.
+ * @param maxWaitMillis the maximum number of milliseconds borrowObject will
+ * block or negative for indefinitely.
* @see #getMaxWait
* @see #setBlockWhenExhausted
*/
- public void setMaxWait(long maxWait) {
- this.maxWait = maxWait;
+ public void setMaxWaitMillis(long maxWaitMillis) {
+ this.maxWaitMillis = maxWaitMillis;
}
/**
@@ -680,7 +681,7 @@ public class GenericKeyedObjectPool<K,T>
setMaxTotalPerKey(conf.getMaxTotalPerKey());
setMaxTotal(conf.getMaxTotal());
setMinIdlePerKey(conf.getMinIdlePerKey());
- setMaxWait(conf.getMaxWaitMillis());
+ setMaxWaitMillis(conf.getMaxWaitMillis());
setBlockWhenExhausted(conf.getBlockWhenExhausted());
setTestOnBorrow(conf.getTestOnBorrow());
setTestOnReturn(conf.getTestOnReturn());
@@ -719,7 +720,7 @@ public class GenericKeyedObjectPool<K,T>
*
* <p>If there are no idle instances available in the pool associated with the given key, behavior
* depends on the {@link #getMaxTotalPerKey() maxTotalPerKey}, {@link #getMaxTotal() maxTotal}, and (if applicable)
- * {@link #getBlockWhenExhausted()} and {@link #getMaxWait() maxWait} settings. If the
+ * {@link #getBlockWhenExhausted()} and {@link #getMaxWaitMillis() maxWait} settings. If the
* number of instances checked out from the pool under the given key is less than <code>maxTotalPerKey</code> and
* the total number of instances in circulation (under all keys) is less than <code>maxTotal</code>, a new instance
* is created, activated and (if applicable) validated and returned to the caller.</p>
@@ -728,7 +729,7 @@ public class GenericKeyedObjectPool<K,T>
* this method will either block ({@link #getBlockWhenExhausted()} is true) or throw a <code>NoSuchElementException</code>
* ({@link #getBlockWhenExhausted()} is false).
* The length of time that this method will block when {@link #getBlockWhenExhausted()} is true
- * is determined by the {@link #getMaxWait() maxWait} property.</p>
+ * is determined by the {@link #getMaxWaitMillis() maxWait} property.</p>
*
* When <code>maxTotal</code> is set to a
* positive value and {@link #borrowObject borrowObject} is invoked
@@ -746,7 +747,7 @@ public class GenericKeyedObjectPool<K,T>
*/
@Override
public T borrowObject(K key) throws Exception {
- return borrowObject(key, getMaxWait());
+ return borrowObject(key, getMaxWaitMillis());
}
/**
@@ -2056,7 +2057,7 @@ public class GenericKeyedObjectPool<K,T>
* @see #setBlockWhenExhausted
* @see #getBlockWhenExhausted
*/
- private long maxWait = GenericKeyedObjectPoolConfig.DEFAULT_MAX_WAIT_MILLIS;
+ private long maxWaitMillis = GenericKeyedObjectPoolConfig.DEFAULT_MAX_WAIT_MILLIS;
/**
* When <code>true</code>, objects will be
Modified: commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPoolMBean.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPoolMBean.java?rev=1331991&r1=1331990&r2=1331991&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPoolMBean.java (original)
+++ commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPoolMBean.java Sun Apr 29 20:37:19 2012
@@ -31,7 +31,7 @@ public interface GenericKeyedObjectPoolM
int getMaxIdlePerKey();
int getMaxTotal();
int getMaxTotalPerKey();
- long getMaxWait();
+ long getMaxWaitMillis();
long getMinEvictableIdleTimeMillis();
int getMinIdlePerKey();
int getNumActive();
Modified: commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java?rev=1331991&r1=1331990&r2=1331991&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java (original)
+++ commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java Sun Apr 29 20:37:19 2012
@@ -130,7 +130,7 @@ public class TestGenericKeyedObjectPool
pool.close();
pool = null;
factory = null;
-
+
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
Set<ObjectName> result = mbs.queryNames(new ObjectName(
"org.apache.commoms.pool2:type=GenericKeyedObjectPool,*"),
@@ -383,8 +383,8 @@ public class TestGenericKeyedObjectPool
assertEquals(12,pool.getMaxIdlePerKey());
}
{
- pool.setMaxWait(1234L);
- assertEquals(1234L,pool.getMaxWait());
+ pool.setMaxWaitMillis(1234L);
+ assertEquals(1234L,pool.getMaxWaitMillis());
}
{
pool.setMinEvictableIdleTimeMillis(12345L);
@@ -549,7 +549,7 @@ public class TestGenericKeyedObjectPool
public void testThreaded1() throws Exception {
pool.setMaxTotalPerKey(15);
pool.setMaxIdlePerKey(15);
- pool.setMaxWait(1000L);
+ pool.setMaxWaitMillis(1000L);
runTestThreads(20, 100, 50, pool);
}
@@ -568,7 +568,7 @@ public class TestGenericKeyedObjectPool
pool.setMaxTotal(maxTotal);
pool.setMaxIdlePerKey(-1);
pool.setTestOnReturn(true);
- pool.setMaxWait(10000L);
+ pool.setMaxWaitMillis(10000L);
runTestThreads(5, 10, 50, pool);
}
@@ -1051,7 +1051,7 @@ public class TestGenericKeyedObjectPool
new GenericKeyedObjectPool<Object,Object>(null);
assertEquals(GenericKeyedObjectPoolConfig.DEFAULT_MAX_TOTAL_PER_KEY, pool.getMaxTotalPerKey());
assertEquals(GenericKeyedObjectPoolConfig.DEFAULT_MAX_IDLE_PER_KEY, pool.getMaxIdlePerKey());
- assertEquals(GenericKeyedObjectPoolConfig.DEFAULT_MAX_WAIT_MILLIS, pool.getMaxWait());
+ assertEquals(GenericKeyedObjectPoolConfig.DEFAULT_MAX_WAIT_MILLIS, pool.getMaxWaitMillis());
assertEquals(GenericKeyedObjectPoolConfig.DEFAULT_MIN_IDLE_PER_KEY, pool.getMinIdlePerKey());
assertEquals(GenericKeyedObjectPoolConfig.DEFAULT_MAX_TOTAL, pool.getMaxTotal());
assertEquals(GenericKeyedObjectPoolConfig.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,
@@ -1089,7 +1089,7 @@ public class TestGenericKeyedObjectPool
pool = new GenericKeyedObjectPool<Object,Object>(null, config);
assertEquals(maxTotalPerKey, pool.getMaxTotalPerKey());
assertEquals(maxIdle, pool.getMaxIdlePerKey());
- assertEquals(maxWait, pool.getMaxWait());
+ assertEquals(maxWait, pool.getMaxWaitMillis());
assertEquals(minIdle, pool.getMinIdlePerKey());
assertEquals(maxTotal, pool.getMaxTotal());
assertEquals(minEvictableIdleTimeMillis,
@@ -1186,7 +1186,7 @@ public class TestGenericKeyedObjectPool
@Test(timeout=60000)
public void testBlockedKeyDoesNotBlockPool() throws Exception {
pool.setBlockWhenExhausted(true);
- pool.setMaxWait(5000);
+ pool.setMaxWaitMillis(5000);
pool.setMaxTotalPerKey(1);
pool.setMaxTotal(-1);
pool.borrowObject("one");
@@ -1229,7 +1229,7 @@ public class TestGenericKeyedObjectPool
final int keyCount = 4; // number of different keys
final int threadsPerKey = 5; // number of threads to grab the key initially
pool.setBlockWhenExhausted(true);
- pool.setMaxWait(maxWait);
+ pool.setMaxWaitMillis(maxWait);
pool.setMaxTotalPerKey(threadsPerKey);
// Create enough threads so half the threads will have to wait
WaitingTestThread wtt[] = new WaitingTestThread[keyCount * threadsPerKey * 2];
@@ -1286,7 +1286,7 @@ public class TestGenericKeyedObjectPool
pool.setMaxTotal(8);
pool.setTestOnBorrow(true);
pool.setMaxIdlePerKey(5);
- pool.setMaxWait(-1);
+ pool.setMaxWaitMillis(-1);
runTestThreads(20, 300, 250, pool);
pool.close();
}
@@ -1335,7 +1335,7 @@ public class TestGenericKeyedObjectPool
pool.setMaxIdlePerKey(3);
pool.setMaxTotal(3);
pool.setMaxTotalPerKey(3);
- pool.setMaxWait(3000); // Really a timeout for the test
+ pool.setMaxWaitMillis(3000); // Really a timeout for the test
// Check out and briefly hold 3 "1"s
WaitingTestThread t1 = new WaitingTestThread(pool, "1", 100);
@@ -1390,7 +1390,7 @@ public class TestGenericKeyedObjectPool
new GenericKeyedObjectPool<String,String>(factory);
pool.setMaxTotalPerKey(1);
pool.setBlockWhenExhausted(true);
- pool.setMaxWait(-1);
+ pool.setMaxWaitMillis(-1);
String obj1 = pool.borrowObject("a");
// Make sure an object was obtained
@@ -1695,7 +1695,7 @@ public class TestGenericKeyedObjectPool
Set<ObjectName> result = mbs.queryNames(oname, null);
Assert.assertEquals(1, result.size());
}
-
+
@Test(timeout=60000)
public void testJmxNotification() throws Exception {
factory.setThrowExceptionOnPassivate(true);
@@ -1703,25 +1703,25 @@ public class TestGenericKeyedObjectPool
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
JmxNotificationListener listener = new JmxNotificationListener();
mbs.addNotificationListener(oname, listener, null, null);
-
+
String obj = pool.borrowObject("one");
pool.returnObject("one", obj);
-
+
List<String> messages = listener.getMessages();
Assert.assertEquals(1, messages.size());
Assert.assertNotNull(messages.get(0));
Assert.assertTrue(messages.get(0).length() > 0);
}
-
+
private static class JmxNotificationListener
implements NotificationListener {
private List<String> messages = new ArrayList<String>();
-
+
public List<String> getMessages() {
return messages;
}
-
+
@Override
public void handleNotification(Notification notification,
Object handback) {