You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2011/08/05 11:24:23 UTC

svn commit: r1154136 - in /httpcomponents/httpcore/trunk: httpcore-nio/src/main/java/org/apache/http/nio/pool/ httpcore-nio/src/test/java/org/apache/http/nio/pool/ httpcore/src/main/java/org/apache/http/pool/ httpcore/src/test/java/org/apache/http/pool/

Author: olegk
Date: Fri Aug  5 09:24:22 2011
New Revision: 1154136

URL: http://svn.apache.org/viewvc?rev=1154136&view=rev
Log:
Fixed inconsistencies in pool control API

Modified:
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/pool/TestNIOConnPool.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/pool/AbstractConnPool.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/pool/ConnPoolControl.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/pool/TestConnPool.java

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java?rev=1154136&r1=1154135&r2=1154136&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java Fri Aug  5 09:24:22 2011
@@ -46,10 +46,11 @@ import org.apache.http.nio.reactor.Conne
 import org.apache.http.nio.reactor.IOSession;
 import org.apache.http.nio.reactor.SessionRequest;
 import org.apache.http.nio.reactor.SessionRequestCallback;
+import org.apache.http.pool.ConnPoolControl;
 import org.apache.http.pool.PoolEntry;
 import org.apache.http.pool.PoolStats;
 
-public abstract class AbstractNIOConnPool<T, C, E extends PoolEntry<T, C>> {
+public abstract class AbstractNIOConnPool<T, C, E extends PoolEntry<T, C>> implements ConnPoolControl<T> {
 
     private final ConnectingIOReactor ioreactor;
     private final SessionRequestCallback sessionRequestCallback;
@@ -359,7 +360,7 @@ public abstract class AbstractNIOConnPoo
         }
     }
 
-    public void setTotalMax(int max) {
+    public void setMaxTotal(int max) {
         if (max <= 0) {
             throw new IllegalArgumentException("Max value may not be negative or zero");
         }
@@ -371,7 +372,7 @@ public abstract class AbstractNIOConnPoo
         }
     }
 
-    public void setDefaultMaxPerHost(int max) {
+    public void setDefaultMaxPerRoute(int max) {
         if (max <= 0) {
             throw new IllegalArgumentException("Max value may not be negative or zero");
         }
@@ -383,7 +384,7 @@ public abstract class AbstractNIOConnPoo
         }
     }
 
-    public void setMaxPerHost(final T route, int max) {
+    public void setMaxPerRoute(final T route, int max) {
         if (route == null) {
             throw new IllegalArgumentException("Route may not be null");
         }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/pool/TestNIOConnPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/pool/TestNIOConnPool.java?rev=1154136&r1=1154135&r2=1154136&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/pool/TestNIOConnPool.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/pool/TestNIOConnPool.java Fri Aug  5 09:24:22 2011
@@ -375,9 +375,9 @@ public class TestNIOConnPool {
                 thenReturn(sessionRequest2);
 
         LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 10);
-        pool.setMaxPerHost("somehost", 2);
-        pool.setMaxPerHost("otherhost", 1);
-        pool.setTotalMax(3);
+        pool.setMaxPerRoute("somehost", 2);
+        pool.setMaxPerRoute("otherhost", 1);
+        pool.setMaxTotal(3);
 
         Future<LocalPoolEntry> future1 = pool.lease("somehost", null);
         pool.requestCompleted(sessionRequest1);
@@ -474,9 +474,9 @@ public class TestNIOConnPool {
                 thenReturn(sessionRequest3, sessionRequest4, sessionRequest3);
 
         LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 10);
-        pool.setMaxPerHost("somehost", 2);
-        pool.setMaxPerHost("otherhost", 2);
-        pool.setTotalMax(2);
+        pool.setMaxPerRoute("somehost", 2);
+        pool.setMaxPerRoute("otherhost", 2);
+        pool.setMaxTotal(2);
 
         Future<LocalPoolEntry> future1 = pool.lease("somehost", null);
         Future<LocalPoolEntry> future2 = pool.lease("somehost", null);
@@ -796,22 +796,22 @@ public class TestNIOConnPool {
         ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
         LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 2);
         try {
-            pool.setTotalMax(-1);
+            pool.setMaxTotal(-1);
             Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException expected) {
         }
         try {
-            pool.setMaxPerHost(null, 1);
+            pool.setMaxPerRoute(null, 1);
             Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException expected) {
         }
         try {
-            pool.setMaxPerHost("somehost", -1);
+            pool.setMaxPerRoute("somehost", -1);
             Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException expected) {
         }
         try {
-            pool.setDefaultMaxPerHost(-1);
+            pool.setDefaultMaxPerRoute(-1);
             Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException expected) {
         }

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/pool/AbstractConnPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/pool/AbstractConnPool.java?rev=1154136&r1=1154135&r2=1154136&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/pool/AbstractConnPool.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/pool/AbstractConnPool.java Fri Aug  5 09:24:22 2011
@@ -275,7 +275,7 @@ public abstract class AbstractConnPool<T
         }
     }
 
