Package com.ibm.di.server
Class ConnectorPool
- java.lang.Object
-
- com.ibm.di.server.ConnectorPool
-
public class ConnectorPool extends java.lang.ObjectThis class is a pool for connectors. It stores certain amount and can give them when needed. When not needed the connectors can be returned to the pool. Also the pool is periodically purged, thus shrunk to a specified size.
-
-
Constructor Summary
Constructors Constructor Description ConnectorPool(java.lang.String aConnectorLibName, PoolDefConfig aPoolDefConfig, Log aLog)Constructor of the connector pool.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConnectorInterfacegetConnector()Returns a connector from the pool.ConnectorInterfacegetConnector(boolean aWaitOnExhausted)Returns a connector from the pool if there is an available free one.intgetFreeConnectorsNum()Returns the count of the free connectors in the pool.java.lang.StringgetName()Returns the name of the connector pool.PoolDefConfiggetPoolConfig()Returns the pool configuration.intgetSize()Returns the size of the pool (the count of connectors in it).voidinitialize()Initializes the connector pool.voidpurge()Removes connectors from the pool and the free connectors collection until the minimum size of the pool is reached.voidreturnConnector(ConnectorInterface aConnector)Returns a connector to the pool and enlists it again in the free connectors.voidterminate()Terminates the connector pool.
-
-
-
Constructor Detail
-
ConnectorPool
public ConnectorPool(java.lang.String aConnectorLibName, PoolDefConfig aPoolDefConfig, Log aLog) throws java.lang.ExceptionConstructor of the connector pool.- Parameters:
aConnectorLibName- a connector pool name used for logging.aPoolDefConfig- a default configuration for the poolaLog- a Log object used to log messages to log files- Throws:
java.lang.Exception
-
-
Method Detail
-
initialize
public void initialize() throws java.lang.ExceptionInitializes the connector pool.- Throws:
java.lang.Exception- if a problem occurs
-
terminate
public void terminate() throws java.lang.ExceptionTerminates the connector pool. Closes connections and frees resources taken from the free connectors in the pool. Also terminates the timer used to perform shrink operations.- Throws:
java.lang.Exception- if a problem occurs
-
getName
public java.lang.String getName()
Returns the name of the connector pool.- Returns:
- the connector pool's name
-
getSize
public int getSize()
Returns the size of the pool (the count of connectors in it).- Returns:
- pool size
-
getFreeConnectorsNum
public int getFreeConnectorsNum()
Returns the count of the free connectors in the pool.- Returns:
- free connectors number
-
getPoolConfig
public PoolDefConfig getPoolConfig()
Returns the pool configuration.- Returns:
- the default pool configuration
-
getConnector
public ConnectorInterface getConnector() throws java.lang.Exception
Returns a connector from the pool. Waits until a connector is returned to the pool and uses it.- Returns:
- a connector
- Throws:
java.lang.Exception- if a problem occurs
-
getConnector
public ConnectorInterface getConnector(boolean aWaitOnExhausted) throws java.lang.Exception
Returns a connector from the pool if there is an available free one. If theaWaitOnExhaustedoption is used, this method will wait for a connector to be returned to the pool and use it. When a connector is taken from the pool it is no longer a free connector but a used one.- Parameters:
aWaitOnExhausted- whether to wait for a connector to be returned to the pool, or take one directly- Returns:
- a connector.
- Throws:
java.lang.Exception- if a problem occurs
-
returnConnector
public void returnConnector(ConnectorInterface aConnector) throws java.lang.Exception
Returns a connector to the pool and enlists it again in the free connectors.- Parameters:
aConnector- the returned connector- Throws:
java.lang.Exception- if a problem occurs
-
purge
public void purge()
Removes connectors from the pool and the free connectors collection until the minimum size of the pool is reached.
-
-