hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r767659 - in /httpcomponents/httpclient/trunk/httpclient/src: main/java/org/apache/http/conn/params/ main/java/org/apache/http/impl/conn/ main/java/org/apache/http/impl/conn/tsccm/ test/java/org/apache/http/impl/conn/
Date Wed, 22 Apr 2009 21:04:48 GMT
Author: olegk
Date: Wed Apr 22 21:04:47 2009
New Revision: 767659

URL: http://svn.apache.org/viewvc?rev=767659&view=rev
Log:
Javadoc cleanups

Modified:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnConnectionPNames.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnManagerPNames.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnManagerParams.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnPerRoute.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnPerRouteBean.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnRoutePNames.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnRouteParams.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestSCMWithServer.java

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnConnectionPNames.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnConnectionPNames.java?rev=767659&r1=767658&r2=767659&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnConnectionPNames.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnConnectionPNames.java
Wed Apr 22 21:04:47 2009
@@ -30,17 +30,13 @@
 
 package org.apache.http.conn.params;
 
-
 /**
- * Parameter names for connections in HttpConn.
- *
- * @version $Revision$
+ * Parameter names for HTTP client connections.
  * 
  * @since 4.0
  */
 public interface ConnConnectionPNames {
 
-
     /**
      * Defines the maximum number of ignorable lines before we expect
      * a HTTP response's status line.

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnManagerPNames.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnManagerPNames.java?rev=767659&r1=767658&r2=767659&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnManagerPNames.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnManagerPNames.java
Wed Apr 22 21:04:47 2009
@@ -30,11 +30,8 @@
 
 package org.apache.http.conn.params;
 
-
 /**
  * Parameter names for connection managers in HttpConn.
- *
- * @version $Revision$
  * 
  * @since 4.0
  */

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnManagerParams.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnManagerParams.java?rev=767659&r1=767658&r2=767659&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnManagerParams.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnManagerParams.java
Wed Apr 22 21:04:47 2009
@@ -40,9 +40,6 @@
  * to client-side
  * {@link org.apache.http.conn.ClientConnectionManager connection managers}. 
  * 
- * 
- * @version $Revision$
- * 
  * @since 4.0
  *
  * @see ConnManagerPNames

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnPerRoute.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnPerRoute.java?rev=767659&r1=767658&r2=767659&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnPerRoute.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnPerRoute.java
Wed Apr 22 21:04:47 2009
@@ -34,13 +34,10 @@
 
 /**
  * This interface is intended for looking up maximum number of connections 
- * allowed for for a given route. This class can be used by pooling 
+ * allowed for a given route. This class can be used by pooling 
  * {@link org.apache.http.conn.ClientConnectionManager connection managers} for 
  * a fine-grained control of connections on a per route basis. 
  * 
- * 
- * @version $Revision$
- * 
  * @since 4.0
  */
 public interface ConnPerRoute {

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnPerRouteBean.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnPerRouteBean.java?rev=767659&r1=767658&r2=767659&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnPerRouteBean.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnPerRouteBean.java
Wed Apr 22 21:04:47 2009
@@ -43,9 +43,6 @@
  * {@link org.apache.http.conn.ClientConnectionManager connection managers} for 
  * a fine-grained control of connections on a per route basis. 
  * 
- * 
- * @version $Revision$
- * 
  * @since 4.0
  */
 @NotThreadSafe // maxPerHostMap and defaultMax
@@ -112,5 +109,10 @@
         this.maxPerHostMap.clear();
         this.maxPerHostMap.putAll(map);
     }
+
+	@Override
+	public String toString() {
+		return this.maxPerHostMap.toString();
+	}
     
 }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnRoutePNames.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnRoutePNames.java?rev=767659&r1=767658&r2=767659&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnRoutePNames.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnRoutePNames.java
