Deprecated ConnManagerPNames and related classes; 'http.conn-manager.timeout' parameter deprecated in favor of 'http.connection.timeout'; improved javadocs for deprecated classes; renamed methods in ThreadSafeClientConnManager for better consistency

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@965983 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2010-07-20 20:14:09 +00:00
parent 5a54675818
commit ee323a52fa
16 changed files with 58 additions and 80 deletions

View File

@ -26,7 +26,6 @@
package org.apache.http.client.params;
import org.apache.http.params.CoreConnectionPNames;
import org.apache.http.params.CoreProtocolPNames;
import org.apache.http.auth.params.AuthPNames;
@ -35,7 +34,6 @@ import org.apache.http.conn.params.ConnManagerPNames;
import org.apache.http.conn.params.ConnConnectionPNames;
import org.apache.http.conn.params.ConnRoutePNames;
/**
* Collected parameter names for the HttpClient module.
* This interface combines the parameter definitions of the HttpClient
@ -49,6 +47,7 @@ import org.apache.http.conn.params.ConnRoutePNames;
*
* @since 4.0
*/
@SuppressWarnings("deprecation")
public interface AllClientPNames extends
CoreConnectionPNames, CoreProtocolPNames,
ClientPNames, AuthPNames, CookieSpecPNames,

View File

