hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r646549 - in /httpcomponents/httpclient/trunk/module-client/src: examples/org/apache/http/examples/conn/ main/java/org/apache/http/conn/ main/java/org/apache/http/impl/client/ main/java/org/apache/http/impl/conn/ main/java/org/apache/http/i...
Date Wed, 09 Apr 2008 21:29:48 GMT
Author: olegk
Date: Wed Apr  9 14:29:33 2008
New Revision: 646549

URL: http://svn.apache.org/viewvc?rev=646549&view=rev
Log:
HTTPCLIENT-652: Added optional state attribute to managed client connections

Added:
    httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/ConnRoute.java
  (with props)
Modified:
    httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/conn/ManagerConnectDirect.java
    httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/conn/ManagerConnectProxy.java
    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/client/DefaultClientRequestDirector.java
    httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/AbstractPoolEntry.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/BasicPoolEntry.java
    httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/BasicPoolEntryRef.java
    httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java
    httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/PoolEntryRequest.java
    httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/RouteSpecificPool.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/client/TestDefaultClientRequestDirector.java
    httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/GetConnThread.java
    httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/TestTSCCMNoServer.java
    httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/TestTSCCMWithServer.java
    httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/tsccm/TestDumbHelpers.java
    httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/tsccm/TestSpuriousWakeup.java
    httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/tsccm/TestWaitingThread.java

Modified: httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/conn/ManagerConnectDirect.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/conn/ManagerConnectDirect.java?rev=646549&r1=646548&r2=646549&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/conn/ManagerConnectDirect.java
(original)
+++ httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/conn/ManagerConnectDirect.java
Wed Apr  9 14:29:33 2008
@@ -107,7 +107,7 @@
             (target, null, supportedSchemes.getScheme(target).isLayered());
 
         System.out.println("requesting connection for " + route);
-        ClientConnectionRequest connRequest = clcm.requestConnection(route);
+        ClientConnectionRequest connRequest = clcm.requestConnection(route, null);
         ManagedClientConnection conn = connRequest.getConnection(0, null);
         try {
             System.out.println("opening connection");

Modified: httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/conn/ManagerConnectProxy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/conn/ManagerConnectProxy.java?rev=646549&r1=646548&r2=646549&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/conn/ManagerConnectProxy.java
(original)
+++ httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/conn/ManagerConnectProxy.java
Wed Apr  9 14:29:33 2008
@@ -113,7 +113,7 @@
              supportedSchemes.getScheme(target).isLayered());
 
         System.out.println("requesting connection for " + route);