Wed Apr 22 21:04:47 2009
@@ -33,8 +33,6 @@
 /**
  * Parameter names for routing in HttpConn.
  * 
- * @version $Revision$
- * 
  * @since 4.0
  */
 public interface ConnRoutePNames {
@@ -50,7 +48,6 @@
      */
     public static final String DEFAULT_PROXY = "http.route.default-proxy";
 
-
     /**
      * Parameter for the local address.
      * On machines with multiple network interfaces, this parameter
@@ -65,7 +62,6 @@
      */
     public static final String LOCAL_ADDRESS = "http.route.local-address";
 
-
     /**
      * Parameter for an forced route.
      * The forced route will be interpreted by the standard

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnRouteParams.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnRouteParams.java?rev=767659&r1=767658&r2=767659&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnRouteParams.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnRouteParams.java
Wed Apr 22 21:04:47 2009
@@ -30,7 +30,6 @@
 
 package org.apache.http.conn.params;
 
-
 import java.net.InetAddress;
 
 import net.jcip.annotations.Immutable;
@@ -39,15 +38,10 @@
 import org.apache.http.params.HttpParams;
 import org.apache.http.conn.routing.HttpRoute;
 
-
-
 /**
  * An adaptor for accessing route related parameters in {@link HttpParams}.
  * See {@link ConnRoutePNames} for parameter name definitions.
  * 
- * 
- * @version $Revision$
- * 
  * @since 4.0
  */
 @Immutable
@@ -67,13 +61,11 @@
      */
     public static final HttpRoute NO_ROUTE = new HttpRoute(NO_HOST); // Immutable
 
-
     /** Disabled default constructor. */
     private ConnRouteParams() {
         // no body
     }
 
-
     /**
      * Obtains the {@link ConnRoutePNames#DEFAULT_PROXY DEFAULT_PROXY}
      * parameter value.
@@ -98,7 +90,6 @@
         return proxy;
     }
 
-
     /**
      * Sets the {@link ConnRoutePNames#DEFAULT_PROXY DEFAULT_PROXY}
      * parameter value.
@@ -117,7 +108,6 @@
         params.setParameter(DEFAULT_PROXY, proxy);
     }
 
-
     /**
      * Obtains the {@link ConnRoutePNames#FORCED_ROUTE FORCED_ROUTE}
      * parameter value.
@@ -142,7 +132,6 @@
         return route;
     }
 
-
     /**
      * Sets the {@link ConnRoutePNames#FORCED_ROUTE FORCED_ROUTE}
      * parameter value.
@@ -161,7 +150,6 @@
         params.setParameter(FORCED_ROUTE, route);
     }
 
-
     /**
      * Obtains the {@link ConnRoutePNames#LOCAL_ADDRESS LOCAL_ADDRESS}
      * parameter value.
@@ -184,7 +172,6 @@
         return local;
     }
 
-
     /**
      * Sets the {@link ConnRoutePNames#LOCAL_ADDRESS LOCAL_ADDRESS}
      * parameter value.

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java?rev=767659&r1=767658&r2=767659&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java
Wed Apr 22 21:04:47 2009
@@ -56,9 +56,11 @@
  * The following parameters can be used to customize the behavior of this 
  * class: 
  * <ul>
+ *  <li>{@link org.apache.http.params.CoreProtocolPNames#STRICT_TRANSFER_ENCODING}</li>
  *  <li>{@link org.apache.http.params.CoreProtocolPNames#HTTP_ELEMENT_CHARSET}</li>
  *  <li>{@link org.apache.http.params.CoreConnectionPNames#SOCKET_BUFFER_SIZE}</li>
  *  <li>{@link org.apache.http.params.CoreConnectionPNames#MAX_LINE_LENGTH}</li>
+ *  <li>{@link org.apache.http.params.CoreConnectionPNames#MAX_HEADER_COUNT}</li>
  * </ul>
  *
  * @since 4.0
@@ -223,7 +225,10 @@
 
     @Override
     public HttpResponse receiveResponseHeader() throws HttpException, IOException {
-        HttpResponse response = super.receiveResponseHeader();
+    	HttpResponse response = super.receiveResponseHeader();
+    	if (log.isDebugEnabled()) {
+            log.debug("Receiving response: " + response.getStatusLine());
+    	}
         if (headerLog.isDebugEnabled()) {
             headerLog.debug("<< " + response.getStatusLine().toString());
             Header[] headers = response.getAllHeaders();
@@ -236,6 +241,9 @@
 
     @Override
     public void sendRequestHeader(HttpRequest request) throws HttpException, IOException
{
+    	if (log.isDebugEnabled()) {
+            log.debug("Sending request: " + request.getRequestLine());
+    	}
         super.sendRequestHeader(request);
         if (headerLog.isDebugEnabled()) {
             headerLog.debug(">> " + request.getRequestLine().toString());

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java?rev=767659&r1=767658&r2=767659&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java
Wed Apr 22 21:04:47 2009
@@ -58,18 +58,17 @@
  * <li>connections are re-used only for the exact same route</li>
  * <li>connection limits are enforced per route rather than per host</li>
  * </ul>
- * Note that access to the pool datastructures is synchronized via the
+ * Note that access to the pool data structures is synchronized via the
  * {@link AbstractConnPool#poolLock poolLock} in the base class,
  * not via <code>synchronized</code> methods.
  *
- *
  * @since 4.0
  */
 public class ConnPoolByRoute extends AbstractConnPool {
         
     private final Log log = LogFactory.getLog(getClass());
 
-    protected final HttpParams params;
+    private final HttpParams params;
     
     /** Connection operator for this pool */
     protected final ClientConnectionOperator operator;

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java?rev=767659&r1=767658&r2=767659&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java
Wed Apr 22 21:04:47 2009
@@ -46,19 +46,32 @@
 import org.apache.http.params.HttpParams;
 import org.apache.http.impl.conn.DefaultClientConnectionOperator;
 
-
-
 /**
- * Manages a pool of {@link OperatedClientConnection client connections}.
+ * Manages a pool of {@link OperatedClientConnection client connections} and 
+ * is able to service connection requests from multiple execution threads. 
+ * Connections are pooled on a per route basis. A request for a route which 
+ * already the manager has persistent connections for available in the pool 
+ * will be services by leasing a connection from the pool rather than 
+ * creating a brand new connection.
  * <p>
- * This class is derived from <code>MultiThreadedHttpConnectionManager</code>
- * in HttpClient 3. See there for original authors.
- * </p>
- *
- *
+ * ThreadSafeClientConnManager maintains a maximum limit of connection on 
+ * a per route basis and in total. Per default this implementation will
+ * create no more than than 2 concurrent connections per given route 
+ * and no more 20 connections in total. For many real-world applications
+ * these limits may prove too constraining, especially if they use HTTP
+ * as a transport protocol for their services. Connection limits, however,
+ * can be adjusted using HTTP parameters.
+ * <p>
+ * The following parameters can be used to customize the behavior of this 
+ * class: 
+ * <ul>
+ *  <li>{@link org.apache.http.conn.params.ConnManagerPNames#MAX_TOTAL_CONNECTIONS}</li>
+ *  <li>{@link org.apache.http.conn.params.ConnManagerPNames#MAX_CONNECTIONS_PER_ROUTE}</li>
+ *  <li>{@link org.apache.http.conn.params.ConnManagerPNames#TIMEOUT}</li>
+ * </ul>
  *
- * <!-- empty lines to avoid svn diff problems -->
- * @version $Revision$ $Date$
+ * @see org.apache.http.conn.params.ConnPerRoute 
+ * @see org.apache.http.conn.params.ConnPerRouteBean
  *
  * @since 4.0
  */
@@ -75,8 +88,6 @@
     /** The operator for opening and updating connections. */
     protected final ClientConnectionOperator connOperator;
     
-
-
     /**
      * Creates a new thread safe connection manager.
      *
@@ -94,16 +105,14 @@
         this.connOperator   = createConnectionOperator(schreg);
         this.connectionPool = createConnectionPool(params);
 
-    } // <constructor>
+    }
 
-    
     @Override
     protected void finalize() throws Throwable {
         shutdown();
         super.finalize();
     }
 
-
     /**
      * Hook for creating the connection pool.
      *
@@ -119,7 +128,6 @@
         return acp;
     }
 
-
     /**
      * Hook for creating the connection operator.
      * It is called by the constructor.
@@ -138,13 +146,10 @@
         return new DefaultClientConnectionOperator(schreg);
     }
 
-
-    // non-javadoc, see interface ClientConnectionManager
     public SchemeRegistry getSchemeRegistry() {
         return this.schemeRegistry;
     }
 
-    
     public ClientConnectionRequest requestConnection(
             final HttpRoute route, 
             final Object state) {
@@ -178,8 +183,6 @@
         
     }
 
-    
-    // non-javadoc, see interface ClientConnectionManager
     public void releaseConnection(ManagedClientConnection conn, long validDuration, TimeUnit
timeUnit) {
 
         if (!(conn instanceof BasicPooledConnAdapter)) {
@@ -228,14 +231,11 @@
         }
     }
 
-
-    // non-javadoc, see interface ClientConnectionManager
     public void shutdown() {
         log.debug("Shutting down");
         connectionPool.shutdown();
     }
 
-
     /**
      * Gets the total number of pooled connections for the given route.
      * This is the total number of connections that have been created and
@@ -251,7 +251,6 @@
                 route);
     }
 
-
     /**
      * Gets the total number of pooled connections.  This is the total number of 
      * connections that have been created and are still in use by this connection 
@@ -268,8 +267,6 @@
         return count;
     }
 
-
-    // non-javadoc, see interface ClientConnectionManager
     public void closeIdleConnections(long idleTimeout, TimeUnit tunit) {
         if (log.isDebugEnabled()) {
             log.debug("Closing connections idle for " + idleTimeout + " " + tunit);
@@ -284,6 +281,5 @@
         connectionPool.deleteClosedConnections();
     }
 
-
-} // class ThreadSafeClientConnManager
+}
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestSCMWithServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestSCMWithServer.java?rev=767659&r1=767658&r2=767659&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestSCMWithServer.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestSCMWithServer.java
Wed Apr 22 21:04:47 2009
@@ -236,4 +236,26 @@
         mgr.shutdown();
     }
     
+    public void testAlreadyLeased() throws Exception {
+
+        HttpParams mgrpar = defaultParams.copy();
+        ConnManagerParams.setMaxTotalConnections(mgrpar, 1);
+
+        SingleClientConnManager mgr = createSCCM(mgrpar, null);
+
+        final HttpHost target = getServerHttp();
+        final HttpRoute route = new HttpRoute(target, null, false);
+
+        ManagedClientConnection conn =  mgr.getConnection(route, null);
+        mgr.releaseConnection(conn, 100, TimeUnit.MILLISECONDS);
+        
+        mgr.getConnection(route, null);
+        try {
+            mgr.getConnection(route, null);
+            fail("IllegalStateException should have been thrown");
+        } catch (IllegalStateException ex) {
+            mgr.shutdown();
+        }
+    }
+
 }



Mime
View raw message