Package org.apache.commons.httpclient
Class MultiThreadedHttpConnectionManager
- java.lang.Object
-
- org.apache.commons.httpclient.MultiThreadedHttpConnectionManager
-
- All Implemented Interfaces:
HttpConnectionManager
@Deprecated public class MultiThreadedHttpConnectionManager extends java.lang.Object implements HttpConnectionManager
Deprecated.Jakarta Commons HttpClient 3.x is deprecated in the Jenkins project. It is not recommended to use it in any new code. Instead, use HTTP client API plugins as a dependency in your code. E.g. Apache HttpComponents Client API 4.x Plugin or Async HTTP Client Plugin.Manages a set of HttpConnections for various HostConfigurations.- Since:
- 2.0
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_MAX_HOST_CONNECTIONS
Deprecated.The default maximum number of connections allowed per hoststatic int
DEFAULT_MAX_TOTAL_CONNECTIONS
Deprecated.The default maximum number of connections allowed overall
-
Constructor Summary
Constructors Constructor Description MultiThreadedHttpConnectionManager()
Deprecated.No-args constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
closeIdleConnections(long idleTimeout)
Deprecated.Closes connections that have been idle for at least the given amount of time.void
deleteClosedConnections()
Deprecated.Deletes all closed connections.HttpConnection
getConnection(HostConfiguration hostConfiguration)
Deprecated.Gets an HttpConnection for a given host configuration.HttpConnection
getConnection(HostConfiguration hostConfiguration, long timeout)
Deprecated.Use #getConnectionWithTimeout(HostConfiguration, long)int
getConnectionsInPool()
Deprecated.Gets the total number of pooled connections.int
getConnectionsInPool(HostConfiguration hostConfiguration)
Deprecated.Gets the total number of pooled connections for the given host configuration.int
getConnectionsInUse()
Deprecated.int
getConnectionsInUse(HostConfiguration hostConfiguration)
Deprecated.HttpConnection
getConnectionWithTimeout(HostConfiguration hostConfiguration, long timeout)
Deprecated.Gets a connection or waits if one is not available.int
getMaxConnectionsPerHost()
int
getMaxTotalConnections()
HttpConnectionManagerParams
getParams()
Deprecated.Returnsparameters
associated with this connection manager.boolean
isConnectionStaleCheckingEnabled()
void
releaseConnection(HttpConnection conn)
Deprecated.Make the given HttpConnection available for use by other requests.void
setConnectionStaleCheckingEnabled(boolean connectionStaleCheckingEnabled)
void
setMaxConnectionsPerHost(int maxHostConnections)
void
setMaxTotalConnections(int maxTotalConnections)
void
setParams(HttpConnectionManagerParams params)
Deprecated.Assignsparameters
for this connection manager.void
shutdown()
Deprecated.Shuts down the connection manager and releases all resources.static void
shutdownAll()
Deprecated.Shuts down and cleans up resources used by all instances of MultiThreadedHttpConnectionManager.
-
-
-
Field Detail
-
DEFAULT_MAX_HOST_CONNECTIONS
public static final int DEFAULT_MAX_HOST_CONNECTIONS
Deprecated.The default maximum number of connections allowed per host- See Also:
- Constant Field Values
-
DEFAULT_MAX_TOTAL_CONNECTIONS
public static final int DEFAULT_MAX_TOTAL_CONNECTIONS
Deprecated.The default maximum number of connections allowed overall- See Also:
- Constant Field Values
-
-
Method Detail
-
shutdownAll
public static void shutdownAll()
Deprecated.Shuts down and cleans up resources used by all instances of MultiThreadedHttpConnectionManager. All static resources are released, all threads are stopped, andshutdown()
is called on all live instances of MultiThreadedHttpConnectionManager.- See Also:
shutdown()
-
shutdown
public void shutdown()
Deprecated.Shuts down the connection manager and releases all resources. All connections associated with this class will be closed and released.The connection manager can no longer be used once shut down.
Calling this method more than once will have no effect.
-
isConnectionStaleCheckingEnabled
public boolean isConnectionStaleCheckingEnabled()
Gets the staleCheckingEnabled value to be set on HttpConnections that are created.- Returns:
true
if stale checking will be enabled on HttpConnections- See Also:
HttpConnection.isStaleCheckingEnabled()
-
setConnectionStaleCheckingEnabled
public void setConnectionStaleCheckingEnabled(boolean connectionStaleCheckingEnabled)
Deprecated.Sets the staleCheckingEnabled value to be set on HttpConnections that are created.- Parameters:
connectionStaleCheckingEnabled
-true
if stale checking will be enabled on HttpConnections- See Also:
HttpConnection.setStaleCheckingEnabled(boolean)
-
setMaxConnectionsPerHost
public void setMaxConnectionsPerHost(int maxHostConnections)
Deprecated.Sets the maximum number of connections allowed for a given HostConfiguration. Per RFC 2616 section 8.1.4, this value defaults to 2.- Parameters:
maxHostConnections
- the number of connections allowed for each hostConfiguration
-
getMaxConnectionsPerHost
public int getMaxConnectionsPerHost()
Deprecated.Gets the maximum number of connections allowed for a given hostConfiguration.- Returns:
- The maximum number of connections allowed for a given hostConfiguration.
-
setMaxTotalConnections
public void setMaxTotalConnections(int maxTotalConnections)
Deprecated.Sets the maximum number of connections allowed for this connection manager.- Parameters:
maxTotalConnections
- the maximum number of connections allowed
-
getMaxTotalConnections
public int getMaxTotalConnections()
Deprecated.Gets the maximum number of connections allowed for this connection manager.- Returns:
- The maximum number of connections allowed
-
getConnection
public HttpConnection getConnection(HostConfiguration hostConfiguration)
Deprecated.Description copied from interface:HttpConnectionManager
Gets an HttpConnection for a given host configuration. If a connection is not available this method will block until one is. The connection manager should be registered with any HttpConnection that is created.- Specified by:
getConnection
in interfaceHttpConnectionManager
- Parameters:
hostConfiguration
- the host configuration to use to configure the connection- Returns:
- an HttpConnection for the given configuration
- See Also:
HttpConnectionManager.getConnection(HostConfiguration)
-
getConnectionWithTimeout
public HttpConnection getConnectionWithTimeout(HostConfiguration hostConfiguration, long timeout) throws ConnectionPoolTimeoutException
Deprecated.Gets a connection or waits if one is not available. A connection is available if one exists that is not being used or if fewer than maxHostConnections have been created in the connectionPool, and fewer than maxTotalConnections have been created in all connectionPools.- Specified by:
getConnectionWithTimeout
in interfaceHttpConnectionManager
- Parameters:
hostConfiguration
- The host configuration specifying the connection details.timeout
- the number of milliseconds to wait for a connection, 0 to wait indefinitely- Returns:
- HttpConnection an available connection
- Throws:
HttpException
- if a connection does not become available in 'timeout' millisecondsConnectionPoolTimeoutException
- if no connection becomes available before the timeout expires- Since:
- 3.0
- See Also:
HttpConnection.setHttpConnectionManager(HttpConnectionManager)
-
getConnection
public HttpConnection getConnection(HostConfiguration hostConfiguration, long timeout) throws HttpException
Deprecated.Use #getConnectionWithTimeout(HostConfiguration, long)Description copied from interface:HttpConnectionManager
Gets an HttpConnection for a given host configuration. If a connection is not available, this method will block for at most the specified number of milliseconds or until a connection becomes available. The connection manager should be registered with any HttpConnection that is created.- Specified by:
getConnection
in interfaceHttpConnectionManager
- Parameters:
hostConfiguration
- the host configuration to use to configure the connectiontimeout
- - the time (in milliseconds) to wait for a connection to become available, 0 to specify an infinite timeout- Returns:
- an HttpConnection for the given configuraiton
- Throws:
HttpException
- if no connection becomes available before the timeout expires- See Also:
HttpConnectionManager.getConnection(HostConfiguration, long)
-
getConnectionsInPool
public int getConnectionsInPool(HostConfiguration hostConfiguration)
Deprecated.Gets the total number of pooled connections for the given host configuration. This is the total number of connections that have been created and are still in use by this connection manager for the host configuration. This value will not exceed themaximum number of connections per host
.- Parameters:
hostConfiguration
- The host configuration- Returns:
- The total number of pooled connections
-
getConnectionsInPool
public int getConnectionsInPool()
Deprecated.Gets the total number of pooled connections. This is the total number of connections that have been created and are still in use by this connection manager. This value will not exceed themaximum number of connections
.- Returns:
- the total number of pooled connections
-
getConnectionsInUse
public int getConnectionsInUse(HostConfiguration hostConfiguration)
Deprecated.Gets the number of connections in use for this configuration.- Parameters:
hostConfiguration
- the key that connections are tracked on- Returns:
- the number of connections in use
-
getConnectionsInUse
public int getConnectionsInUse()
Deprecated.Gets the total number of connections in use.- Returns:
- the total number of connections in use
-
deleteClosedConnections
public void deleteClosedConnections()
Deprecated.Deletes all closed connections. Only connections currently owned by the connection manager are processed.- Since:
- 3.0
- See Also:
HttpConnection.isOpen()
-
closeIdleConnections
public void closeIdleConnections(long idleTimeout)
Deprecated.Description copied from interface:HttpConnectionManager
Closes connections that have been idle for at least the given amount of time. Only connections that are currently owned, not checked out, are subject to idle timeouts.- Specified by:
closeIdleConnections
in interfaceHttpConnectionManager
- Parameters:
idleTimeout
- the minimum idle time, in milliseconds, for connections to be closed- Since:
- 3.0
-
releaseConnection
public void releaseConnection(HttpConnection conn)
Deprecated.Make the given HttpConnection available for use by other requests. If another thread is blocked in getConnection() that could use this connection, it will be woken up.- Specified by:
releaseConnection
in interfaceHttpConnectionManager
- Parameters:
conn
- the HttpConnection to make available.
-
getParams
public HttpConnectionManagerParams getParams()
Deprecated.Returnsparameters
associated with this connection manager.- Specified by:
getParams
in interfaceHttpConnectionManager
- Since:
- 3.0
- See Also:
HttpConnectionManagerParams
-
setParams
public void setParams(HttpConnectionManagerParams params)
Deprecated.Assignsparameters
for this connection manager.- Specified by:
setParams
in interfaceHttpConnectionManager
- Since:
- 3.0
- See Also:
HttpConnectionManagerParams
-
-