org.xsocket.connection
Interface IConnectionPool

Package class diagram package IConnectionPool
All Superinterfaces:
Closeable
All Known Implementing Classes:
BlockingConnectionPool, NonBlockingConnectionPool

public interface IConnectionPool
extends Closeable

A connection pool manages a pool of open connections. Typically, a connection pool will be used on the client-side if connections for the same server (address) will be created in a serial manner in a sort period of time. By pooling such connections the overhead of establishing a connection will be avoided For pool management reasons, timeouts can be defined. The IdleTimeout defines the max idle time in the pool. After this time the free connection will be closed. In the same way, the max living time defines the timeout of the connection. If a free connection exceeds this time, the connection will be closed.
Additional the max size of the active connections can be defined. If a connection is requested and the max limit of the active connection is reached, the request will be blocked until a connection becomes free or the maxWaitTime will be reached.

Author:
grro@xsocket.org

Field Summary
static int DEFAULT_CREATION_TIMEOUT_MILLIS
           
static int DEFAULT_IDLE_TIMEOUT_MILLIS
           
static int DEFAULT_LIFE_TIMEOUT_MILLIS
           
static int DEFAULT_MAX_ACTIVE
           
static int DEFAULT_MAX_IDLE
           
static long DEFAULT_MAX_WAIT_MILLIS
           
 
Method Summary
 void addListener(ILifeCycle listener)
          adds a listener
 List<String> getActiveConnectionInfos()
          get a info list about the active connections
 long getCreationMaxWaitMillis()
          get the max waiting by retrieving a resource
 List<String> getIdleConnectionInfos()
          get a info list about the idle connections
 int getMaxActive()
          return the number of max active resources
 int getMaxIdle()
          get the number of max idling resources
 int getNumActive()
          get the current number of the active resources
 int getNumCreated()
          get the number of the created resources
 int getNumDestroyed()
          get the number of the destroyed resources
 int getNumIdle()
          get the current number of idling resources
 int getNumTimeoutPooledMaxIdleTime()
          get the number of timeouts caused by the pool idle timeout
 int getNumTimeoutPooledMaxLifeTime()
          get the number of timeouts caused by the pool life timeout
 int getPooledMaxIdleTimeMillis()
          get the idle time out
 int getPooledMaxLifeTimeMillis()
          get the life timeout of a resource
 boolean isOpen()
          returns true, is pool is open
 boolean removeListener(ILifeCycle listener)
          removes a listener
 void setCreationMaxWaitMillis(long maxWaitMillis)
          set the max waiting by retrieving a resource
 void setMaxActive(int maxActive)
          set the number of max active resources
 void setMaxIdle(int maxIdle)
          set the number of max idling resources
 void setPooledMaxIdleTimeMillis(int idleTimeoutMillis)
          set the idle time out of a resource within the pool
 void setPooledMaxLifeTimeMillis(int lifeTimeoutMillis)
          set the life timeout of a resource
 
Methods inherited from interface java.io.Closeable
close
 

Field Detail

DEFAULT_MAX_ACTIVE

static final int DEFAULT_MAX_ACTIVE
See Also:
Constant Field Values

DEFAULT_MAX_IDLE

static final int DEFAULT_MAX_IDLE
See Also:
Constant Field Values

DEFAULT_MAX_WAIT_MILLIS

static final long DEFAULT_MAX_WAIT_MILLIS
See Also:
Constant Field Values

DEFAULT_IDLE_TIMEOUT_MILLIS

static final int DEFAULT_IDLE_TIMEOUT_MILLIS
See Also:
Constant Field Values

DEFAULT_LIFE_TIMEOUT_MILLIS

static final int DEFAULT_LIFE_TIMEOUT_MILLIS
See Also:
Constant Field Values

DEFAULT_CREATION_TIMEOUT_MILLIS

static final int DEFAULT_CREATION_TIMEOUT_MILLIS
See Also:
Constant Field Values
Method Detail

isOpen

boolean isOpen()
returns true, is pool is open

Returns:
true, is pool is open

addListener

void addListener(ILifeCycle listener)
adds a listener

Parameters:
listener - the listener to add

removeListener

boolean removeListener(ILifeCycle listener)
removes a listener

Parameters:
listener - the listener to remove
Returns:
true, is the listener has been removed

getMaxActive

int getMaxActive()
return the number of max active resources

Returns:
number of max active resources

setMaxActive

void setMaxActive(int maxActive)
set the number of max active resources

Parameters:
maxActive - the number of max active resources

getCreationMaxWaitMillis

long getCreationMaxWaitMillis()
get the max waiting by retrieving a resource

Returns:
the max waiting by retrieving a resource

setCreationMaxWaitMillis

void setCreationMaxWaitMillis(long maxWaitMillis)
set the max waiting by retrieving a resource

Parameters:
maxWaitMillis - the max waiting by retrieving a resource

getMaxIdle

int getMaxIdle()
get the number of max idling resources

Returns:
the number of max idling resources

setMaxIdle

void setMaxIdle(int maxIdle)
set the number of max idling resources

Parameters:
the - number of max idling resources

getNumActive

int getNumActive()
get the current number of the active resources

Returns:
the current number of the active resources

getNumDestroyed

int getNumDestroyed()
get the number of the destroyed resources

Returns:
the number of the destroyed resources

getNumTimeoutPooledMaxLifeTime

int getNumTimeoutPooledMaxLifeTime()
get the number of timeouts caused by the pool life timeout

Returns:
the number of timeouts

getNumTimeoutPooledMaxIdleTime

int getNumTimeoutPooledMaxIdleTime()
get the number of timeouts caused by the pool idle timeout

Returns:
the number of timeouts

getNumCreated

int getNumCreated()
get the number of the created resources

Returns:
the number of the created resources

getActiveConnectionInfos

List<String> getActiveConnectionInfos()
get a info list about the active connections

Returns:
a info list about the active connection

getIdleConnectionInfos

List<String> getIdleConnectionInfos()
get a info list about the idle connections

Returns:
a info list about the idle connections

getNumIdle

int getNumIdle()
get the current number of idling resources

Returns:
the current number of idling resources

getPooledMaxIdleTimeMillis

int getPooledMaxIdleTimeMillis()
get the idle time out

Returns:
the idle time out

setPooledMaxIdleTimeMillis

void setPooledMaxIdleTimeMillis(int idleTimeoutMillis)
set the idle time out of a resource within the pool

Parameters:
idleTimeoutMillis - the idle time out

getPooledMaxLifeTimeMillis

int getPooledMaxLifeTimeMillis()
get the life timeout of a resource

Returns:
the life timeout of a resource

setPooledMaxLifeTimeMillis

void setPooledMaxLifeTimeMillis(int lifeTimeoutMillis)
set the life timeout of a resource

Parameters:
lifeTimeoutSec - the life timeout of a resource


Copyright 2008 xSocket.org