-    public void setTotalMax(int max) {
+    public void setMaxTotal(int max) {
         if (max <= 0) {
             throw new IllegalArgumentException("Max value may not be negative or zero");
         }
@@ -287,7 +287,7 @@ public abstract class AbstractConnPool<T
         }
     }
 
-    public void setDefaultMaxPerHost(int max) {
+    public void setDefaultMaxPerRoute(int max) {
         if (max <= 0) {
             throw new IllegalArgumentException("Max value may not be negative or zero");
         }
@@ -299,7 +299,7 @@ public abstract class AbstractConnPool<T
         }
     }
 
-    public void setMaxPerHost(final T route, int max) {
+    public void setMaxPerRoute(final T route, int max) {
         if (route == null) {
             throw new IllegalArgumentException("Route may not be null");
         }

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/pool/ConnPoolControl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/pool/ConnPoolControl.java?rev=1154136&r1=1154135&r2=1154136&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/pool/ConnPoolControl.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/pool/ConnPoolControl.java Fri Aug  5 09:24:22 2011
@@ -28,11 +28,11 @@ package org.apache.http.pool;
 
 public interface ConnPoolControl<T> {
 
-    void setTotalMax(int max);
+    void setMaxTotal(int max);
 
-    void setDefaultMaxPerHost(int max);
+    void setDefaultMaxPerRoute(int max);
 
-    void setMaxPerHost(final T route, int max);
+    void setMaxPerRoute(final T route, int max);
 
     PoolStats getTotalStats();
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/pool/TestConnPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/pool/TestConnPool.java?rev=1154136&r1=1154135&r2=1154136&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/pool/TestConnPool.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/pool/TestConnPool.java Fri Aug  5 09:24:22 2011
@@ -92,8 +92,8 @@ public class TestConnPool {
     public void testEmptyPool() throws Exception {
         HttpConnectionFactory connFactory = Mockito.mock(HttpConnectionFactory.class);
         LocalConnPool pool = new LocalConnPool(connFactory, 2, 10);
-        pool.setDefaultMaxPerHost(5);
-        pool.setMaxPerHost("somehost", 3);
+        pool.setDefaultMaxPerRoute(5);
+        pool.setMaxPerRoute("somehost", 3);
         PoolStats totals = pool.getTotalStats();
         Assert.assertEquals(0, totals.getAvailable());
         Assert.assertEquals(0, totals.getLeased());
@@ -231,9 +231,9 @@ public class TestConnPool {
         Mockito.when(connFactory.create(Mockito.eq("otherhost"))).thenReturn(conn2);
 
         LocalConnPool pool = new LocalConnPool(connFactory, 2, 10);
-        pool.setMaxPerHost("somehost", 2);
-        pool.setMaxPerHost("otherhost", 1);
-        pool.setTotalMax(3);
+        pool.setMaxPerRoute("somehost", 2);
+        pool.setMaxPerRoute("otherhost", 1);
+        pool.setMaxTotal(3);
 
         Future<LocalPoolEntry> future1 = pool.lease("somehost", null);
         GetPoolEntryThread t1 = new GetPoolEntryThread(future1);
@@ -333,9 +333,9 @@ public class TestConnPool {
         Mockito.when(connFactory.create(Mockito.eq("otherhost"))).thenReturn(conn4, conn5);
 
         LocalConnPool pool = new LocalConnPool(connFactory, 2, 10);
-        pool.setMaxPerHost("somehost", 2);
-        pool.setMaxPerHost("otherhost", 2);
-        pool.setTotalMax(2);
+        pool.setMaxPerRoute("somehost", 2);
+        pool.setMaxPerRoute("otherhost", 2);
+        pool.setMaxTotal(2);
 
         Future<LocalPoolEntry> future1 = pool.lease("somehost", null);
         GetPoolEntryThread t1 = new GetPoolEntryThread(future1);
@@ -646,22 +646,22 @@ public class TestConnPool {
         HttpConnectionFactory connFactory = Mockito.mock(HttpConnectionFactory.class);
         LocalConnPool pool = new LocalConnPool(connFactory, 2, 2);
         try {
-            pool.setTotalMax(-1);
+            pool.setMaxTotal(-1);
             Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException expected) {
         }
         try {
-            pool.setMaxPerHost(null, 1);
+            pool.setMaxPerRoute(null, 1);
             Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException expected) {
         }
         try {
-            pool.setMaxPerHost("somehost", -1);
+            pool.setMaxPerRoute("somehost", -1);
             Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException expected) {
         }
         try {
-            pool.setDefaultMaxPerHost(-1);
+            pool.setDefaultMaxPerRoute(-1);
             Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException expected) {
         }