@ -26,11 +26,15 @@
package org.apache.http.conn.params;
import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
import org.apache.http.params.CoreConnectionPNames;
/**
* Parameter names for connection managers in HttpConn.
*
* @since 4.0
*/
@Deprecated
public interface ConnManagerPNames {
/**
@ -39,7 +43,8 @@ public interface ConnManagerPNames {
* {@link org.apache.http.conn.ClientConnectionManager}.
* <p>
* This parameter expects a value of type {@link Long}.
* </p>
* <p>
* @deprecated use {@link CoreConnectionPNames#CONNECTION_TIMEOUT}
*/
public static final String TIMEOUT = "http.conn-manager.timeout";
@ -49,9 +54,10 @@ public interface ConnManagerPNames {
* and applies to individual manager instances.
* <p>
* This parameter expects a value of type {@link ConnPerRoute}.
* </p>
* <p>
* @deprecated use {@link ThreadSafeClientConnManager#setMaxForRoute(org.apache.http.conn.routing.HttpRoute, int)},
* {@link ThreadSafeClientConnManager#getMaxForRoute(org.apache.http.conn.routing.HttpRoute)}
*/
@Deprecated
public static final String MAX_CONNECTIONS_PER_ROUTE = "http.conn-manager.max-per-route";
/**
@ -60,9 +66,10 @@ public interface ConnManagerPNames {
* and applies to individual manager instances.
* <p>
* This parameter expects a value of type {@link Integer}.
* </p>
* <p>
* @deprecated use {@link ThreadSafeClientConnManager#setMaxTotal(int)},
* {@link ThreadSafeClientConnManager#getMaxTotal()}
*/
@Deprecated
public static final String MAX_TOTAL_CONNECTIONS = "http.conn-manager.max-total";
}

View File

@ -40,6 +40,7 @@ import org.apache.http.params.HttpParams;
* @since 4.0
*/
@NotThreadSafe
@Deprecated
public class ConnManagerParamBean extends HttpAbstractParamBean {
public ConnManagerParamBean (final HttpParams params) {

View File

@ -29,6 +29,8 @@ package org.apache.http.conn.params;
import org.apache.http.annotation.Immutable;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
/**
@ -39,6 +41,7 @@ import org.apache.http.params.HttpParams;
*
* @see ConnManagerPNames
*/
@Deprecated
@Immutable
public final class ConnManagerParams implements ConnManagerPNames {
@ -51,6 +54,8 @@ public final class ConnManagerParams implements ConnManagerPNames {
* {@link org.apache.http.conn.ClientConnectionManager}.
*
* @return timeout in milliseconds.
*
* @deprecated use {@link HttpConnectionParams#getConnectionTimeout(HttpParams)}
*/
public static long getTimeout(final HttpParams params) {
if (params == null) {
@ -65,6 +70,8 @@ public final class ConnManagerParams implements ConnManagerPNames {
* {@link org.apache.http.conn.ClientConnectionManager}.
*
* @param timeout the timeout in milliseconds
*
* @deprecated use {@link HttpConnectionParams#setConnectionTimeout(HttpParams, int)
*/
public static void setTimeout(final HttpParams params, long timeout) {
if (params == null) {
@ -74,7 +81,6 @@ public final class ConnManagerParams implements ConnManagerPNames {
}
/** The default maximum number of connections allowed per host */
@Deprecated
private static final ConnPerRoute DEFAULT_CONN_PER_ROUTE = new ConnPerRoute() {
public int getMaxForRoute(HttpRoute route) {
@ -90,11 +96,8 @@ public final class ConnManagerParams implements ConnManagerPNames {
* @param connPerRoute lookup interface for maximum number of connections allowed
* per route
*
* @deprecated do not use
*
* @see ConnManagerPNames#MAX_CONNECTIONS_PER_ROUTE
* @deprecated use {@link ThreadSafeClientConnManager#setMaxForRoute(org.apache.http.conn.routing.HttpRoute, int)}
*/
@Deprecated
public static void setMaxConnectionsPerRoute(final HttpParams params,
final ConnPerRoute connPerRoute) {
if (params == null) {
@ -111,11 +114,8 @@ public final class ConnManagerParams implements ConnManagerPNames {
*
* @return lookup interface for maximum number of connections allowed per route.
*
* @deprecated do not use
*
* @see ConnManagerPNames#MAX_CONNECTIONS_PER_ROUTE
* @deprecated use {@link ThreadSafeClientConnManager#getMaxForRoute(org.apache.http.conn.routing.HttpRoute)}
*/
@Deprecated
public static ConnPerRoute getMaxConnectionsPerRoute(final HttpParams params) {
if (params == null) {
throw new IllegalArgumentException
@ -128,18 +128,14 @@ public final class ConnManagerParams implements ConnManagerPNames {
return connPerRoute;
}
/**
* Sets the maximum number of connections allowed.
*
* @param params HTTP parameters
* @param maxTotalConnections The maximum number of connections allowed.
*
* @deprecated do not use
*
* @see ConnManagerPNames#MAX_TOTAL_CONNECTIONS
* @deprecated use {@link ThreadSafeClientConnManager#setMaxTotal(int)}
*/
@Deprecated
public static void setMaxTotalConnections(
final HttpParams params,
int maxTotalConnections) {
@ -157,11 +153,8 @@ public final class ConnManagerParams implements ConnManagerPNames {
*
* @return The maximum number of connections allowed.
*
* @deprecated do not use
*
* @see ConnManagerPNames#MAX_TOTAL_CONNECTIONS
* @deprecated use {@link ThreadSafeClientConnManager#getMaxTotal()}
*/
@Deprecated
public static int getMaxTotalConnections(
final HttpParams params) {
if (params == null) {
@ -171,5 +164,4 @@ public final class ConnManagerParams implements ConnManagerPNames {
return params.getIntParameter(MAX_TOTAL_CONNECTIONS, DEFAULT_MAX_TOTAL_CONNECTIONS);
}
}

View File

@ -135,7 +135,6 @@ import org.apache.http.util.VersionInfo;
* <li>{@link org.apache.http.conn.params.ConnRoutePNames#FORCED_ROUTE}</li>
* <li>{@link org.apache.http.conn.params.ConnRoutePNames#LOCAL_ADDRESS}</li>
* <li>{@link org.apache.http.conn.params.ConnRoutePNames#DEFAULT_PROXY}</li>
* <li>{@link org.apache.http.conn.params.ConnManagerPNames#TIMEOUT}</li>
* <li>{@link org.apache.http.cookie.params.CookieSpecPNames#DATE_PATTERNS}</li>
* <li>{@link org.apache.http.cookie.params.CookieSpecPNames#SINGLE_COOKIE_HEADER}</li>
* <li>{@link org.apache.http.auth.params.AuthPNames#CREDENTIAL_CHARSET}</li>

View File

@ -74,7 +74,6 @@ import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.conn.ClientConnectionRequest;
import org.apache.http.conn.ConnectionKeepAliveStrategy;
import org.apache.http.conn.ManagedClientConnection;
import org.apache.http.conn.params.ConnManagerParams;
import org.apache.http.conn.routing.BasicRouteDirector;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.conn.routing.HttpRouteDirector;
@ -115,7 +114,6 @@ import org.apache.http.protocol.HttpRequestExecutor;
* <li>{@link org.apache.http.conn.params.ConnRoutePNames#FORCED_ROUTE}</li>
* <li>{@link org.apache.http.conn.params.ConnRoutePNames#LOCAL_ADDRESS}</li>
* <li>{@link org.apache.http.conn.params.ConnRoutePNames#DEFAULT_PROXY}</li>
* <li>{@link org.apache.http.conn.params.ConnManagerPNames#TIMEOUT}</li>
* <li>{@link org.apache.http.cookie.params.CookieSpecPNames#DATE_PATTERNS}</li>
* <li>{@link org.apache.http.cookie.params.CookieSpecPNames#SINGLE_COOKIE_HEADER}</li>
* <li>{@link org.apache.http.auth.params.AuthPNames#CREDENTIAL_CHARSET}</li>
@ -361,7 +359,7 @@ public class DefaultRequestDirector implements RequestDirector {
RoutedRequest roureq = new RoutedRequest(origWrapper, origRoute);
long timeout = ConnManagerParams.getTimeout(params);
long timeout = HttpConnectionParams.getConnectionTimeout(params);
boolean reuse = false;
boolean done = false;

View File

@ -302,14 +302,14 @@ public class ThreadSafeClientConnManager implements ClientConnectionManager {
/**
* since 4.1
*/
public int getMaxTotalConnections() {
public int getMaxTotal() {
return pool.getMaxTotalConnections();
}
/**
* since 4.1
*/
public void setMaxTotalConnections(int max) {
public void setMaxTotal(int max) {
pool.setMaxTotalConnections(max);
}

View File

@ -65,7 +65,7 @@ public class TestConnectionAutoRelease extends ServerTestBase {
public void testReleaseOnEntityConsumeContent() throws Exception {
ThreadSafeClientConnManager mgr = createTSCCM(null);
mgr.setDefaultMaxPerRoute(1);
mgr.setMaxTotalConnections(1);
mgr.setMaxTotal(1);
// Zero connections in the pool
Assert.assertEquals(0, mgr.getConnectionsInPool());
@ -105,7 +105,7 @@ public class TestConnectionAutoRelease extends ServerTestBase {
public void testReleaseOnEntityWriteTo() throws Exception {
ThreadSafeClientConnManager mgr = createTSCCM(null);
mgr.setDefaultMaxPerRoute(1);
mgr.setMaxTotalConnections(1);
mgr.setMaxTotal(1);
// Zero connections in the pool
Assert.assertEquals(0, mgr.getConnectionsInPool());
@ -146,7 +146,7 @@ public class TestConnectionAutoRelease extends ServerTestBase {
public void testReleaseOnAbort() throws Exception {
ThreadSafeClientConnManager mgr = createTSCCM(null);
mgr.setDefaultMaxPerRoute(1);
mgr.setMaxTotalConnections(1);
mgr.setMaxTotal(1);
// Zero connections in the pool
Assert.assertEquals(0, mgr.getConnectionsInPool());
@ -219,7 +219,7 @@ public class TestConnectionAutoRelease extends ServerTestBase {
ThreadSafeClientConnManager mgr = createTSCCM(null);
mgr.setDefaultMaxPerRoute(1);
mgr.setMaxTotalConnections(1);
mgr.setMaxTotal(1);
// Zero connections in the pool
Assert.assertEquals(0, mgr.getConnectionsInPool());

View File

@ -100,7 +100,7 @@ public class TestConnectionReuse {
supportedSchemes.register(new Scheme("http", 80, sf));
ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(supportedSchemes);
mgr.setMaxTotalConnections(5);
mgr.setMaxTotal(5);
mgr.setDefaultMaxPerRoute(5);
DefaultHttpClient client = new DefaultHttpClient(mgr, params);
@ -171,7 +171,7 @@ public class TestConnectionReuse {
supportedSchemes.register(new Scheme("http", 80, sf));
ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(supportedSchemes);
mgr.setMaxTotalConnections(5);
mgr.setMaxTotal(5);
mgr.setDefaultMaxPerRoute(5);
DefaultHttpClient client = new DefaultHttpClient(mgr, params);
@ -232,7 +232,7 @@ public class TestConnectionReuse {
supportedSchemes.register(new Scheme("http", 80, sf));
ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(supportedSchemes);
mgr.setMaxTotalConnections(5);
mgr.setMaxTotal(5);
mgr.setDefaultMaxPerRoute(5);
DefaultHttpClient client = new DefaultHttpClient(mgr, params);
@ -294,7 +294,7 @@ public class TestConnectionReuse {
supportedSchemes.register(new Scheme("http", 80, sf));
ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(supportedSchemes);
mgr.setMaxTotalConnections(1);
mgr.setMaxTotal(1);
mgr.setDefaultMaxPerRoute(1);
DefaultHttpClient client = new DefaultHttpClient(mgr, params);

View File

@ -189,7 +189,7 @@ public class TestContentCodings extends ServerTestBase {
schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
ThreadSafeClientConnManager cm = new ThreadSafeClientConnManager(schemeRegistry);
cm.setMaxTotalConnections(clients);
cm.setMaxTotal(clients);
final HttpClient httpClient = new DefaultHttpClient(cm);

View File

@ -86,7 +86,7 @@ public class TestStatefulConnManagement extends ServerTestBase {
ConnManagerParams.setTimeout(params, 10L);
ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(supportedSchemes);
mgr.setMaxTotalConnections(workerCount);
mgr.setMaxTotal(workerCount);
mgr.setDefaultMaxPerRoute(workerCount);
@ -211,7 +211,7 @@ public class TestStatefulConnManagement extends ServerTestBase {
// We build a client with 2 max active // connections, and 2 max per route.
ThreadSafeClientConnManager connMngr = new ThreadSafeClientConnManager(supportedSchemes);
connMngr.setMaxTotalConnections(maxConn);
connMngr.setMaxTotal(maxConn);
connMngr.setDefaultMaxPerRoute(maxConn);
DefaultHttpClient client = new DefaultHttpClient(connMngr);

View File

@ -70,7 +70,7 @@ public class TestIdleConnectionEviction extends ServerTestBase {
ThreadSafeClientConnManager cm = new ThreadSafeClientConnManager(schemeRegistry);
cm.setDefaultMaxPerRoute(10);
cm.setMaxTotalConnections(50);
cm.setMaxTotal(50);
DefaultHttpClient httpclient = new DefaultHttpClient(cm, params);

View File

@ -153,7 +153,7 @@ public class TestTSCCMNoServer {
throws InterruptedException, ConnectionPoolTimeoutException {
ThreadSafeClientConnManager mgr = createTSCCM(null);
mgr.setMaxTotalConnections(2);
mgr.setMaxTotal(2);
mgr.setDefaultMaxPerRoute(1);
HttpHost target1 = new HttpHost("www.test1.invalid", 80, "http");
@ -199,7 +199,7 @@ public class TestTSCCMNoServer {
HttpRoute route3 = new HttpRoute(target3, null, false);
ThreadSafeClientConnManager mgr = createTSCCM(null);
mgr.setMaxTotalConnections(100);
mgr.setMaxTotal(100);
mgr.setDefaultMaxPerRoute(1);
mgr.setMaxForRoute(route2, 2);
mgr.setMaxForRoute(route3, 3);
@ -265,7 +265,7 @@ public class TestTSCCMNoServer {
public void testReleaseConnection() throws Exception {
ThreadSafeClientConnManager mgr = createTSCCM(null);
mgr.setMaxTotalConnections(3);
mgr.setMaxTotal(3);
mgr.setDefaultMaxPerRoute(1);
HttpHost target1 = new HttpHost("www.test1.invalid", 80, "http");
@ -367,7 +367,7 @@ public class TestTSCCMNoServer {
// 3.x: TestHttpConnectionManager.testShutdown
ThreadSafeClientConnManager mgr = createTSCCM(null);
mgr.setMaxTotalConnections(1);
mgr.setMaxTotal(1);
mgr.setDefaultMaxPerRoute(1);
HttpHost target = new HttpHost("www.test.invalid", 80, "http");
@ -413,7 +413,7 @@ public class TestTSCCMNoServer {
// 3.x: TestHttpConnectionManager.testWaitingThreadInterrupted
ThreadSafeClientConnManager mgr = createTSCCM(null);
mgr.setMaxTotalConnections(1);
mgr.setMaxTotal(1);
HttpHost target = new HttpHost("www.test.invalid", 80, "http");
HttpRoute route = new HttpRoute(target, null, false);
@ -458,7 +458,7 @@ public class TestTSCCMNoServer {
// 3.x: TestHttpConnectionManager.testHostReusePreference
ThreadSafeClientConnManager mgr = createTSCCM(null);
mgr.setMaxTotalConnections(1);
mgr.setMaxTotal(1);
HttpHost target1 = new HttpHost("www.test1.invalid", 80, "http");
HttpRoute route1 = new HttpRoute(target1, null, false);
@ -497,7 +497,7 @@ public class TestTSCCMNoServer {
@Test
public void testAbortAfterRequestStarts() throws Exception {
ThreadSafeClientConnManager mgr = createTSCCM(null);
mgr.setMaxTotalConnections(1);
mgr.setMaxTotal(1);
HttpHost target = new HttpHost("www.test.invalid", 80, "http");
HttpRoute route = new HttpRoute(target, null, false);
@ -537,7 +537,7 @@ public class TestTSCCMNoServer {
@Test
public void testAbortBeforeRequestStarts() throws Exception {
ThreadSafeClientConnManager mgr = createTSCCM(null);
mgr.setMaxTotalConnections(1);
mgr.setMaxTotal(1);
HttpHost target = new HttpHost("www.test.invalid", 80, "http");
HttpRoute route = new HttpRoute(target, null, false);

View File

@ -96,7 +96,7 @@ public class TestTSCCMWithServer extends ServerTestBase {
final int COUNT = 8; // adjust to execute more requests
ThreadSafeClientConnManager mgr = createTSCCM(null);
mgr.setMaxTotalConnections(COUNT/2);
mgr.setMaxTotal(COUNT/2);
mgr.setDefaultMaxPerRoute(COUNT/2);
final HttpHost target = getServerHttp();
@ -169,7 +169,7 @@ public class TestTSCCMWithServer extends ServerTestBase {
public void testReleaseConnection() throws Exception {
ThreadSafeClientConnManager mgr = createTSCCM(null);
mgr.setMaxTotalConnections(1);
mgr.setMaxTotal(1);
final HttpHost target = getServerHttp();
final HttpRoute route = new HttpRoute(target, null, false);
@ -255,7 +255,7 @@ public class TestTSCCMWithServer extends ServerTestBase {
public void testReleaseConnectionWithTimeLimits() throws Exception {
ThreadSafeClientConnManager mgr = createTSCCM(null);
mgr.setMaxTotalConnections(1);
mgr.setMaxTotal(1);
final HttpHost target = getServerHttp();
final HttpRoute route = new HttpRoute(target, null, false);
@ -357,7 +357,7 @@ public class TestTSCCMWithServer extends ServerTestBase {
public void testCloseExpiredConnections() throws Exception {
ThreadSafeClientConnManager mgr = createTSCCM(null);
mgr.setMaxTotalConnections(1);
mgr.setMaxTotal(1);
final HttpHost target = getServerHttp();
final HttpRoute route = new HttpRoute(target, null, false);
@ -398,7 +398,7 @@ public class TestTSCCMWithServer extends ServerTestBase {
public void testReleaseConnectionOnAbort() throws Exception {
ThreadSafeClientConnManager mgr = createTSCCM(null);
mgr.setMaxTotalConnections(1);
mgr.setMaxTotal(1);
final HttpHost target = getServerHttp();
final HttpRoute route = new HttpRoute(target, null, false);
@ -501,7 +501,7 @@ public class TestTSCCMWithServer extends ServerTestBase {
registry.register(scheme);
ThreadSafeClientConnManager mgr = createTSCCM(registry);
mgr.setMaxTotalConnections(1);
mgr.setMaxTotal(1);
final HttpHost target = getServerHttp();
final HttpRoute route = new HttpRoute(target, null, false);
@ -553,7 +553,7 @@ public class TestTSCCMWithServer extends ServerTestBase {
registry.register(scheme);
ThreadSafeClientConnManager mgr = createTSCCM(registry);
mgr.setMaxTotalConnections(1);
mgr.setMaxTotal(1);
final HttpHost target = getServerHttp();
final HttpRoute route = new HttpRoute(target, null, false);
@ -607,7 +607,7 @@ public class TestTSCCMWithServer extends ServerTestBase {
registry.register(scheme);
ThreadSafeClientConnManager mgr = createTSCCM(registry);
mgr.setMaxTotalConnections(1);
mgr.setMaxTotal(1);
final HttpHost target = getServerHttp();
final HttpRoute route = new HttpRoute(target, null, false);
@ -669,7 +669,7 @@ public class TestTSCCMWithServer extends ServerTestBase {
return operatorRef.get();
}
};
mgr.setMaxTotalConnections(1);
mgr.setMaxTotal(1);
Assert.assertNotNull(operatorRef.get());
final HttpHost target = getServerHttp();

View File

@ -117,7 +117,7 @@ public class TestSpuriousWakeup {
XTSCCM mgr = new XTSCCM(schreg);
try {
mgr.setMaxTotalConnections(1);
mgr.setMaxTotal(1);
mgr.setDefaultMaxPerRoute(1);
// take out the only connection

View File

@ -602,24 +602,6 @@ httpclient.getConnectionManager().shutdown();
]]></programlisting>
</section>
</section>
<section>
<title>Connection management parameters</title>
<para>These are parameters that be used to customize standard HTTP connection manager
implementations:</para>
<itemizedlist>
<listitem>
<formalpara>
<title>'http.conn-manager.timeout':</title>
<para>defines the timeout in milliseconds used when retrieving an instance of
<interfacename>ManagedClientConnection</interfacename> from the
<interfacename>ClientConnectionManager</interfacename> This parameter
expects a value of type <classname>java.lang.Long</classname>. If this
parameter is not set connection requests will not time out (infinite
timeout).</para>
</formalpara>
</listitem>
</itemizedlist>
</section>
<section>
<title>Multithreaded request execution</title>
<para>When equipped with a pooling connection manager such as ThreadSafeClientConnManager