hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rola...@apache.org
Subject svn commit: r607432 - in /httpcomponents/httpclient/trunk: ./ module-client/src/main/java/org/apache/http/conn/ module-client/src/main/java/org/apache/http/impl/conn/ module-client/src/main/java/org/apache/http/impl/conn/tsccm/ module-client/src/test/j...
Date Sat, 29 Dec 2007 15:50:03 GMT
Author: rolandw
Date: Sat Dec 29 07:50:02 2007
New Revision: 607432

URL: http://svn.apache.org/viewvc?rev=607432&view=rev
Log:
HTTPCLIENT-725: time unit when closing idle connections

Modified:
    httpcomponents/httpclient/trunk/RELEASE_NOTES.txt
    httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/ClientConnectionManager.java
    httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/IdleConnectionHandler.java
    httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/SingleClientConnManager.java
    httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/AbstractConnPool.java
    httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java
    httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/TestTSCCMNoServer.java

Modified: httpcomponents/httpclient/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/RELEASE_NOTES.txt?rev=607432&r1=607431&r2=607432&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpclient/trunk/RELEASE_NOTES.txt Sat Dec 29 07:50:02 2007
@@ -1,7 +1,10 @@
 Changes since 4.0 Alpha 2
 -------------------
 
-* [HTTPCLIENT-677] Connection manager no longer uses Thread.interrupt()
+* [HTTPCLIENT-725] Use TimeUnit arguments for timeouts in connection manager.
+  Contributed by Roland Weber <rolandw at apache.org>
+
+* [HTTPCLIENT-677] Connection manager no longer uses Thread.interrupt().
   Contributed by Roland Weber <rolandw at apache.org>
 
 * [HTTPCLIENT-716] Allow application-defined routes.
@@ -16,11 +19,11 @@
 * [HTTPCLIENT-715] Remove RoutedRequest from API
   Contributed by Roland Weber <rolandw at apache.org>
 
-* [HTTPCLIENT-705] Fixed incorrect handling of URIs with null path component
+* [HTTPCLIENT-705] Fixed incorrect handling of URIs with null path component.
   Contributed by Oleg Kalnichevski <olegk at apache.org>
 
 * [HTTPCLIENT-688] HttpOptions#getAllowedMethods can now handle multiple 
-  Allow headers
+  Allow headers.
   Contributed by Andrea Selva <selva.andre at gmail.com>
 
 

Modified: httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/ClientConnectionManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/ClientConnectionManager.java?rev=607432&r1=607431&r2=607432&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/ClientConnectionManager.java
(original)
+++ httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/ClientConnectionManager.java
Sat Dec 29 07:50:02 2007
@@ -131,12 +131,14 @@
     /**
      * Closes idle connections in the pool.
      * Open connections in the pool that have not been used for the
-     * timespan given by the timeout argument will be closed.
+     * timespan given by the argument will be closed.
      * Currently allocated connections are not subject to this method.
+     * Times will be checked with milliseconds precision
      * 
-     * @param idletime       the idle time in milliseconds
+     * @param idletime  the idle time of connections to be closed
+     * @param tunit     the unit for the <code>idletime</code>
      */
-    void closeIdleConnections(long idletime)
+    void closeIdleConnections(long idletime, TimeUnit tunit)
         ;
 
 

Modified: httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/IdleConnectionHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/IdleConnectionHandler.java?rev=607432&r1=607431&r2=607432&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/IdleConnectionHandler.java
(original)
+++ httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/IdleConnectionHandler.java
Sat Dec 29 07:50:02 2007
@@ -100,6 +100,7 @@
      * 
      * @param idleTime the minimum idle time, in milliseconds, for connections to be closed
      */
+    //@@@ add TimeUnit argument here?
     public void closeIdleConnections(long idleTime) {
         
         // the latest time for which connections will be closed

Modified: httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/SingleClientConnManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/SingleClientConnManager.java?rev=607432&r1=607431&r2=607432&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/SingleClientConnManager.java
(original)
+++ httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/SingleClientConnManager.java
Sat Dec 29 07:50:02 2007
@@ -289,11 +289,17 @@
 
 
     // non-javadoc, see interface ClientConnectionManager
-    public void closeIdleConnections(long idletime) {
+    public void closeIdleConnections(long idletime, TimeUnit tunit) {
         assertStillUp();
 
+        // idletime can be 0 or negative, no problem there
+        if (tunit == null) {
+            throw new IllegalArgumentException("Time unit must not be null.");
+        }
+
         if ((managedConn == null) && uniquePoolEntry.connection.isOpen()) {
-            final long cutoff = System.currentTimeMillis() - idletime;
+            final long cutoff =
+                System.currentTimeMillis() - tunit.toMillis(idletime);
             if (lastReleaseTime <= cutoff) {
                 try {
                     uniquePoolEntry.close();

Modified: httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/AbstractConnPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/AbstractConnPool.java?rev=607432&r1=607431&r2=607432&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/AbstractConnPool.java
(original)
+++ httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/AbstractConnPool.java
Sat Dec 29 07:50:02 2007
@@ -249,12 +249,18 @@
      *
      * @param idletime  the time the connections should have been idle
      *                  in order to be closed now
+     * @param tunit     the unit for the <code>idletime</code>
      */
-    public void closeIdleConnections(long idletime) {
+    public void closeIdleConnections(long idletime, TimeUnit tunit) {
+
+        // idletime can be 0 or negative, no problem there
+        if (tunit == null) {
+            throw new IllegalArgumentException("Time unit must not be null.");
+        }
 
         try {
             poolLock.lock();
-            idleConnHandler.closeIdleConnections(idletime);
+            idleConnHandler.closeIdleConnections(tunit.toMillis(idletime));
         } finally {
             poolLock.unlock();
         }

Modified: httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java?rev=607432&r1=607431&r2=607432&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java
(original)
+++ httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java
Sat Dec 29 07:50:02 2007
@@ -264,9 +264,9 @@
 
 
     // non-javadoc, see interface ClientConnectionManager
-    public void closeIdleConnections(long idleTimeout) {
+    public void closeIdleConnections(long idleTimeout, TimeUnit tunit) {
         // combine these two in a single call?
-        connectionPool.closeIdleConnections(idleTimeout);
+        connectionPool.closeIdleConnections(idleTimeout, tunit);
         connectionPool.deleteClosedConnections();
     }
 

Modified: httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/TestTSCCMNoServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/TestTSCCMNoServer.java?rev=607432&r1=607431&r2=607432&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/TestTSCCMNoServer.java
(original)
+++ httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/TestTSCCMNoServer.java
Sat Dec 29 07:50:02 2007
@@ -393,7 +393,8 @@
         assertEquals("connectionsInPool(host)",
                      mgr.getConnectionsInPool(route), 1);
 
-        mgr.closeIdleConnections(0L); // implicitly deletes them, too
+        // this implicitly deletes them
+        mgr.closeIdleConnections(0L, TimeUnit.MILLISECONDS);
 
         assertEquals("connectionsInPool",
                      mgr.getConnectionsInPool(), 0);



Mime
View raw message