hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1570106 - 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/
Date Thu, 20 Feb 2014 08:29:22 GMT
Author: olegk
Date: Thu Feb 20 08:29:21 2014
New Revision: 1570106

URL: http://svn.apache.org/r1570106
Log:
HTTPCORE-374: Pool implementations to return a set of all known routes
Contributed by Dmitry Potapov <potapov.d at gmail.com>

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/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=1570106&r1=1570105&r2=1570106&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
Thu Feb 20 08:29:21 2014
@@ -660,6 +660,20 @@ public abstract class AbstractNIOConnPoo
     }
 
     /**
+     * Returns snapshot of all knows routes
+     *
+     * @since 4.4
+     */
+    public Set<T> getRoutes() {
+        this.lock.lock();
+        try {
+            return new HashSet<T>(routeToPool.keySet());
+        } finally {
+            this.lock.unlock();
+        }
+    }
+
+    /**
      * Enumerates all available connections.
      *
      * @since 4.3

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=1570106&r1=1570105&r2=1570106&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
Thu Feb 20 08:29:21 2014
@@ -31,6 +31,7 @@ import java.net.InetSocketAddress;
 import java.net.SocketAddress;
 import java.net.SocketTimeoutException;
 import java.net.UnknownHostException;
+import java.util.Collections;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
@@ -125,6 +126,7 @@ public class TestNIOConnPool {
         Assert.assertEquals(0, totals.getLeased());
         Assert.assertEquals(0, totals.getPending());
         Assert.assertEquals(10, totals.getMax());
+        Assert.assertEquals(Collections.emptySet(), pool.getRoutes());
         final PoolStats stats = pool.getStats("somehost");
         Assert.assertEquals(0, stats.getAvailable());
         Assert.assertEquals(0, stats.getLeased());
@@ -789,6 +791,7 @@ public class TestNIOConnPool {
         Assert.assertEquals(0, totals.getAvailable());
         Assert.assertEquals(0, totals.getLeased());
         Assert.assertEquals(1, totals.getPending());
+        Assert.assertEquals(Collections.singleton("somehost"), pool.getRoutes());
         final PoolStats stats = pool.getStats("somehost");
         Assert.assertEquals(0, stats.getAvailable());
         Assert.assertEquals(0, stats.getLeased());

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=1570106&r1=1570105&r2=1570106&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
Thu Feb 20 08:29:21 2014
@@ -434,6 +434,20 @@ public abstract class AbstractConnPool<T
     }
 
     /**
+     * Returns snapshot of all knows routes
+     *
+     * @since 4.4
+     */
+    public Set<T> getRoutes() {
+        this.lock.lock();
+        try {
+            return new HashSet<T>(routeToPool.keySet());
+        } finally {
+            this.lock.unlock();
+        }
+    }
+
+    /**
      * Enumerates all available connections.
      *
      * @since 4.3

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=1570106&r1=1570105&r2=1570106&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
Thu Feb 20 08:29:21 2014
@@ -27,6 +27,7 @@
 package org.apache.http.pool;
 
 import java.io.IOException;
+import java.util.Collections;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
@@ -96,6 +97,7 @@ public class TestConnPool {
         Assert.assertEquals(0, totals.getAvailable());
         Assert.assertEquals(0, totals.getLeased());
         Assert.assertEquals(10, totals.getMax());
+        Assert.assertEquals(Collections.emptySet(), pool.getRoutes());
         final PoolStats stats = pool.getStats("somehost");
         Assert.assertEquals(0, stats.getAvailable());
         Assert.assertEquals(0, stats.getLeased());
@@ -526,6 +528,7 @@ public class TestConnPool {
         final PoolStats totals = pool.getTotalStats();
         Assert.assertEquals(0, totals.getAvailable());
         Assert.assertEquals(1, totals.getLeased());
+        Assert.assertEquals(Collections.singleton("somehost"), pool.getRoutes());
         final PoolStats stats = pool.getStats("somehost");
         Assert.assertEquals(0, stats.getAvailable());
         Assert.assertEquals(1, stats.getLeased());



Mime
View raw message