Moved connection manager timeout parameter to ConnManagerPNames
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@658781 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1b4ecf0b57
commit
be2250f5b2
|
@ -42,16 +42,6 @@ package org.apache.http.client.params;
|
|||
*/
|
||||
public interface ClientPNames {
|
||||
|
||||
/**
|
||||
* Defines the timeout in milliseconds used when retrieving an instance of
|
||||
* {@link org.apache.http.conn.ManagedClientConnection} from the
|
||||
* {@link org.apache.http.conn.ClientConnectionManager}.
|
||||
* <p>
|
||||
* This parameter expects a value of type {@link Long}.
|
||||
* </p>
|
||||
*/
|
||||
public static final String CONNECTION_MANAGER_TIMEOUT = "http.connection-manager.timeout";
|
||||
|
||||
/**
|
||||
* Defines the class name of the default {@link org.apache.http.conn.ClientConnectionManager}
|
||||
* <p>
|
||||
|
|
|
@ -45,10 +45,6 @@ public class ClientParamBean extends HttpAbstractParamBean {
|
|||
super(params);
|
||||
}
|
||||
|
||||
public void setConnectionManagerTimeout (final long timeout) {
|
||||
params.setLongParameter(ClientPNames.CONNECTION_MANAGER_TIMEOUT, timeout);
|
||||
}
|
||||
|
||||
public void setConnectionManagerFactoryClassName (final String factory) {
|
||||
params.setParameter(ClientPNames.CONNECTION_MANAGER_FACTORY_CLASS_NAME, factory);
|
||||
}
|
||||
|
|
|
@ -47,36 +47,6 @@ public class HttpClientParams {
|
|||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the timeout in milliseconds used when retrieving a
|
||||
* {@link org.apache.http.conn.ManagedClientConnection} from the
|
||||
* {@link org.apache.http.conn.ClientConnectionManager}.
|
||||
*
|
||||
* @return timeout in milliseconds.
|
||||
*/
|
||||
public static long getConnectionManagerTimeout(final HttpParams params) {
|
||||
if (params == null) {
|
||||
throw new IllegalArgumentException("HTTP parameters may not be null");
|
||||
}
|
||||
return params.getLongParameter
|
||||
(ClientPNames.CONNECTION_MANAGER_TIMEOUT, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the timeout in milliseconds used when retrieving a
|
||||
* {@link org.apache.http.conn.ManagedClientConnection} from the
|
||||
* {@link org.apache.http.conn.ClientConnectionManager}.
|
||||
*
|
||||
* @param timeout the timeout in milliseconds
|
||||
*/
|
||||
public static void setConnectionManagerTimeout(final HttpParams params, long timeout) {
|
||||
if (params == null) {
|
||||
throw new IllegalArgumentException("HTTP parameters may not be null");
|
||||
}
|
||||
params.setLongParameter
|
||||
(ClientPNames.CONNECTION_MANAGER_TIMEOUT, timeout);
|
||||
}
|
||||
|
||||
public static boolean isRedirecting(final HttpParams params) {
|
||||
if (params == null) {
|
||||
throw new IllegalArgumentException("HTTP parameters may not be null");
|
||||
|
|
|
@ -40,6 +40,16 @@ package org.apache.http.conn.params;
|
|||
*/
|
||||
public interface ConnManagerPNames {
|
||||
|
||||
/**
|
||||
* Defines the timeout in milliseconds used when retrieving an instance of
|
||||
* {@link org.apache.http.conn.ManagedClientConnection} from the
|
||||
* {@link org.apache.http.conn.ClientConnectionManager}.
|
||||
* <p>
|
||||
* This parameter expects a value of type {@link Long}.
|
||||
* </p>
|
||||
*/
|
||||
public static final String TIMEOUT = "http.conn-manager.timeout";
|
||||
|
||||
/**
|
||||
* Defines the maximum number of connections per route.
|
||||
* This limit is interpreted by client connection managers
|
||||
|
|
|
@ -44,6 +44,10 @@ public class ConnManagerParamBean extends HttpAbstractParamBean {
|
|||
public ConnManagerParamBean (final HttpParams params) {
|
||||
super(params);
|
||||
}
|
||||
|
||||
public void setTimeout (final long timeout) {
|
||||
params.setLongParameter(ConnManagerPNames.TIMEOUT, timeout);
|
||||
}
|
||||
|
||||
/** @see ConnManagerPNames#MAX_TOTAL_CONNECTIONS */
|
||||
public void setMaxTotalConnections (final int maxConnections) {
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
/*
|
||||
* $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.conn.params;
|
||||
|
||||
import org.apache.http.params.HttpParams;
|
||||
|
||||
/**
|
||||
* An adaptor for accessing HTTP connection parameters in {@link HttpParams}.
|
||||
*
|
||||
* @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
|
||||
*
|
||||
* @version $Revision$
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public class HttpConnParams {
|
||||
|
||||
// since the parameter names have been moved to interfaces,
|
||||
// this class currently is a dummy
|
||||
|
||||
/** Disabled default constructor. */
|
||||
private HttpConnParams() {
|
||||
// no body
|
||||
}
|
||||
}
|
||||
|
|
@ -52,6 +52,34 @@ public final class HttpConnectionManagerParams implements ConnManagerPNames {
|
|||
/** The default maximum number of connections allowed overall */
|
||||
public static final int DEFAULT_MAX_TOTAL_CONNECTIONS = 20;
|
||||
|
||||
/**
|
||||
* Returns the timeout in milliseconds used when retrieving a
|
||||
* {@link org.apache.http.conn.ManagedClientConnection} from the
|
||||
* {@link org.apache.http.conn.ClientConnectionManager}.
|
||||
*
|
||||
* @return timeout in milliseconds.
|
||||
*/
|
||||
public static long getTimeout(final HttpParams params) {
|
||||
if (params == null) {
|
||||
throw new IllegalArgumentException("HTTP parameters may not be null");
|
||||
}
|
||||
return params.getLongParameter(TIMEOUT, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the timeout in milliseconds used when retrieving a
|
||||
* {@link org.apache.http.conn.ManagedClientConnection} from the
|
||||
* {@link org.apache.http.conn.ClientConnectionManager}.
|
||||
*
|
||||
* @param timeout the timeout in milliseconds
|
||||
*/
|
||||
public static void setTimeout(final HttpParams params, long timeout) {
|
||||
if (params == null) {
|
||||
throw new IllegalArgumentException("HTTP parameters may not be null");
|
||||
}
|
||||
params.setLongParameter(TIMEOUT, timeout);
|
||||
}
|
||||
|
||||
/** The default maximum number of connections allowed per host */
|
||||
private static final ConnPerRoute DEFAULT_CONN_PER_ROUTE = new ConnPerRoute() {
|
||||
|
||||
|
|
|
@ -74,6 +74,7 @@ import org.apache.http.conn.BasicManagedEntity;
|
|||
import org.apache.http.conn.ClientConnectionManager;
|
||||
import org.apache.http.conn.ClientConnectionRequest;
|
||||
import org.apache.http.conn.ManagedClientConnection;
|
||||
import org.apache.http.conn.params.HttpConnectionManagerParams;
|
||||
import org.apache.http.conn.routing.BasicRouteDirector;
|
||||
import org.apache.http.conn.routing.HttpRoute;
|
||||
import org.apache.http.conn.routing.HttpRouteDirector;
|
||||
|
@ -277,7 +278,7 @@ public class DefaultClientRequestDirector
|
|||
|
||||
RoutedRequest roureq = new RoutedRequest(origWrapper, origRoute);
|
||||
|
||||
long timeout = HttpClientParams.getConnectionManagerTimeout(params);
|
||||
long timeout = HttpConnectionManagerParams.getTimeout(params);
|
||||
|
||||
int execCount = 0;
|
||||
|
||||
|
|
|
@ -42,7 +42,6 @@ import org.apache.http.HttpStatus;
|
|||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.UserTokenHandler;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.params.HttpClientParams;
|
||||
import org.apache.http.conn.ManagedClientConnection;
|
||||
import org.apache.http.conn.params.ConnPerRouteBean;
|
||||
import org.apache.http.conn.params.HttpConnectionManagerParams;
|
||||
|
@ -103,7 +102,7 @@ public class TestStatefulConnManagement extends ServerTestBase {
|
|||
HttpConnectionManagerParams.setMaxTotalConnections(params, workerCount);
|
||||
HttpConnectionManagerParams.setMaxConnectionsPerRoute(params,
|
||||
new ConnPerRouteBean(workerCount));
|
||||
HttpClientParams.setConnectionManagerTimeout(params, 10L);
|
||||
HttpConnectionManagerParams.setTimeout(params, 10L);
|
||||
|
||||
ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(
|
||||
params, supportedSchemes);
|
||||
|
|
Loading…
Reference in New Issue