hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1606665 - in /httpcomponents/httpclient/trunk/httpclient/src: main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java test/java/org/apache/http/impl/client/integration/TestConnectionManagement.java
Date Mon, 30 Jun 2014 10:12:32 GMT
Author: olegk
Date: Mon Jun 30 10:12:31 2014
New Revision: 1606665

URL: http://svn.apache.org/r1606665
Log:
Added new functionality to the pooling conn manager introduced by HTTPCORE-374
Contributed by Dmitry Potapov <potapov.d at gmail.com>

Modified:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionManagement.java

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java?rev=1606665&r1=1606664&r2=1606665&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java
Mon Jun 30 10:12:31 2014
@@ -30,6 +30,7 @@ import java.io.Closeable;
 import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
@@ -445,6 +446,13 @@ public class PoolingHttpClientConnection
         return this.pool.getStats(route);
     }
 
+    /**
+     * @since 4.4
+     */
+    public Set<HttpRoute> getRoutes() {
+        return this.pool.getRoutes();
+    }
+
     public SocketConfig getDefaultSocketConfig() {
         return this.configData.getDefaultSocketConfig();
     }

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionManagement.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionManagement.java?rev=1606665&r1=1606664&r2=1606665&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionManagement.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionManagement.java
Mon Jun 30 10:12:31 2014
@@ -31,6 +31,7 @@ import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.net.Socket;
 import java.net.SocketException;
+import java.util.Collections;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
@@ -297,18 +298,21 @@ public class TestConnectionManagement ex
         this.connManager.connect(conn, route, 0, context);
         this.connManager.routeComplete(conn, route, context);
 
+        Assert.assertEquals(Collections.singleton(route), this.connManager.getRoutes());
         Assert.assertEquals(1, this.connManager.getTotalStats().getLeased());
         Assert.assertEquals(1, this.connManager.getStats(route).getLeased());
 
         this.connManager.releaseConnection(conn, null, 100, TimeUnit.MILLISECONDS);
 
         // Released, still active.
+        Assert.assertEquals(Collections.singleton(route), this.connManager.getRoutes());
         Assert.assertEquals(1, this.connManager.getTotalStats().getAvailable());
         Assert.assertEquals(1, this.connManager.getStats(route).getAvailable());
 
         this.connManager.closeExpiredConnections();
 
         // Time has not expired yet.
+        Assert.assertEquals(Collections.singleton(route), this.connManager.getRoutes());
         Assert.assertEquals(1, this.connManager.getTotalStats().getAvailable());
         Assert.assertEquals(1, this.connManager.getStats(route).getAvailable());
 
@@ -317,6 +321,7 @@ public class TestConnectionManagement ex
         this.connManager.closeExpiredConnections();
 
         // Time expired now, connections are destroyed.
+        Assert.assertEquals(Collections.emptySet(), this.connManager.getRoutes());
         Assert.assertEquals(0, this.connManager.getTotalStats().getAvailable());
         Assert.assertEquals(0, this.connManager.getStats(route).getAvailable());
 
@@ -340,18 +345,21 @@ public class TestConnectionManagement ex
         this.connManager.connect(conn, route, 0, context);
         this.connManager.routeComplete(conn, route, context);
 
+        Assert.assertEquals(Collections.singleton(route), this.connManager.getRoutes());
         Assert.assertEquals(1, this.connManager.getTotalStats().getLeased());
         Assert.assertEquals(1, this.connManager.getStats(route).getLeased());
         // Release, let remain idle for forever
         this.connManager.releaseConnection(conn, null, -1, TimeUnit.MILLISECONDS);
 
         // Released, still active.
+        Assert.assertEquals(Collections.singleton(route), this.connManager.getRoutes());
         Assert.assertEquals(1, this.connManager.getTotalStats().getAvailable());
         Assert.assertEquals(1, this.connManager.getStats(route).getAvailable());
 
         this.connManager.closeExpiredConnections();
 
         // Time has not expired yet.
+        Assert.assertEquals(Collections.singleton(route), this.connManager.getRoutes());
         Assert.assertEquals(1, this.connManager.getTotalStats().getAvailable());
         Assert.assertEquals(1, this.connManager.getStats(route).getAvailable());
 
@@ -360,6 +368,7 @@ public class TestConnectionManagement ex
         this.connManager.closeExpiredConnections();
 
         // TTL expired now, connections are destroyed.
+        Assert.assertEquals(Collections.emptySet(), this.connManager.getRoutes());
         Assert.assertEquals(0, this.connManager.getTotalStats().getAvailable());
         Assert.assertEquals(0, this.connManager.getStats(route).getAvailable());
 



Mime
View raw message