-        ClientConnectionRequest connRequest = clcm.requestConnection(route);
+        ClientConnectionRequest connRequest = clcm.requestConnection(route, null);
         ManagedClientConnection conn = connRequest.getConnection(0, null);
         try {
             System.out.println("opening connection");

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=646549&r1=646548&r2=646549&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
Wed Apr  9 14:29:33 2008
@@ -80,7 +80,7 @@
      * {@link ManagedClientConnection} can be obtained, or the request can be
      * aborted.
      */
-    ClientConnectionRequest requestConnection(HttpRoute route)
+    ClientConnectionRequest requestConnection(HttpRoute route, Object state)
         ;
 
 

Modified: httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultClientRequestDirector.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultClientRequestDirector.java?rev=646549&r1=646548&r2=646549&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultClientRequestDirector.java
(original)
+++ httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultClientRequestDirector.java
Wed Apr  9 14:29:33 2008
@@ -284,7 +284,8 @@
                 
                 // Allocate connection if needed
                 if (managedConn == null) {
-                    ClientConnectionRequest connRequest = connManager.requestConnection(route);
+                    ClientConnectionRequest connRequest = connManager.requestConnection(
+                            route, null);
                     if (orig instanceof AbortableHttpRequest) {
                         ((AbortableHttpRequest) orig).setConnectionRequest(connRequest);
                     }

Modified: httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/AbstractPoolEntry.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/AbstractPoolEntry.java?rev=646549&r1=646548&r2=646549&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/AbstractPoolEntry.java
(original)
+++ httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/AbstractPoolEntry.java
Wed Apr  9 14:29:33 2008
@@ -75,8 +75,8 @@
     //@@@ currently accessed from connection manager(s) as attribute
     //@@@ avoid that, derived classes should decide whether update is allowed
     //@@@ SCCM: yes, TSCCM: no
-    protected volatile HttpRoute plannedRoute;
-
+    protected volatile ConnRoute route;
+    
     /** The tracked route, or <code>null</code> before tracking starts. */
     protected volatile RouteTracker tracker;
 
@@ -89,9 +89,9 @@
      *                or <code>null</code>
      */
     protected AbstractPoolEntry(OperatedClientConnection occ,
-                                HttpRoute route) {
+                                ConnRoute route) {
         this.connection = occ;
-        this.plannedRoute = route;
+        this.route = route;
         this.tracker = null;
     }
 

Added: httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/ConnRoute.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/ConnRoute.java?rev=646549&view=auto
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/ConnRoute.java
(added)
+++ httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/ConnRoute.java
Wed Apr  9 14:29:33 2008
@@ -0,0 +1,98 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.impl.conn;
+
+import org.apache.http.conn.routing.HttpRoute;
+import org.apache.http.util.LangUtils;
+
+/**
+ * A route for {@link ManagedClientConnection} along with the state information 
+ * associated with that connection.
+ * 
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ * 
+ */
+public class ConnRoute {
+
+    private final HttpRoute route;
+    private final Object state;
+    
+    public ConnRoute(final HttpRoute route, final Object state) {
+        super();
+        if (route == null) {
+            throw new IllegalArgumentException("HTTP route may not be null");
+        }
+        this.route = route;
+        this.state = state;
+    }
+
+    public HttpRoute getRoute() {
+        return this.route;
+    }
+
+    public Object getState() {
+        return this.state;
+    }
+
+    @Override
+    public boolean equals(final Object obj) {
+        if (obj == null) return false;
+        if (this == obj) return true;
+        if (obj instanceof ConnRoute) {
+            ConnRoute that = (ConnRoute) obj;
+            return this.route.equals(that.route) 
+                && LangUtils.equals(this.state, that.state);
+        } else {
+            return false;
+        }
+    }
+
+    @Override
+    public int hashCode() {
+        int hash = LangUtils.HASH_SEED;
+        hash = LangUtils.hashCode(hash, this.route);
+        hash = LangUtils.hashCode(hash, this.state);
+        return hash;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder buffer = new StringBuilder();
+        buffer.append(this.route);
+        if (this.state != null) {
+            buffer.append(" [");
+            buffer.append(this.state);
+            buffer.append("]");
+        }
+        return buffer.toString();
+    }
+    
+}

Propchange: httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/ConnRoute.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/ConnRoute.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/ConnRoute.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

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=646549&r1=646548&r2=646549&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
Wed Apr  9 14:29:33 2008
@@ -178,7 +178,9 @@
     }
 
 
-    public final ClientConnectionRequest requestConnection(final HttpRoute route) {
+    public final ClientConnectionRequest requestConnection(
+            final HttpRoute route,
+            final Object state) {
         
         return new ClientConnectionRequest() {
             
@@ -188,7 +190,8 @@
             
             public ManagedClientConnection getConnection(
                     long timeout, TimeUnit tunit) {
-                return SingleClientConnManager.this.getConnection(route);
+                return SingleClientConnManager.this.getConnection(
+                        route, state);
             }
             
         };
@@ -204,7 +207,7 @@
      * @return  a connection that can be used to communicate
      *          along the given route
      */
-    public ManagedClientConnection getConnection(HttpRoute route) {
+    public ManagedClientConnection getConnection(HttpRoute route, Object state) {
 
         if (route == null) {
             throw new IllegalArgumentException("Route may not be null.");
@@ -236,7 +239,7 @@
             }
         }
 
-        managedConn = new ConnAdapter(uniquePoolEntry, route);
+        managedConn = new ConnAdapter(uniquePoolEntry, new ConnRoute(route, state));
 
         return managedConn;
     }
@@ -417,10 +420,10 @@
          * @param entry   the pool entry for the connection being wrapped
          * @param plan    the planned route for this connection
          */
-        protected ConnAdapter(PoolEntry entry, HttpRoute plan) {
+        protected ConnAdapter(PoolEntry entry, ConnRoute route) {
             super(SingleClientConnManager.this, entry);
             markReusable();
-            entry.plannedRoute = plan;
+            entry.route = route;
         }
     }
 

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=646549&r1=646548&r2=646549&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
Wed Apr  9 14:29:33 2008
@@ -43,13 +43,13 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.conn.ClientConnectionOperator;
 import org.apache.http.conn.ClientConnectionManager;
 import org.apache.http.conn.ConnectionPoolTimeoutException;
 import org.apache.http.conn.OperatedClientConnection;
 import org.apache.http.params.HttpParams;
 import org.apache.http.impl.conn.IdleConnectionHandler;
+import org.apache.http.impl.conn.ConnRoute;
 
 
 
@@ -209,7 +209,7 @@
      *         if the calling thread was interrupted
      */
     public final
-        BasicPoolEntry getEntry(HttpRoute route, long timeout, TimeUnit tunit,
+        BasicPoolEntry getEntry(ConnRoute route, long timeout, TimeUnit tunit,
                                 ClientConnectionOperator operator)
         throws ConnectionPoolTimeoutException, InterruptedException {
         return newPoolEntryRequest().getPoolEntry(route, timeout, tunit, operator);
@@ -247,7 +247,7 @@
                 //@@@ flag in the BasicPoolEntryRef, to be reset when freed?
                 final boolean lost = issuedConnections.remove(ref);
                 if (lost) {
-                    final HttpRoute route =
+                    final ConnRoute route =
                         ((BasicPoolEntryRef)ref).getRoute();
                     if (LOG.isDebugEnabled()) {
                         LOG.debug("Connection garbage collected. " + route);
@@ -274,7 +274,7 @@
      *
      * @param route     the route of the pool entry that was lost
      */
-    protected abstract void handleLostEntry(HttpRoute route)
+    protected abstract void handleLostEntry(ConnRoute route)
         ;
 
 

Modified: httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/BasicPoolEntry.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/BasicPoolEntry.java?rev=646549&r1=646548&r2=646549&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/BasicPoolEntry.java
(original)
+++ httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/BasicPoolEntry.java
Wed Apr  9 14:29:33 2008
@@ -33,10 +33,10 @@
 
 import java.lang.ref.ReferenceQueue;
 
-import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.conn.OperatedClientConnection;
 import org.apache.http.conn.ClientConnectionOperator;
 import org.apache.http.impl.conn.AbstractPoolEntry;
+import org.apache.http.impl.conn.ConnRoute;
 
 
 
@@ -67,7 +67,7 @@
      *                or <code>null</code>
      */
     public BasicPoolEntry(ClientConnectionOperator op,
-                          HttpRoute route,
+                          ConnRoute route,
                           ReferenceQueue<Object> queue) {
         //@@@ create connection in base? or delay creation until needed?
         super(op.createConnection(), route);
@@ -92,8 +92,8 @@
         return super.connection;
     }
 
-    protected final HttpRoute getPlannedRoute() {
-        return super.plannedRoute;
+    protected final ConnRoute getPlannedRoute() {
+        return super.route;
     }
 
     protected final BasicPoolEntryRef getWeakRef() {

Modified: httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/BasicPoolEntryRef.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/BasicPoolEntryRef.java?rev=646549&r1=646548&r2=646549&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/BasicPoolEntryRef.java
(original)
+++ httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/BasicPoolEntryRef.java
Wed Apr  9 14:29:33 2008
@@ -34,7 +34,7 @@
 import java.lang.ref.WeakReference;
 import java.lang.ref.ReferenceQueue;
 
-import org.apache.http.conn.routing.HttpRoute;
+import org.apache.http.impl.conn.ConnRoute;
 
 
 
@@ -46,7 +46,7 @@
 public class BasicPoolEntryRef extends WeakReference<BasicPoolEntry> {
 
     /** The planned route of the entry. */
-    private final HttpRoute route;
+    private final ConnRoute route;
 
 
     /**
@@ -72,7 +72,7 @@
      *
      * @return      the planned route
      */
-    public final HttpRoute getRoute() {
+    public final ConnRoute getRoute() {
         return this.route;
     }
 

Modified: httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java?rev=646549&r1=646548&r2=646549&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java
(original)
+++ httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java
Wed Apr  9 14:29:33 2008
@@ -46,6 +46,7 @@
 import org.apache.http.conn.ClientConnectionOperator;
 import org.apache.http.conn.ConnectionPoolTimeoutException;
 import org.apache.http.conn.params.HttpConnectionManagerParams;
+import org.apache.http.impl.conn.ConnRoute;
 
 
 
@@ -83,7 +84,7 @@
      * Keys are of class {@link HttpRoute},
      * values of class {@link RouteSpecificPool}.
      */
-    protected final Map<HttpRoute,RouteSpecificPool> routeToPool;
+    protected final Map<ConnRoute, RouteSpecificPool> routeToPool;
 
 
 
@@ -127,8 +128,8 @@
      *
      * @return  a map
      */
-    protected Map<HttpRoute,RouteSpecificPool> createRouteToPoolMap() {
-        return new HashMap<HttpRoute,RouteSpecificPool>();
+    protected Map<ConnRoute,RouteSpecificPool> createRouteToPoolMap() {
+        return new HashMap<ConnRoute, RouteSpecificPool>();
     }
 
 
@@ -140,7 +141,7 @@
      *
      * @return  the new pool
      */
-    protected RouteSpecificPool newRouteSpecificPool(HttpRoute route) {
+    protected RouteSpecificPool newRouteSpecificPool(ConnRoute route) {
         return new RouteSpecificPool(route);
     }
 
@@ -169,7 +170,7 @@
      * @return  the pool for the argument route,
      *     never <code>null</code> if <code>create</code> is <code>true</code>
      */
-    protected RouteSpecificPool getRoutePool(HttpRoute route,
+    protected RouteSpecificPool getRoutePool(ConnRoute route,
                                              boolean create) {
         RouteSpecificPool rospl = null;
 
@@ -192,7 +193,7 @@
 
 
     //@@@ consider alternatives for gathering statistics
-    public int getConnectionsInPool(HttpRoute route) {
+    public int getConnectionsInPool(ConnRoute route) {
 
         try {
             poolLock.lock();
@@ -222,9 +223,12 @@
                 }
             }
             
-            public BasicPoolEntry getPoolEntry(HttpRoute route, long timeout,
-                    TimeUnit tunit, ClientConnectionOperator operator)
-                    throws InterruptedException, ConnectionPoolTimeoutException {
+            public BasicPoolEntry getPoolEntry(
+                    ConnRoute route, 
+                    long timeout,
+                    TimeUnit tunit, 
+                    ClientConnectionOperator operator)
+                        throws InterruptedException, ConnectionPoolTimeoutException {
                 return getEntryBlocking(route, timeout, tunit, operator, aborter);
             }
             
@@ -251,14 +255,15 @@
      * @throws InterruptedException
      *         if the calling thread was interrupted
      */
-    protected BasicPoolEntry getEntryBlocking(HttpRoute route,
+    protected BasicPoolEntry getEntryBlocking(
+                                   ConnRoute route,
                                    long timeout, TimeUnit tunit,
                                    ClientConnectionOperator operator,
                                    Aborter aborter)
         throws ConnectionPoolTimeoutException, InterruptedException {
 
         int maxHostConnections = HttpConnectionManagerParams
-            .getMaxConnectionsPerHost(this.params, route);
+            .getMaxConnectionsPerHost(this.params, route.getRoute());
         int maxTotalConnections = HttpConnectionManagerParams
             .getMaxTotalConnections(this.params);
         
@@ -358,7 +363,7 @@
     @Override
     public void freeEntry(BasicPoolEntry entry) {
 
-        HttpRoute route = entry.getPlannedRoute();
+        ConnRoute route = entry.getPlannedRoute();
         if (LOG.isDebugEnabled()) {
             LOG.debug("Freeing connection. " + route);
         }
@@ -488,7 +493,7 @@
      */
     protected void deleteEntry(BasicPoolEntry entry) {
 
-        HttpRoute route = entry.getPlannedRoute();
+        ConnRoute route = entry.getPlannedRoute();
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("Deleting connection. " + route);
@@ -541,7 +546,7 @@
 
     // non-javadoc, see base class AbstractConnPool
     @Override
-    protected void handleLostEntry(HttpRoute route) {
+    protected void handleLostEntry(ConnRoute route) {
 
         try {
             poolLock.lock();

Modified: httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/PoolEntryRequest.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/PoolEntryRequest.java?rev=646549&r1=646548&r2=646549&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/PoolEntryRequest.java
(original)
+++ httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/PoolEntryRequest.java
Wed Apr  9 14:29:33 2008
@@ -1,7 +1,7 @@
 /*
- * $HeadURL:$
- * $Revision:$
- * $Date:$
+ * $HeadURL$
+ * $Revision$
+ * $Date$
  *
  * ====================================================================
  *
@@ -35,6 +35,7 @@
 import org.apache.http.conn.ClientConnectionOperator;
 import org.apache.http.conn.ConnectionPoolTimeoutException;
 import org.apache.http.conn.routing.HttpRoute;
+import org.apache.http.impl.conn.ConnRoute;
 
 /**
  * Encapsulates a request for a {@link BasicPoolEntry}.
@@ -60,9 +61,12 @@
      * @throws InterruptedException
      *         if the calling thread was interrupted
      */
-    BasicPoolEntry getPoolEntry(HttpRoute route, long timeout, TimeUnit unit,
-            ClientConnectionOperator operator) throws InterruptedException,
-            ConnectionPoolTimeoutException;
+    BasicPoolEntry getPoolEntry(
+            ConnRoute route, 
+            long timeout, 
+            TimeUnit unit,
+            ClientConnectionOperator operator) 
+                throws InterruptedException, ConnectionPoolTimeoutException;
 
     /**
      * Aborts the active or next call to

Modified: httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/RouteSpecificPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/RouteSpecificPool.java?rev=646549&r1=646548&r2=646549&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/RouteSpecificPool.java
(original)
+++ httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/RouteSpecificPool.java
Wed Apr  9 14:29:33 2008
@@ -33,7 +33,7 @@
 import java.util.Queue;
 import java.util.LinkedList;
 
-import org.apache.http.conn.routing.HttpRoute;
+import org.apache.http.impl.conn.ConnRoute;
 
 
 /**
@@ -44,7 +44,7 @@
 public class RouteSpecificPool {
 
     /** The route this pool is for. */
-    protected final HttpRoute route;
+    protected final ConnRoute route;
 
     /**
      * The list of free entries.
@@ -65,8 +65,8 @@
      *
      * @param r     the route for which to pool
      */
-    public RouteSpecificPool(HttpRoute r) {
-        this.route = r;
+    public RouteSpecificPool(ConnRoute route) {
+        this.route = route;
         this.freeEntries = new LinkedList<BasicPoolEntry>();
         this.waitingThreads = new LinkedList<WaitingThread>();
         this.numEntries = 0;
@@ -78,7 +78,7 @@
      *
      * @return  the route
      */
-    public final HttpRoute getRoute() {
+    public final ConnRoute getRoute() {
         return route;
     }
 

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=646549&r1=646548&r2=646549&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
Wed Apr  9 14:29:33 2008
@@ -45,6 +45,7 @@
 import org.apache.http.conn.OperatedClientConnection;
 import org.apache.http.params.HttpParams;
 import org.apache.http.impl.conn.DefaultClientConnectionOperator;
+import org.apache.http.impl.conn.ConnRoute;
 
 
 
@@ -147,7 +148,7 @@
     }
 
     
-    public ClientConnectionRequest requestConnection(final HttpRoute route) {
+    public ClientConnectionRequest requestConnection(final HttpRoute route, final Object
state) {
         
         final PoolEntryRequest poolRequest = connectionPool.newPoolEntryRequest();
         
@@ -169,7 +170,8 @@
                         + route + ", timeout = " + timeout);
                 }
 
-                final BasicPoolEntry entry = poolRequest.getPoolEntry(route, timeout, tunit,
connOperator);
+                final BasicPoolEntry entry = poolRequest.getPoolEntry(
+                        new ConnRoute(route, state), timeout, tunit, connOperator);
 
                 return new BasicPooledConnAdapter(ThreadSafeClientConnManager.this, entry);
             }
@@ -240,8 +242,9 @@
      *
      * @return  the total number of pooled connections for that route
      */
-    public int getConnectionsInPool(HttpRoute route) {
-        return ((ConnPoolByRoute)connectionPool).getConnectionsInPool(route);
+    public int getConnectionsInPool(HttpRoute route, Object state) {
+        return ((ConnPoolByRoute)connectionPool).getConnectionsInPool(
+                new ConnRoute(route, state));
     }
 
 

Modified: httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/client/TestDefaultClientRequestDirector.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/client/TestDefaultClientRequestDirector.java?rev=646549&r1=646548&r2=646549&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/client/TestDefaultClientRequestDirector.java
(original)
+++ httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/client/TestDefaultClientRequestDirector.java
Wed Apr  9 14:29:33 2008
@@ -343,7 +343,7 @@
         }
         
         @Override
-        public ClientConnectionRequest requestConnection(HttpRoute route) {
+        public ClientConnectionRequest requestConnection(HttpRoute route, Object state) {
             // If this is the redirect route, stub the return value
             // so-as to pretend the host is waiting on a slot...
             if(route.getTargetHost().getHostName().equals("localhost")) {
@@ -372,7 +372,7 @@
                     }
                 };  
             } else {
-                return super.requestConnection(route);
+                return super.requestConnection(route, state);
             }
         }
     }
@@ -387,8 +387,8 @@
         }
         
         @Override
-        public ManagedClientConnection getConnection(HttpRoute route) {
-            allocatedConnection = super.getConnection(route);
+        public ManagedClientConnection getConnection(HttpRoute route, Object state) {
+            allocatedConnection = super.getConnection(route, state);
             return allocatedConnection;
         }
         
@@ -423,7 +423,9 @@
             throw new UnsupportedOperationException("just a mockup");
         }
         
-        public ClientConnectionRequest requestConnection(final HttpRoute route) {
+        public ClientConnectionRequest requestConnection(
+                final HttpRoute route, 
+                final Object state) {
             
             return new ClientConnectionRequest() {
                 
@@ -489,7 +491,9 @@
             throw new UnsupportedOperationException("just a mockup");
         }
         
-        public ClientConnectionRequest requestConnection(final HttpRoute route) {
+        public ClientConnectionRequest requestConnection(
+                final HttpRoute route,
+                final Object state) {
             
             final Thread currentThread = Thread.currentThread();
             

Modified: httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/GetConnThread.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/GetConnThread.java?rev=646549&r1=646548&r2=646549&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/GetConnThread.java
(original)
+++ httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/GetConnThread.java
Wed Apr  9 14:29:33 2008
@@ -60,7 +60,7 @@
      */
     public GetConnThread(ClientConnectionManager mgr,
                          HttpRoute route, long timeout) {
-        this(mgr.requestConnection(route), route, timeout);
+        this(mgr.requestConnection(route, null), route, timeout);
     }
     
     /**

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=646549&r1=646548&r2=646549&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
Wed Apr  9 14:29:33 2008
@@ -79,14 +79,14 @@
             final HttpRoute route,
             long timeout,
             TimeUnit unit) throws ConnectionPoolTimeoutException, InterruptedException {
-        ClientConnectionRequest connRequest = mgr.requestConnection(route);
+        ClientConnectionRequest connRequest = mgr.requestConnection(route, null);
         return connRequest.getConnection(timeout, unit);
     }
     
     private static ManagedClientConnection getConnection(
             final ClientConnectionManager mgr, 
             final HttpRoute route) throws ConnectionPoolTimeoutException, InterruptedException
{
-        ClientConnectionRequest connRequest = mgr.requestConnection(route);
+        ClientConnectionRequest connRequest = mgr.requestConnection(route, null);
         return connRequest.getConnection(0, null);
     }
     
@@ -406,13 +406,13 @@
         assertEquals("connectionsInPool",
                      mgr.getConnectionsInPool(), 1);
         assertEquals("connectionsInPool(host)",
-                     mgr.getConnectionsInPool(route), 1);
+                     mgr.getConnectionsInPool(route, null), 1);
         mgr.releaseConnection(conn);
 
         assertEquals("connectionsInPool",
                      mgr.getConnectionsInPool(), 1);
         assertEquals("connectionsInPool(host)",
-                     mgr.getConnectionsInPool(route), 1);
+                     mgr.getConnectionsInPool(route, null), 1);
 
         // this implicitly deletes them
         mgr.closeIdleConnections(0L, TimeUnit.MILLISECONDS);
@@ -420,7 +420,7 @@
         assertEquals("connectionsInPool",
                      mgr.getConnectionsInPool(), 0);
         assertEquals("connectionsInPool(host)",
-                     mgr.getConnectionsInPool(route), 0);
+                     mgr.getConnectionsInPool(route, null), 0);
 
         mgr.shutdown();
     }
@@ -575,7 +575,7 @@
         
         // get the only connection, then start an extra thread
         ManagedClientConnection conn = getConnection(mgr, route, 1L, TimeUnit.MILLISECONDS);
-        ClientConnectionRequest request = mgr.requestConnection(route);
+        ClientConnectionRequest request = mgr.requestConnection(route, null);
         GetConnThread gct = new GetConnThread(request, route, 0L); // no timeout
         gct.start();
         Thread.sleep(100); // give extra thread time to block
@@ -617,7 +617,7 @@
 
         // get the only connection, then start an extra thread
         ManagedClientConnection conn = getConnection(mgr, route, 1L, TimeUnit.MILLISECONDS);
-        ClientConnectionRequest request = mgr.requestConnection(route);
+        ClientConnectionRequest request = mgr.requestConnection(route, null);
         request.abortRequest();
         
         GetConnThread gct = new GetConnThread(request, route, 0L); // no timeout

Modified: httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/TestTSCCMWithServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/TestTSCCMWithServer.java?rev=646549&r1=646548&r2=646549&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/TestTSCCMWithServer.java
(original)
+++ httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/TestTSCCMWithServer.java
Wed Apr  9 14:29:33 2008
@@ -181,14 +181,14 @@
             final HttpRoute route,
             long timeout,
             TimeUnit unit) throws ConnectionPoolTimeoutException, InterruptedException {
-        ClientConnectionRequest connRequest = mgr.requestConnection(route);
+        ClientConnectionRequest connRequest = mgr.requestConnection(route, null);
         return connRequest.getConnection(timeout, unit);
     }
     
     private static ManagedClientConnection getConnection(
             final ClientConnectionManager mgr, 
             final HttpRoute route) throws ConnectionPoolTimeoutException, InterruptedException
{
-        ClientConnectionRequest connRequest = mgr.requestConnection(route);
+        ClientConnectionRequest connRequest = mgr.requestConnection(route, null);
         return connRequest.getConnection(0, null);
     }
     

Modified: httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/tsccm/TestDumbHelpers.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/tsccm/TestDumbHelpers.java?rev=646549&r1=646548&r2=646549&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/tsccm/TestDumbHelpers.java
(original)
+++ httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/tsccm/TestDumbHelpers.java
Wed Apr  9 14:29:33 2008
@@ -50,6 +50,7 @@
 import org.apache.http.conn.scheme.SocketFactory;
 import org.apache.http.conn.ClientConnectionOperator;
 import org.apache.http.impl.conn.DefaultClientConnectionOperator;
+import org.apache.http.impl.conn.ConnRoute;
 
 
 
@@ -113,13 +114,13 @@
             // expected
         }
 
-        bpe = new BasicPoolEntry(ccop, route, null);
+        bpe = new BasicPoolEntry(ccop, new ConnRoute(route, null), null);
         assertEquals ("wrong operator", ccop, bpe.getOperator());
-        assertEquals ("wrong route", route, bpe.getPlannedRoute());
+        assertEquals ("wrong route", route, bpe.getPlannedRoute().getRoute());
         assertNotNull("missing ref", bpe.getWeakRef());
 
         assertEquals("bad weak ref", bpe, bpe.getWeakRef().get());
-        assertEquals("bad ref route", route, bpe.getWeakRef().getRoute());
+        assertEquals("bad ref route", route, bpe.getWeakRef().getRoute().getRoute());
     }
 
 

Modified: httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/tsccm/TestSpuriousWakeup.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/tsccm/TestSpuriousWakeup.java?rev=646549&r1=646548&r2=646549&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/tsccm/TestSpuriousWakeup.java
(original)
+++ httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/tsccm/TestSpuriousWakeup.java
Wed Apr  9 14:29:33 2008
@@ -151,7 +151,7 @@
 
         try {
             // take out the only connection
-            ClientConnectionRequest connRequest = mgr.requestConnection(ROUTE);
+            ClientConnectionRequest connRequest = mgr.requestConnection(ROUTE, null);
             ManagedClientConnection conn = connRequest.getConnection(0, null);
             assertNotNull(conn);
 

Modified: httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/tsccm/TestWaitingThread.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/tsccm/TestWaitingThread.java?rev=646549&r1=646548&r2=646549&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/tsccm/TestWaitingThread.java
(original)
+++ httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/tsccm/TestWaitingThread.java
Wed Apr  9 14:29:33 2008
@@ -40,6 +40,7 @@
 
 import org.apache.http.HttpHost;
 import org.apache.http.conn.routing.HttpRoute;
+import org.apache.http.impl.conn.ConnRoute;
 
 
 
@@ -83,7 +84,7 @@
         assertNull  ("thread from nowhere", wt.getThread());
 
         HttpRoute         route = new HttpRoute(TARGET);
-        RouteSpecificPool rospl = new RouteSpecificPool(route);
+        RouteSpecificPool rospl = new RouteSpecificPool(new ConnRoute(route, null));
         wt = new WaitingThread(cnd, rospl);
         assertEquals("wrong condition", cnd, wt.getCondition());
         assertEquals("wrong pool", rospl, wt.getPool());



Mime
View raw message