public class ConnectionPool
extends java.lang.Object
| Constructor | Description |
|---|---|
ConnectionPool(ConnectionFactory cFactory,
int maxConnections) |
Creates a new connection pool.
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
closeAll() |
Closes all available pooled connections.
|
void |
closeAllBut(java.util.Collection<PeerNode> remainingNodes) |
Closes all available pooled connections to any node not in the given
collection.
|
Connection |
getConnection() |
Gets a connection from the pool.
|
Connection |
getConnection(long timeout) |
Tries to get a valid connection from the pool waiting at most
timeout milliseconds.
|
ConnectionFactory |
getConnectionFactory() |
Gets the connection factory used by the pool.
|
void |
releaseConnection(Connection conn) |
Puts the given connection back into the pool.
|
public ConnectionPool(ConnectionFactory cFactory, int maxConnections)
cFactory - the connection factory to use to create new connectionsmaxConnections - the maximum number of connections (0 for no limit)public Connection getConnection() throws ConnectionException
ConnectionException - if creating the connection failspublic Connection getConnection(long timeout) throws ConnectionException
timeout - number of milliseconds to wait at most for a valid connection
to appear (0 to wait forever)ConnectionException - if creating the connection failspublic void releaseConnection(Connection conn)
conn - the connection to releasepublic void closeAll()
public void closeAllBut(java.util.Collection<PeerNode> remainingNodes)
remainingNodes - a set of nodes to which connections should remain (fast access
to Collection.contains(Object) is preferable, e.g. use
Set)public ConnectionFactory getConnectionFactory()