You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2011/08/18 10:00:01 UTC
svn commit: r1159072 - in /httpcomponents/httpasyncclient/trunk: ./
httpasyncclient/src/examples/org/apache/http/examples/nio/client/
httpasyncclient/src/main/java/org/apache/http/impl/nio/client/
httpasyncclient/src/main/java/org/apache/http/impl/nio/...
Author: olegk
Date: Thu Aug 18 08:00:00 2011
New Revision: 1159072
URL: http://svn.apache.org/viewvc?rev=1159072&view=rev
Log:
Redesigned connection management code based on HttpCore 4.2 API (merged from conn-mgmt-redesign branch)
Added:
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/HttpNIOConnPool.java
- copied unchanged from r1159070, httpcomponents/httpasyncclient/branches/conn-mgmt-redesign/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/HttpNIOConnPool.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/ManagedClientConnectionImpl.java
- copied unchanged from r1159070, httpcomponents/httpasyncclient/branches/conn-mgmt-redesign/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/ManagedClientConnectionImpl.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/resources/commons-logging.properties
- copied unchanged from r1159070, httpcomponents/httpasyncclient/branches/conn-mgmt-redesign/httpasyncclient/src/test/resources/commons-logging.properties
Removed:
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/ClientConnAdaptor.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/HttpSessionPool.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/pool/
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/concurrent/
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/PoolStats.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/concurrent/
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/pool/
Modified:
httpcomponents/httpasyncclient/trunk/ (props changed)
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/examples/org/apache/http/examples/nio/client/AsyncClientHttpExchangeFutureCallback.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/examples/org/apache/http/examples/nio/client/ZeroCopyHttpExchange.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/AbstractHttpAsyncClient.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultResultCallback.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/DefaultClientConnection.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/HttpPoolEntry.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/PoolingClientConnectionManager.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/HttpAsyncClient.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncCharConsumer.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseZeroCopyRequestProducer.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncMethods.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/ZeroCopyConsumer.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/ZeroCopyPost.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/ZeroCopyPut.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/ClientConnectionManager.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/ManagedClientConnection.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/OperatedClientConnection.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestHttpAsync.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestHttpsAsync.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/localserver/ (props changed)
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/methods/TestAsyncConsumers.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/methods/TestZeroCopy.java
httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/resources/test.keystore (props changed)
httpcomponents/httpasyncclient/trunk/pom.xml
Propchange: httpcomponents/httpasyncclient/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Thu Aug 18 08:00:00 2011
@@ -0,0 +1 @@
+/httpcomponents/httpasyncclient/branches/conn-mgmt-redesign:1155312-1159070
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/examples/org/apache/http/examples/nio/client/AsyncClientHttpExchangeFutureCallback.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/examples/org/apache/http/examples/nio/client/AsyncClientHttpExchangeFutureCallback.java?rev=1159072&r1=1159071&r2=1159072&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/examples/org/apache/http/examples/nio/client/AsyncClientHttpExchangeFutureCallback.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/examples/org/apache/http/examples/nio/client/AsyncClientHttpExchangeFutureCallback.java Thu Aug 18 08:00:00 2011
@@ -30,9 +30,9 @@ import java.util.concurrent.CountDownLat
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
+import org.apache.http.concurrent.FutureCallback;
import org.apache.http.impl.nio.client.DefaultHttpAsyncClient;
import org.apache.http.nio.client.HttpAsyncClient;
-import org.apache.http.nio.concurrent.FutureCallback;
public class AsyncClientHttpExchangeFutureCallback {
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/examples/org/apache/http/examples/nio/client/ZeroCopyHttpExchange.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/examples/org/apache/http/examples/nio/client/ZeroCopyHttpExchange.java?rev=1159072&r1=1159071&r2=1159072&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/examples/org/apache/http/examples/nio/client/ZeroCopyHttpExchange.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/examples/org/apache/http/examples/nio/client/ZeroCopyHttpExchange.java Thu Aug 18 08:00:00 2011
@@ -32,6 +32,7 @@ import java.util.concurrent.Future;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.ClientProtocolException;
+import org.apache.http.entity.ContentType;
import org.apache.http.impl.nio.client.DefaultHttpAsyncClient;
import org.apache.http.nio.client.HttpAsyncClient;
import org.apache.http.nio.client.methods.ZeroCopyConsumer;
@@ -45,7 +46,8 @@ public class ZeroCopyHttpExchange {
try {
File upload = new File(args[0]);
File download = new File(args[1]);
- ZeroCopyPost httpost = new ZeroCopyPost("http://localhost:8080/", upload, "text/plain");
+ ZeroCopyPost httpost = new ZeroCopyPost("http://localhost:8080/", upload,
+ ContentType.create("text/plain", null));
ZeroCopyConsumer<File> consumer = new ZeroCopyConsumer<File>(download) {
@Override
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/AbstractHttpAsyncClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/AbstractHttpAsyncClient.java?rev=1159072&r1=1159071&r2=1159072&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/AbstractHttpAsyncClient.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/AbstractHttpAsyncClient.java Thu Aug 18 08:00:00 2011
@@ -51,6 +51,8 @@ import org.apache.http.client.params.Aut
import org.apache.http.client.params.CookiePolicy;
import org.apache.http.client.protocol.ClientContext;
import org.apache.http.client.utils.URIUtils;
+import org.apache.http.concurrent.BasicFuture;
+import org.apache.http.concurrent.FutureCallback;
import org.apache.http.conn.ConnectionKeepAliveStrategy;
import org.apache.http.conn.routing.HttpRoutePlanner;
import org.apache.http.cookie.CookieSpecRegistry;
@@ -79,8 +81,6 @@ import org.apache.http.nio.client.HttpAs
import org.apache.http.nio.client.HttpAsyncRequestProducer;
import org.apache.http.nio.client.HttpAsyncResponseConsumer;
import org.apache.http.nio.client.methods.HttpAsyncMethods;
-import org.apache.http.nio.concurrent.BasicFuture;
-import org.apache.http.nio.concurrent.FutureCallback;
import org.apache.http.nio.conn.ClientConnectionManager;
import org.apache.http.nio.reactor.IOEventDispatch;
import org.apache.http.nio.reactor.IOReactorException;
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java?rev=1159072&r1=1159071&r2=1159072&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java Thu Aug 18 08:00:00 2011
@@ -62,6 +62,7 @@ import org.apache.http.client.params.Cli
import org.apache.http.client.params.HttpClientParams;
import org.apache.http.client.protocol.ClientContext;
import org.apache.http.client.utils.URIUtils;
+import org.apache.http.concurrent.FutureCallback;
import org.apache.http.conn.ConnectionKeepAliveStrategy;
import org.apache.http.conn.routing.BasicRouteDirector;
import org.apache.http.conn.routing.HttpRoute;
@@ -78,7 +79,6 @@ import org.apache.http.nio.IOControl;
import org.apache.http.nio.client.HttpAsyncExchangeHandler;
import org.apache.http.nio.client.HttpAsyncRequestProducer;
import org.apache.http.nio.client.HttpAsyncResponseConsumer;
-import org.apache.http.nio.concurrent.FutureCallback;
import org.apache.http.nio.conn.ClientConnectionManager;
import org.apache.http.nio.conn.ManagedClientConnection;
import org.apache.http.nio.conn.scheme.Scheme;
@@ -377,7 +377,7 @@ class DefaultAsyncRequestDirector<T> imp
}
this.managedConn.setIdleDuration(duration, TimeUnit.MILLISECONDS);
} else {
- this.managedConn.markNonReusable();
+ this.managedConn.unmarkReusable();
releaseConnection();
invalidateAuthIfSuccessful(this.proxyAuthState);
invalidateAuthIfSuccessful(this.targetAuthState);
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultResultCallback.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultResultCallback.java?rev=1159072&r1=1159071&r2=1159072&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultResultCallback.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultResultCallback.java Thu Aug 18 08:00:00 2011
@@ -28,8 +28,8 @@ package org.apache.http.impl.nio.client;
import java.util.Queue;
+import org.apache.http.concurrent.BasicFuture;
import org.apache.http.nio.client.HttpAsyncExchangeHandler;
-import org.apache.http.nio.concurrent.BasicFuture;
class DefaultResultCallback<T> implements ResultCallback<T> {
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/DefaultClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/DefaultClientConnection.java?rev=1159072&r1=1159071&r2=1159072&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/DefaultClientConnection.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/DefaultClientConnection.java Thu Aug 18 08:00:00 2011
@@ -28,7 +28,6 @@ package org.apache.http.impl.nio.conn;
import java.io.IOException;
import java.nio.channels.ReadableByteChannel;
-import java.util.concurrent.atomic.AtomicLong;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -55,18 +54,17 @@ public class DefaultClientConnection
private final Log wirelog = LogFactory.getLog("org.apache.http.wire");
private final Log log;
- private static final AtomicLong COUNT = new AtomicLong();
-
private String id;
private SSLIOSession ssliosession;
public DefaultClientConnection(
+ final String id,
final IOSession iosession,
final HttpResponseFactory responseFactory,
final ByteBufferAllocator allocator,
final HttpParams params) {
super(iosession, responseFactory, allocator, params);
- this.id = "http-outgoing-" + COUNT.incrementAndGet();
+ this.id = id;
this.log = LogFactory.getLog(iosession.getClass());
if (this.log.isDebugEnabled() || this.wirelog.isDebugEnabled()) {
this.session = new LoggingIOSession(iosession, this.id, this.log, this.wirelog);
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/HttpPoolEntry.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/HttpPoolEntry.java?rev=1159072&r1=1159071&r2=1159072&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/HttpPoolEntry.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/HttpPoolEntry.java Thu Aug 18 08:00:00 2011
@@ -32,62 +32,40 @@ import java.util.concurrent.TimeUnit;
import org.apache.commons.logging.Log;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.conn.routing.RouteTracker;
-import org.apache.http.impl.nio.pool.PoolEntry;
-import org.apache.http.nio.conn.OperatedClientConnection;
import org.apache.http.nio.reactor.IOSession;
-import org.apache.http.protocol.ExecutionContext;
+import org.apache.http.pool.PoolEntry;
-class HttpPoolEntry extends PoolEntry<HttpRoute> {
+class HttpPoolEntry extends PoolEntry<HttpRoute, IOSession> {
private final Log log;
private final RouteTracker tracker;
- HttpPoolEntry(final Log log, final HttpRoute route, final IOSession session,
+ HttpPoolEntry(final Log log, final String id, final HttpRoute route, final IOSession session,
final long timeToLive, final TimeUnit tunit) {
- super(route, session, timeToLive, tunit);
+ super(id, route, session, timeToLive, tunit);
this.log = log;
this.tracker = new RouteTracker(route);
}
@Override
- public IOSession getIOSession() {
- return super.getIOSession();
+ public boolean isExpired(long now) {
+ boolean expired = super.isExpired(now);
+ if (expired && this.log.isDebugEnabled()) {
+ this.log.debug("Connection " + this + " expired @ " + new Date(getExpiry()));
+ }
+ return expired;
}
- public HttpRoute getPlannedRoute() {
+ HttpRoute getPlannedRoute() {
return super.getRoute();
}
- @Override
- public Object getState() {
- return super.getState();
- }
-
- @Override
- public void setState(final Object state) {
- super.setState(state);
- }
-
- protected RouteTracker getTracker() {
+ RouteTracker getTracker() {
return this.tracker;
}
- public HttpRoute getEffectiveRoute() {
+ HttpRoute getEffectiveRoute() {
return this.tracker.toRoute();
}
- @Override
- public boolean isExpired(long now) {
- boolean expired = super.isExpired(now);
- if (expired && this.log.isDebugEnabled()) {
- this.log.debug("Connection " + this + " expired @ " + new Date(getExpiry()));
- }
- return expired;
- }
-
- public OperatedClientConnection getConnection() {
- return (OperatedClientConnection) getIOSession().getAttribute(
- ExecutionContext.HTTP_CONNECTION);
- }
-
}
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/PoolingClientConnectionManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/PoolingClientConnectionManager.java?rev=1159072&r1=1159071&r2=1159072&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/PoolingClientConnectionManager.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/PoolingClientConnectionManager.java Thu Aug 18 08:00:00 2011
@@ -32,25 +32,25 @@ import java.util.concurrent.TimeUnit;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.http.concurrent.BasicFuture;
+import org.apache.http.concurrent.FutureCallback;
import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.impl.nio.pool.PoolEntryCallback;
-import org.apache.http.nio.concurrent.BasicFuture;
-import org.apache.http.nio.concurrent.FutureCallback;
import org.apache.http.nio.conn.ManagedClientConnection;
import org.apache.http.nio.conn.ClientConnectionManager;
-import org.apache.http.nio.conn.PoolStats;
import org.apache.http.nio.conn.scheme.SchemeRegistry;
import org.apache.http.nio.reactor.ConnectingIOReactor;
import org.apache.http.nio.reactor.IOEventDispatch;
import org.apache.http.nio.reactor.IOReactorException;
import org.apache.http.nio.reactor.IOReactorStatus;
+import org.apache.http.pool.ConnPoolControl;
+import org.apache.http.pool.PoolStats;
-public class PoolingClientConnectionManager implements ClientConnectionManager {
+public class PoolingClientConnectionManager implements ClientConnectionManager, ConnPoolControl<HttpRoute> {
private final Log log = LogFactory.getLog(getClass());
private final ConnectingIOReactor ioreactor;
- private final HttpSessionPool pool;
+ private final HttpNIOConnPool pool;
private final SchemeRegistry schemeRegistry;
public PoolingClientConnectionManager(
@@ -68,7 +68,7 @@ public class PoolingClientConnectionMana
throw new IllegalArgumentException("Time unit may not be null");
}
this.ioreactor = ioreactor;
- this.pool = new HttpSessionPool(this.log, ioreactor, schemeRegistry, timeToLive, tunit);
+ this.pool = new HttpNIOConnPool(this.log, ioreactor, schemeRegistry, timeToLive, tunit);
this.schemeRegistry = schemeRegistry;
}
@@ -83,6 +83,15 @@ public class PoolingClientConnectionMana
this(ioreactor, SchemeRegistryFactory.createDefault());
}
+ @Override
+ protected void finalize() throws Throwable {
+ try {
+ shutdown();
+ } finally {
+ super.finalize();
+ }
+ }
+
public SchemeRegistry getSchemeRegistry() {
return this.schemeRegistry;
}
@@ -107,10 +116,42 @@ public class PoolingClientConnectionMana
this.log.debug("Connection manager shut down");
}
+ private String format(final HttpRoute route, final Object state) {
+ StringBuilder buf = new StringBuilder();
+ buf.append("[route: ").append(route).append("]");
+ if (state != null) {
+ buf.append("[state: ").append(state).append("]");
+ }
+ return buf.toString();
+ }
+
+ private String formatStats(final HttpRoute route) {
+ StringBuilder buf = new StringBuilder();
+ PoolStats totals = this.pool.getTotalStats();
+ PoolStats stats = this.pool.getStats(route);
+ buf.append("[total kept alive: ").append(totals.getAvailable()).append("; ");
+ buf.append("route allocated: ").append(stats.getLeased() + stats.getAvailable());
+ buf.append(" of ").append(stats.getMax()).append("; ");
+ buf.append("total allocated: ").append(totals.getLeased() + totals.getAvailable());
+ buf.append(" of ").append(totals.getMax()).append("]");
+ return buf.toString();
+ }
+
+ private String format(final HttpPoolEntry entry) {
+ StringBuilder buf = new StringBuilder();
+ buf.append("[id: ").append(entry.getId()).append("]");
+ buf.append("[route: ").append(entry.getRoute()).append("]");
+ Object state = entry.getState();
+ if (state != null) {
+ buf.append("[state: ").append(state).append("]");
+ }
+ return buf.toString();
+ }
+
public Future<ManagedClientConnection> leaseConnection(
final HttpRoute route,
final Object state,
- final long timeout,
+ final long connectTimeout,
final TimeUnit tunit,
final FutureCallback<ManagedClientConnection> callback) {
if (route == null) {
@@ -120,70 +161,69 @@ public class PoolingClientConnectionMana
throw new IllegalArgumentException("Time unit may not be null");
}
if (this.log.isDebugEnabled()) {
- this.log.debug("Connection request: route[" + route + "][state: " + state + "]");
- PoolStats totals = this.pool.getTotalStats();
- PoolStats stats = this.pool.getStats(route);
- this.log.debug("Total: " + totals);
- this.log.debug("Route [" + route + "]: " + stats);
+ this.log.debug("Connection request: " + format(route, state) + formatStats(route));
}
BasicFuture<ManagedClientConnection> future = new BasicFuture<ManagedClientConnection>(
callback);
- this.pool.lease(route, state, timeout, tunit, new InternalPoolEntryCallback(future));
- if (this.log.isDebugEnabled()) {
- if (!future.isDone()) {
- this.log.debug("Connection could not be allocated immediately: " +
- "route[" + route + "][state: " + state + "]");
- }
- }
+ this.pool.lease(route, state, connectTimeout, tunit, new InternalPoolEntryCallback(future));
return future;
}
public void releaseConnection(
final ManagedClientConnection conn,
- final long validDuration,
+ final long keepalive,
final TimeUnit tunit) {
if (conn == null) {
throw new IllegalArgumentException("HTTP connection may not be null");
}
- if (!(conn instanceof ClientConnAdaptor)) {
+ if (!(conn instanceof ManagedClientConnectionImpl)) {
throw new IllegalArgumentException("Connection class mismatch, " +
"connection not obtained from this manager");
}
if (tunit == null) {
throw new IllegalArgumentException("Time unit may not be null");
}
- ClientConnAdaptor adaptor = (ClientConnAdaptor) conn;
- ClientConnectionManager manager = adaptor.getManager();
+ ManagedClientConnectionImpl managedConn = (ManagedClientConnectionImpl) conn;
+ ClientConnectionManager manager = managedConn.getManager();
if (manager != null && manager != this) {
throw new IllegalArgumentException("Connection not obtained from this manager");
}
if (this.pool.isShutdown()) {
return;
}
- HttpPoolEntry entry = adaptor.getEntry();
- if (this.log.isDebugEnabled()) {
- HttpRoute route = entry.getPlannedRoute();
- this.log.debug("Releasing connection: " + entry);
- PoolStats totals = this.pool.getTotalStats();
- PoolStats stats = this.pool.getStats(route);
- this.log.debug("Total: " + totals);
- this.log.debug("Route [" + route + "]: " + stats);
- }
- boolean reusable = adaptor.isReusable();
- if (reusable) {
- entry.updateExpiry(validDuration, tunit);
- if (this.log.isDebugEnabled()) {
- String s;
- if (validDuration > 0) {
- s = "for " + validDuration + " " + tunit;
- } else {
- s = "indefinitely";
+ synchronized (managedConn) {
+ HttpPoolEntry entry = managedConn.detach();
+ if (entry == null) {
+ return;
+ }
+ try {
+ if (managedConn.isOpen() && !managedConn.isMarkedReusable()) {
+ try {
+ managedConn.shutdown();
+ } catch (IOException iox) {
+ if (this.log.isDebugEnabled()) {
+ this.log.debug("I/O exception shutting down released connection", iox);
+ }
+ }
+ }
+ entry.updateExpiry(keepalive, tunit != null ? tunit : TimeUnit.MILLISECONDS);
+ if (this.log.isDebugEnabled()) {
+ String s;
+ if (keepalive > 0) {
+ s = "for " + keepalive + " " + tunit;
+ } else {
+ s = "indefinitely";
+ }
+ this.log.debug("Connection " + format(entry) + " can be kept alive " + s);
}
- this.log.debug("Pooling connection: " + entry + "; keep alive " + s);
+ } finally {
+ this.pool.release(entry, managedConn.isMarkedReusable());
+ }
+ if (this.log.isDebugEnabled()) {
+ this.log.debug("Connection released: " + format(entry) + formatStats(entry.getRoute()));
}
}
- this.pool.release(entry, reusable);
}
public PoolStats getTotalStats() {
@@ -194,16 +234,31 @@ public class PoolingClientConnectionMana
return this.pool.getStats(route);
}
+ @Deprecated
public void setTotalMax(int max) {
- this.pool.setTotalMax(max);
+ this.pool.setMaxTotal(max);
}
+ public void setMaxTotal(int max) {
+ this.pool.setMaxTotal(max);
+ }
+
+ @Deprecated
public void setDefaultMaxPerHost(int max) {
- this.pool.setDefaultMaxPerHost(max);
+ this.pool.setDefaultMaxPerRoute(max);
+ }
+
+ public void setDefaultMaxPerRoute(int max) {
+ this.pool.setDefaultMaxPerRoute(max);
}
+ @Deprecated
public void setMaxPerHost(final HttpRoute route, int max) {
- this.pool.setMaxPerHost(route, max);
+ this.pool.setMaxPerRoute(route, max);
+ }
+
+ public void setMaxPerRoute(final HttpRoute route, int max) {
+ this.pool.setMaxPerRoute(route, max);
}
public void closeIdleConnections(long idleTimeout, final TimeUnit tunit) {
@@ -218,7 +273,7 @@ public class PoolingClientConnectionMana
this.pool.closeExpired();
}
- class InternalPoolEntryCallback implements PoolEntryCallback<HttpRoute, HttpPoolEntry> {
+ class InternalPoolEntryCallback implements FutureCallback<HttpPoolEntry> {
private final BasicFuture<ManagedClientConnection> future;
@@ -230,9 +285,9 @@ public class PoolingClientConnectionMana
public void completed(final HttpPoolEntry entry) {
if (log.isDebugEnabled()) {
- log.debug("Connection allocated: " + entry);
+ log.debug("Connection leased: " + format(entry) + formatStats(entry.getRoute()));
}
- ManagedClientConnection conn = new ClientConnAdaptor(
+ ManagedClientConnection conn = new ManagedClientConnectionImpl(
PoolingClientConnectionManager.this,
entry);
if (!this.future.completed(conn)) {
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/HttpAsyncClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/HttpAsyncClient.java?rev=1159072&r1=1159071&r2=1159072&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/HttpAsyncClient.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/HttpAsyncClient.java Thu Aug 18 08:00:00 2011
@@ -32,7 +32,7 @@ import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.nio.concurrent.FutureCallback;
+import org.apache.http.concurrent.FutureCallback;
import org.apache.http.nio.conn.ClientConnectionManager;
import org.apache.http.nio.reactor.IOReactorStatus;
import org.apache.http.params.HttpParams;
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncCharConsumer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncCharConsumer.java?rev=1159072&r1=1159071&r2=1159072&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncCharConsumer.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncCharConsumer.java Thu Aug 18 08:00:00 2011
@@ -38,15 +38,15 @@ import java.nio.charset.UnsupportedChars
import org.apache.http.HttpEntity;
import org.apache.http.HttpException;
import org.apache.http.HttpResponse;
+import org.apache.http.entity.ContentType;
import org.apache.http.nio.ContentDecoder;
import org.apache.http.nio.IOControl;
import org.apache.http.protocol.HTTP;
-import org.apache.http.util.EntityUtils;
public abstract class AsyncCharConsumer<T> extends AbstractHttpAsyncResponseConsumer<T> {
private final int bufSize;
- private String charsetName;
+ private ContentType contentType;
private Charset charset;
private CharsetDecoder chardecoder;
private ByteBuffer bbuf;
@@ -68,12 +68,7 @@ public abstract class AsyncCharConsumer<
public synchronized void responseReceived(
final HttpResponse response) throws IOException, HttpException {
HttpEntity entity = response.getEntity();
- if (entity != null) {
- this.charsetName = EntityUtils.getContentCharSet(entity);
- }
- if (this.charsetName == null) {
- this.charsetName = HTTP.DEFAULT_CONTENT_CHARSET;
- }
+ this.contentType = ContentType.getOrDefault(entity);
super.responseReceived(response);
}
@@ -82,9 +77,13 @@ public abstract class AsyncCharConsumer<
final ContentDecoder decoder, final IOControl ioctrl) throws IOException {
if (this.charset == null) {
try {
- this.charset = Charset.forName(this.charsetName);
+ String cs = this.contentType.getCharset();
+ if (cs == null) {
+ cs = HTTP.DEFAULT_CONTENT_CHARSET;
+ }
+ this.charset = Charset.forName(cs);
} catch (UnsupportedCharsetException ex) {
- throw new UnsupportedEncodingException(this.charsetName);
+ throw new UnsupportedEncodingException(this.contentType.getCharset());
}
this.chardecoder = this.charset.newDecoder();
this.bbuf = ByteBuffer.allocate(this.bufSize);
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseZeroCopyRequestProducer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseZeroCopyRequestProducer.java?rev=1159072&r1=1159071&r2=1159072&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseZeroCopyRequestProducer.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/BaseZeroCopyRequestProducer.java Thu Aug 18 08:00:00 2011
@@ -40,6 +40,7 @@ import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.client.utils.URIUtils;
import org.apache.http.entity.BasicHttpEntity;
+import org.apache.http.entity.ContentType;
import org.apache.http.nio.ContentEncoder;
import org.apache.http.nio.ContentEncoderChannel;
import org.apache.http.nio.FileContentEncoder;
@@ -50,13 +51,13 @@ abstract class BaseZeroCopyRequestProduc
private final URI requestURI;
private final File file;
- private final String contentType;
+ private final ContentType contentType;
private FileChannel fileChannel;
private long idx = -1;
protected BaseZeroCopyRequestProducer(
- final URI requestURI, final File file, final String contentType) {
+ final URI requestURI, final File file, final ContentType contentType) {
super();
if (requestURI == null) {
throw new IllegalArgumentException("Request URI may not be null");
@@ -75,7 +76,9 @@ abstract class BaseZeroCopyRequestProduc
BasicHttpEntity entity = new BasicHttpEntity();
entity.setChunked(false);
entity.setContentLength(this.file.length());
- entity.setContentType(this.contentType);
+ if (this.contentType != null) {
+ entity.setContentType(this.contentType.toString());
+ }
return createRequest(this.requestURI, entity);
}
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncMethods.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncMethods.java?rev=1159072&r1=1159071&r2=1159072&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncMethods.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/HttpAsyncMethods.java Thu Aug 18 08:00:00 2011
@@ -41,11 +41,11 @@ import org.apache.http.client.methods.Ht
import org.apache.http.client.methods.HttpTrace;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.client.utils.URIUtils;
+import org.apache.http.entity.ContentType;
import org.apache.http.nio.client.HttpAsyncRequestProducer;
import org.apache.http.nio.client.HttpAsyncResponseConsumer;
import org.apache.http.nio.entity.NByteArrayEntity;
import org.apache.http.nio.entity.NStringEntity;
-import org.apache.http.protocol.HTTP;
public final class HttpAsyncMethods {
@@ -110,16 +110,9 @@ public final class HttpAsyncMethods {
public static HttpAsyncRequestProducer createPost(
final URI requestURI,
final String content,
- String mimeType, String charset) throws UnsupportedEncodingException {
+ final ContentType contentType) throws UnsupportedEncodingException {
HttpPost httppost = new HttpPost(requestURI);
- if (mimeType == null) {
- mimeType = HTTP.PLAIN_TEXT_TYPE;
- }
- if (charset == null) {
- charset = HTTP.DEFAULT_CONTENT_CHARSET;
- }
- NStringEntity entity = new NStringEntity(content, charset);
- entity.setContentType(mimeType + HTTP.CHARSET_PARAM + charset);
+ NStringEntity entity = new NStringEntity(content, contentType);
httppost.setEntity(entity);
HttpHost target = URIUtils.extractHost(requestURI);
return new HttpAsyncRequestProducerImpl(target, httppost, entity);
@@ -128,39 +121,33 @@ public final class HttpAsyncMethods {
public static HttpAsyncRequestProducer createPost(
final String requestURI,
final String content,
- String mimeType, String charset) throws UnsupportedEncodingException {
- return createPost(URI.create(requestURI), content, mimeType, charset);
+ final ContentType contentType) throws UnsupportedEncodingException {
+ return createPost(URI.create(requestURI), content, contentType);
}
public static HttpAsyncRequestProducer createPost(
final URI requestURI,
- final byte[] content, final String contentType) {
+ final byte[] content,
+ final ContentType contentType) {
HttpPost httppost = new HttpPost(requestURI);
- NByteArrayEntity entity = new NByteArrayEntity(content);
- entity.setContentType(contentType);
+ NByteArrayEntity entity = new NByteArrayEntity(content, contentType);
HttpHost target = URIUtils.extractHost(requestURI);
return new HttpAsyncRequestProducerImpl(target, httppost, entity);
}
public static HttpAsyncRequestProducer createPost(
final String requestURI,
- final byte[] content, final String contentType) {
+ final byte[] content,
+ final ContentType contentType) {
return createPost(URI.create(requestURI), content, contentType);
}
public static HttpAsyncRequestProducer createPut(
final URI requestURI,
final String content,
- String mimeType, String charset) throws UnsupportedEncodingException {
+ final ContentType contentType) throws UnsupportedEncodingException {
HttpPut httpput = new HttpPut(requestURI);
- if (mimeType == null) {
- mimeType = HTTP.PLAIN_TEXT_TYPE;
- }
- if (charset == null) {
- charset = HTTP.DEFAULT_CONTENT_CHARSET;
- }
- NStringEntity entity = new NStringEntity(content, charset);
- entity.setContentType(mimeType + HTTP.CHARSET_PARAM + charset);
+ NStringEntity entity = new NStringEntity(content, contentType);
httpput.setEntity(entity);
HttpHost target = URIUtils.extractHost(requestURI);
return new HttpAsyncRequestProducerImpl(target, httpput, entity);
@@ -169,52 +156,52 @@ public final class HttpAsyncMethods {
public static HttpAsyncRequestProducer createPut(
final String requestURI,
final String content,
- String mimeType, String charset) throws UnsupportedEncodingException {
- return createPut(URI.create(requestURI), content, mimeType, charset);
+ final ContentType contentType) throws UnsupportedEncodingException {
+ return createPut(URI.create(requestURI), content, contentType);
}
public static HttpAsyncRequestProducer createPut(
final URI requestURI,
final byte[] content,
- final String contentType) {
+ final ContentType contentType) {
HttpPut httpput = new HttpPut(requestURI);
- NByteArrayEntity entity = new NByteArrayEntity(content);
- entity.setContentType(contentType);
+ NByteArrayEntity entity = new NByteArrayEntity(content, contentType);
HttpHost target = URIUtils.extractHost(requestURI);
return new HttpAsyncRequestProducerImpl(target, httpput, entity);
}
public static HttpAsyncRequestProducer createPut(
final String requestURI,
- final byte[] content, final String contentType) {
+ final byte[] content,
+ final ContentType contentType) {
return createPut(URI.create(requestURI), content, contentType);
}
public static HttpAsyncRequestProducer createZeroCopyPost(
final URI requestURI,
final File content,
- final String contentType) {
+ final ContentType contentType) {
return new ZeroCopyPost(requestURI, content, contentType);
}
public static HttpAsyncRequestProducer createZeroCopyPost(
final String requestURI,
final File content,
- final String contentType) {
+ final ContentType contentType) {
return new ZeroCopyPost(URI.create(requestURI), content, contentType);
}
public static HttpAsyncRequestProducer createZeroCopyPut(
final URI requestURI,
final File content,
- final String contentType) {
+ final ContentType contentType) {
return new ZeroCopyPut(requestURI, content, contentType);
}
public static HttpAsyncRequestProducer createZeroCopyPut(
final String requestURI,
final File content,
- final String contentType) {
+ final ContentType contentType) {
return new ZeroCopyPut(URI.create(requestURI), content, contentType);
}
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/ZeroCopyConsumer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/ZeroCopyConsumer.java?rev=1159072&r1=1159071&r2=1159072&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/ZeroCopyConsumer.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/ZeroCopyConsumer.java Thu Aug 18 08:00:00 2011
@@ -89,7 +89,7 @@ public abstract class ZeroCopyConsumer<T
@Override
protected T buildResult() throws Exception {
- FileEntity entity = new FileEntity(this.file, null);
+ FileEntity entity = new FileEntity(this.file);
entity.setContentType(this.response.getFirstHeader(HTTP.CONTENT_TYPE));
this.response.setEntity(entity);
return process(this.response, this.file);
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/ZeroCopyPost.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/ZeroCopyPost.java?rev=1159072&r1=1159071&r2=1159072&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/ZeroCopyPost.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/ZeroCopyPost.java Thu Aug 18 08:00:00 2011
@@ -32,14 +32,15 @@ import java.net.URI;
import org.apache.http.HttpEntity;
import org.apache.http.HttpEntityEnclosingRequest;
import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.ContentType;
public class ZeroCopyPost extends BaseZeroCopyRequestProducer {
- public ZeroCopyPost(final URI requestURI, final File content, final String contentType) {
+ public ZeroCopyPost(final URI requestURI, final File content, final ContentType contentType) {
super(requestURI, content, contentType);
}
- public ZeroCopyPost(final String requestURI, final File content, final String contentType) {
+ public ZeroCopyPost(final String requestURI, final File content, final ContentType contentType) {
super(URI.create(requestURI), content, contentType);
}
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/ZeroCopyPut.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/ZeroCopyPut.java?rev=1159072&r1=1159071&r2=1159072&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/ZeroCopyPut.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/ZeroCopyPut.java Thu Aug 18 08:00:00 2011
@@ -32,14 +32,15 @@ import java.net.URI;
import org.apache.http.HttpEntity;
import org.apache.http.HttpEntityEnclosingRequest;
import org.apache.http.client.methods.HttpPut;
+import org.apache.http.entity.ContentType;
public class ZeroCopyPut extends BaseZeroCopyRequestProducer {
- public ZeroCopyPut(final URI requestURI, final File content, final String contentType) {
+ public ZeroCopyPut(final URI requestURI, final File content, final ContentType contentType) {
super(requestURI, content, contentType);
}
- public ZeroCopyPut(final String requestURI, final File content, final String contentType) {
+ public ZeroCopyPut(final String requestURI, final File content, final ContentType contentType) {
super(URI.create(requestURI), content, contentType);
}
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/ClientConnectionManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/ClientConnectionManager.java?rev=1159072&r1=1159071&r2=1159072&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/ClientConnectionManager.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/ClientConnectionManager.java Thu Aug 18 08:00:00 2011
@@ -29,8 +29,8 @@ package org.apache.http.nio.conn;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
+import org.apache.http.concurrent.FutureCallback;
import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.nio.concurrent.FutureCallback;
import org.apache.http.nio.conn.scheme.SchemeRegistry;
import org.apache.http.nio.reactor.IOReactor;
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/ManagedClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/ManagedClientConnection.java?rev=1159072&r1=1159071&r2=1159072&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/ManagedClientConnection.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/ManagedClientConnection.java Thu Aug 18 08:00:00 2011
@@ -46,9 +46,9 @@ public interface ManagedClientConnection
void markReusable();
- void markNonReusable();
+ void unmarkReusable();
- boolean isReusable();
+ boolean isMarkedReusable();
void open(HttpRoute route, HttpContext context, HttpParams params) throws IOException;
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/OperatedClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/OperatedClientConnection.java?rev=1159072&r1=1159071&r2=1159072&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/OperatedClientConnection.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/OperatedClientConnection.java Thu Aug 18 08:00:00 2011
@@ -26,12 +26,14 @@
*/
package org.apache.http.nio.conn;
+import org.apache.http.HttpInetConnection;
import org.apache.http.impl.nio.reactor.SSLIOSession;
import org.apache.http.nio.NHttpClientConnection;
import org.apache.http.nio.NHttpClientIOTarget;
import org.apache.http.nio.reactor.IOSession;
-public interface OperatedClientConnection extends NHttpClientConnection, NHttpClientIOTarget {
+public interface OperatedClientConnection
+ extends NHttpClientConnection, HttpInetConnection, NHttpClientIOTarget {
void upgrade(IOSession iosession);
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestHttpAsync.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestHttpAsync.java?rev=1159072&r1=1159071&r2=1159072&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestHttpAsync.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestHttpAsync.java Thu Aug 18 08:00:00 2011
@@ -86,8 +86,8 @@ public class TestHttpAsync extends Async
int reqCount = 20;
- this.sessionManager.setDefaultMaxPerHost(reqCount);
- this.sessionManager.setTotalMax(100);
+ this.sessionManager.setDefaultMaxPerRoute(reqCount);
+ this.sessionManager.setMaxTotal(100);
Queue<Future<HttpResponse>> queue = new LinkedList<Future<HttpResponse>>();
@@ -117,8 +117,8 @@ public class TestHttpAsync extends Async
int reqCount = 20;
- this.sessionManager.setDefaultMaxPerHost(1);
- this.sessionManager.setTotalMax(100);
+ this.sessionManager.setDefaultMaxPerRoute(1);
+ this.sessionManager.setMaxTotal(100);
Queue<Future<HttpResponse>> queue = new LinkedList<Future<HttpResponse>>();
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestHttpsAsync.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestHttpsAsync.java?rev=1159072&r1=1159071&r2=1159072&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestHttpsAsync.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestHttpsAsync.java Thu Aug 18 08:00:00 2011
@@ -173,8 +173,8 @@ public class TestHttpsAsync extends Asyn
int reqCount = 20;
- this.sessionManager.setDefaultMaxPerHost(reqCount);
- this.sessionManager.setTotalMax(100);
+ this.sessionManager.setDefaultMaxPerRoute(reqCount);
+ this.sessionManager.setMaxTotal(100);
Queue<Future<HttpResponse>> queue = new LinkedList<Future<HttpResponse>>();
@@ -204,8 +204,8 @@ public class TestHttpsAsync extends Asyn
int reqCount = 20;
- this.sessionManager.setDefaultMaxPerHost(1);
- this.sessionManager.setTotalMax(100);
+ this.sessionManager.setDefaultMaxPerRoute(1);
+ this.sessionManager.setMaxTotal(100);
Queue<Future<HttpResponse>> queue = new LinkedList<Future<HttpResponse>>();
Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/localserver/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Aug 18 08:00:00 2011
@@ -1,3 +1,4 @@
+/httpcomponents/httpasyncclient/branches/conn-mgmt-redesign/httpasyncclient/src/test/java/org/apache/http/localserver:1155312-1159070
/httpcomponents/httpclient/branches/4.0.x/httpclient/src/test/java/org/apache/http/localserver:950681-950688
/httpcomponents/httpclient/branches/4.1.x/httpclient/src/test/java/org/apache/http/localserver:1079518-1080165
/httpcomponents/httpclient/branches/branch_4_1/httpclient/src/test/java/org/apache/http/localserver:755593-811107
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/methods/TestAsyncConsumers.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/methods/TestAsyncConsumers.java?rev=1159072&r1=1159071&r2=1159072&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/methods/TestAsyncConsumers.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/methods/TestAsyncConsumers.java Thu Aug 18 08:00:00 2011
@@ -35,6 +35,7 @@ import java.util.concurrent.atomic.Atomi
import org.apache.http.HttpException;
import org.apache.http.HttpResponse;
+import org.apache.http.entity.ContentType;
import org.apache.http.localserver.AsyncHttpTestBase;
import org.apache.http.nio.ContentDecoder;
import org.apache.http.nio.IOControl;
@@ -146,7 +147,8 @@ public class TestAsyncConsumers extends
for (int i = 0; i < 5; i++) {
HttpAsyncRequestProducer httppost = HttpAsyncMethods.createPost(
- this.target.toURI() + "/echo/stuff", s, "text/plain", HTTP.ASCII);
+ this.target.toURI() + "/echo/stuff", s,
+ ContentType.create("text/plain", HTTP.ASCII));
AsyncCharConsumer<String> consumer = new BufferingCharConsumer();
Future<String> future = this.httpclient.execute(httppost, consumer, null);
String result = future.get();
@@ -165,7 +167,8 @@ public class TestAsyncConsumers extends
for (int i = 0; i < 5; i++) {
HttpAsyncRequestProducer httppost = HttpAsyncMethods.createPost(
- this.target.toURI() + "/echo/stuff", s, "text/plain", HTTP.ASCII);
+ this.target.toURI() + "/echo/stuff", s,
+ ContentType.create("text/plain", HTTP.ASCII));
AsyncCharConsumer<String> consumer = new BufferingCharConsumer(512);
Future<String> future = this.httpclient.execute(httppost, consumer, null);
String result = future.get();
@@ -183,7 +186,8 @@ public class TestAsyncConsumers extends
String s = sb.toString();
HttpAsyncRequestProducer httppost = HttpAsyncMethods.createPost(
- this.target.toURI() + "/echo/stuff", s, "text/plain", HTTP.ASCII);
+ this.target.toURI() + "/echo/stuff", s,
+ ContentType.create("text/plain", HTTP.ASCII));
AsyncCharConsumer<String> consumer = Mockito.spy(new BufferingCharConsumer());
Future<String> future = this.httpclient.execute(httppost, consumer, null);
String result = future.get();
@@ -197,7 +201,8 @@ public class TestAsyncConsumers extends
@Test
public void testResourceReleaseOnException() throws Exception {
HttpAsyncRequestProducer httppost = HttpAsyncMethods.createPost(
- this.target.toURI() + "/echo/stuff", "stuff", "text/plain", HTTP.ASCII);
+ this.target.toURI() + "/echo/stuff", "stuff",
+ ContentType.create("text/plain", HTTP.ASCII));
AsyncCharConsumer<String> consumer = Mockito.spy(new BufferingCharConsumer());
Mockito.doThrow(new IOException("Kaboom")).when(consumer).consumeContent(
Mockito.any(ContentDecoder.class), Mockito.any(IOControl.class));
@@ -220,7 +225,8 @@ public class TestAsyncConsumers extends
@Test
public void testResourceReleaseOnBuildFailure() throws Exception {
HttpAsyncRequestProducer httppost = HttpAsyncMethods.createPost(
- this.target.toURI() + "/echo/stuff", "stuff", "text/plain", HTTP.ASCII);
+ this.target.toURI() + "/echo/stuff", "stuff",
+ ContentType.create("text/plain", HTTP.ASCII));
AsyncCharConsumer<String> consumer = Mockito.spy(new BufferingCharConsumer());
Mockito.doThrow(new HttpException("Kaboom")).when(consumer).buildResult();
Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/methods/TestZeroCopy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/methods/TestZeroCopy.java?rev=1159072&r1=1159071&r2=1159072&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/methods/TestZeroCopy.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/methods/TestZeroCopy.java Thu Aug 18 08:00:00 2011
@@ -46,12 +46,12 @@ import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.BasicHttpEntity;
+import org.apache.http.entity.ContentType;
import org.apache.http.entity.FileEntity;
import org.apache.http.entity.StringEntity;
import org.apache.http.localserver.AsyncHttpTestBase;
import org.apache.http.protocol.HttpContext;
import org.apache.http.protocol.HttpRequestHandler;
-import org.apache.http.util.EntityUtils;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
@@ -108,7 +108,7 @@ public class TestZeroCopy extends AsyncH
private final boolean forceChunking;
protected TestZeroCopyPost(final String requestURI, final boolean forceChunking) {
- super(URI.create(requestURI), TEST_FILE, "text/plain");
+ super(URI.create(requestURI), TEST_FILE, ContentType.create("text/plain", null));
this.forceChunking = forceChunking;
}
@@ -166,8 +166,8 @@ public class TestZeroCopy extends AsyncH
InputStream instream = requestEntity.getContent();
try {
- LineIterator it = IOUtils.lineIterator(instream,
- EntityUtils.getContentCharSet(requestEntity));
+ ContentType contentType = ContentType.getOrDefault(requestEntity);
+ LineIterator it = IOUtils.lineIterator(instream, contentType.getCharset());
int count = 0;
while (it.hasNext()) {
String line = it.next();
@@ -183,7 +183,8 @@ public class TestZeroCopy extends AsyncH
instream.close();
}
if (ok) {
- FileEntity responseEntity = new FileEntity(TEST_FILE, "text/plian");
+ FileEntity responseEntity = new FileEntity(TEST_FILE,
+ ContentType.create("text/plian", null));
if (this.forceChunking) {
responseEntity.setChunked(true);
}
Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/resources/test.keystore
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Aug 18 08:00:00 2011
@@ -1 +1,2 @@
+/httpcomponents/httpasyncclient/branches/conn-mgmt-redesign/httpasyncclient/src/test/resources/test.keystore:1155312-1159070
/httpcomponents/httpcore/branches/ibm_compat_branch/httpcore-nio/src/test/resources/test.keystore:755687-758898
Modified: httpcomponents/httpasyncclient/trunk/pom.xml
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/pom.xml?rev=1159072&r1=1159071&r2=1159072&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/pom.xml (original)
+++ httpcomponents/httpasyncclient/trunk/pom.xml Thu Aug 18 08:00:00 2011
@@ -72,7 +72,7 @@
<maven.compile.target>1.5</maven.compile.target>
<maven.compile.optimize>true</maven.compile.optimize>
<maven.compile.deprecation>true</maven.compile.deprecation>
- <httpcore.version>4.1.1</httpcore.version>
+ <httpcore.version>4.2-alpha1</httpcore.version>
<httpclient.version>4.1.1</httpclient.version>
<commons-logging.version>1.1.1</commons-logging.version>
<commons-io.version>2.0.1</commons-io.version>