hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1161021 - in /httpcomponents/httpcore/trunk: httpcore-nio/src/main/java/org/apache/http/nio/pool/ httpcore/src/main/java/org/apache/http/pool/
Date Wed, 24 Aug 2011 09:00:18 GMT
Author: olegk
Date: Wed Aug 24 09:00:18 2011
New Revision: 1161021

URL: http://svn.apache.org/viewvc?rev=1161021&view=rev
Log:
Added getters to the ConnPoolControl interface

Modified:
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.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

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=1161021&r1=1161020&r2=1161021&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
Wed Aug 24 09:00:18 2011
@@ -270,7 +270,7 @@ public abstract class AbstractNIOConnPoo
             }
 
             // New connection is needed
-            int maxPerRoute = getMaxPerRoute(route);
+            int maxPerRoute = getMax(route);
             // Shrink the pool prior to allocating a new connection
             int excess = Math.max(0, pool.getAllocatedCount() + 1 - maxPerRoute);
             if (excess > 0) {
@@ -401,7 +401,7 @@ public abstract class AbstractNIOConnPoo
         }
     }
 
-    private int getMaxPerRoute(final T route) {
+    private int getMax(final T route) {
         Integer v = this.maxPerRoute.get(route);
         if (v != null) {
             return v.intValue();
@@ -422,6 +422,15 @@ public abstract class AbstractNIOConnPoo
         }
     }
 
+    public int getMaxTotal() {
+        this.lock.lock();
+        try {
+            return this.maxTotal;
+        } finally {
+            this.lock.unlock();
+        }
+    }
+
     public void setDefaultMaxPerRoute(int max) {
         if (max <= 0) {
             throw new IllegalArgumentException("Max value may not be negative or zero");
@@ -434,6 +443,15 @@ public abstract class AbstractNIOConnPoo
         }
     }
 
+    public int getDefaultMaxPerRoute() {
+        this.lock.lock();
+        try {
+            return this.defaultMaxPerRoute;
+        } finally {
+            this.lock.unlock();
+        }
+    }
+
     public void setMaxPerRoute(final T route, int max) {
         if (route == null) {
             throw new IllegalArgumentException("Route may not be null");
@@ -449,6 +467,18 @@ public abstract class AbstractNIOConnPoo
         }
     }
 
+    public int getMaxPerRoute(T route) {
+        if (route == null) {
+            throw new IllegalArgumentException("Route may not be null");
+        }
+        this.lock.lock();
+        try {
+            return getMax(route);
+        } finally {
+            this.lock.unlock();
+        }
+    }
+
     public PoolStats getTotalStats() {
         this.lock.lock();
         try {
@@ -473,7 +503,7 @@ public abstract class AbstractNIOConnPoo
                     pool.getLeasedCount(),
                     pool.getPendingCount(),
                     pool.getAvailableCount(),
-                    getMaxPerRoute(route));
+                    getMax(route));
         } finally {
             this.lock.unlock();
         }

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=1161021&r1=1161020&r2=1161021&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
Wed Aug 24 09:00:18 2011
@@ -200,7 +200,7 @@ public abstract class AbstractConnPool<T
                 }
 
                 // New connection is needed
-                int maxPerRoute = getMaxPerRoute(route);
+                int maxPerRoute = getMax(route);
                 // Shrink the pool prior to allocating a new connection
                 int excess = Math.max(0, pool.getAllocatedCount() + 1 - maxPerRoute);
                 if (excess > 0) {
@@ -290,7 +290,7 @@ public abstract class AbstractConnPool<T
         }
     }
 
-    private int getMaxPerRoute(final T route) {
+    private int getMax(final T route) {
         Integer v = this.maxPerRoute.get(route);
         if (v != null) {
             return v.intValue();
@@ -311,6 +311,15 @@ public abstract class AbstractConnPool<T
         }
     }
 
+    public int getMaxTotal() {
+        this.lock.lock();
+        try {
+            return this.maxTotal;
+        } finally {
+            this.lock.unlock();
+        }
+    }
+
     public void setDefaultMaxPerRoute(int max) {
         if (max <= 0) {
             throw new IllegalArgumentException("Max value may not be negative or zero");
@@ -323,6 +332,15 @@ public abstract class AbstractConnPool<T
         }
     }
 
+    public int getDefaultMaxPerRoute() {
+        this.lock.lock();
+        try {
+            return this.defaultMaxPerRoute;
+        } finally {
+            this.lock.unlock();
+        }
+    }
+
     public void setMaxPerRoute(final T route, int max) {
         if (route == null) {
             throw new IllegalArgumentException("Route may not be null");
@@ -338,6 +356,18 @@ public abstract class AbstractConnPool<T
         }
     }
 
+    public int getMaxPerRoute(T route) {
+        if (route == null) {
+            throw new IllegalArgumentException("Route may not be null");
+        }
+        this.lock.lock();
+        try {
+            return getMax(route);
+        } finally {
+            this.lock.unlock();
+        }
+    }
+
     public PoolStats getTotalStats() {
         this.lock.lock();
         try {
@@ -362,7 +392,7 @@ public abstract class AbstractConnPool<T
                     pool.getLeasedCount(),
                     pool.getPendingCount(),
                     pool.getAvailableCount(),
-                    getMaxPerRoute(route));
+                    getMax(route));
         } finally {
             this.lock.unlock();
         }

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=1161021&r1=1161020&r2=1161021&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
Wed Aug 24 09:00:18 2011
@@ -32,15 +32,23 @@ package org.apache.http.pool;
  * allowed.
  *
  * @param <T> route
+ *
+ * @since 4.2
  */
 public interface ConnPoolControl<T> {
 
     void setMaxTotal(int max);
 
+    int getMaxTotal();
+
     void setDefaultMaxPerRoute(int max);
 
+    int getDefaultMaxPerRoute();
+
     void setMaxPerRoute(final T route, int max);
 
+    int getMaxPerRoute(final T route);
+
     PoolStats getTotalStats();
 
     PoolStats getStats(final T route);



Mime
View raw message