com.oaklandsw.http
Class HttpConnectionManager

java.lang.Object
  extended bycom.oaklandsw.http.HttpConnectionManager

public class HttpConnectionManager
extends java.lang.Object

Creates and manages a pool of HttpConnections.

Used only to get an HttpConnection to allow repeated use of a specific connection for a HttpURLConnection.


Field Summary
static int COUNT_ATTEMPTED
           
static int COUNT_AVOIDED_FLUSHES
           
static int COUNT_BUFFER_FLUSHES
           
static int COUNT_FAIL_GE_400
           
static int COUNT_FAIL_MAX_RETRY
           
static int COUNT_FLUSH_IO_ERRORS
           
static int COUNT_FORCED_FLUSHES
           
static int COUNT_LAST
           
static int COUNT_PIPELINE_DEPTH_HIGH
           
static int COUNT_PIPELINE_ERROR
           
static int COUNT_PIPELINE_READ_RESP
           
static int COUNT_PIPELINE_WRITE_REQ
           
static int COUNT_SUCCESS
           
static int COUNT_TOTAL_PIPELINE_RETRY
           
static int COUNT_TOTAL_RETRY
           
 
Constructor Summary
HttpConnectionManager(GlobalState globalState)
           
 
Method Summary
 boolean checkEverythingEmpty()
           
 int getActiveConnectionCount(java.lang.String url)
          Returns the number of connections currently in use for the specified host/port.
 Credential getCachedCredential(ConnectionInfo ci, int authType)
           
 HttpConnection getConnection(HttpURLConnection urlCon)
          Get an HttpConnection for a given URL.
 int getCount(int count)
           
 GlobalState getGlobalState()
           
 int getTotalConnectionCount(java.lang.String url)
          Returns the number of connections currently in use for the specified host/port.
 void releaseConnection(HttpConnection conn)
          Make the given HttpConnection available for use by other requests.
 void resetStatistics()
           
 void setSocketConnectionIOListener(ConnectionIOListener ioListener)
          Sets a ConnectionIOListener to receive events associated with data on the all connections.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COUNT_ATTEMPTED

public static final int COUNT_ATTEMPTED
See Also:
Constant Field Values

COUNT_SUCCESS

public static final int COUNT_SUCCESS
See Also:
Constant Field Values

COUNT_PIPELINE_WRITE_REQ

public static final int COUNT_PIPELINE_WRITE_REQ
See Also:
Constant Field Values

COUNT_PIPELINE_READ_RESP

public static final int COUNT_PIPELINE_READ_RESP
See Also:
Constant Field Values

COUNT_PIPELINE_ERROR

public static final int COUNT_PIPELINE_ERROR
See Also:
Constant Field Values

COUNT_TOTAL_RETRY

public static final int COUNT_TOTAL_RETRY
See Also:
Constant Field Values

COUNT_TOTAL_PIPELINE_RETRY

public static final int COUNT_TOTAL_PIPELINE_RETRY
See Also:
Constant Field Values

COUNT_FAIL_MAX_RETRY

public static final int COUNT_FAIL_MAX_RETRY
See Also:
Constant Field Values

COUNT_FAIL_GE_400

public static final int COUNT_FAIL_GE_400
See Also:
Constant Field Values

COUNT_PIPELINE_DEPTH_HIGH

public static final int COUNT_PIPELINE_DEPTH_HIGH
See Also:
Constant Field Values

COUNT_FORCED_FLUSHES

public static final int COUNT_FORCED_FLUSHES
See Also:
Constant Field Values

COUNT_BUFFER_FLUSHES

public static final int COUNT_BUFFER_FLUSHES
See Also:
Constant Field Values

COUNT_AVOIDED_FLUSHES

public static final int COUNT_AVOIDED_FLUSHES
See Also:
Constant Field Values

COUNT_FLUSH_IO_ERRORS

public static final int COUNT_FLUSH_IO_ERRORS
See Also:
Constant Field Values

COUNT_LAST

public static final int COUNT_LAST
See Also:
Constant Field Values
Constructor Detail

HttpConnectionManager

public HttpConnectionManager(GlobalState globalState)
Method Detail

setSocketConnectionIOListener

public void setSocketConnectionIOListener(ConnectionIOListener ioListener)
Sets a ConnectionIOListener to receive events associated with data on the all connections. The information for which HttpURLConnection is not available when using this method. Use this if you are very concerned about performance as this does not create an extra pair of objects for each HttpURLConnection.

Parameters:
ioListener -

getConnection

public HttpConnection getConnection(HttpURLConnection urlCon)
                             throws HttpException,
                                    java.lang.InterruptedException,
                                    java.net.MalformedURLException
Get an HttpConnection for a given URL. The URL must be fully specified (i.e. contain a protocol and a host (and optional port number). If the maximum number of connections for the host has been reached, this method will block for connectionTimeout milliseconds or until a connection becomes available. If no connection becomes available before the timeout expires an HttpException will be thrown.

Parameters:
urlCon - - an HttpURLConnection
Returns:
an HttpConnection for the given host:port
Throws:
java.net.MalformedURLException
HttpException - - If no connection becomes available before the timeout expires
java.lang.InterruptedException

releaseConnection

public void releaseConnection(HttpConnection conn)
                       throws java.lang.InterruptedException
Make the given HttpConnection available for use by other requests. If another thread is blocked in getConnection() waiting for a connection for this host:port, they will be woken up.

Parameters:
conn - - The HttpConnection to make available.
Throws:
java.lang.InterruptedException

getActiveConnectionCount

public int getActiveConnectionCount(java.lang.String url)
Returns the number of connections currently in use for the specified host/port.


getTotalConnectionCount

public int getTotalConnectionCount(java.lang.String url)
Returns the number of connections currently in use for the specified host/port.


checkEverythingEmpty

public boolean checkEverythingEmpty()

getCachedCredential

public Credential getCachedCredential(ConnectionInfo ci,
                                      int authType)

resetStatistics

public void resetStatistics()

getCount

public int getCount(int count)

getGlobalState

public GlobalState getGlobalState()


Copyright © 2002-2007 Oakland Software Incorporated. All Rights Reserved.