|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.zib.scalaris.ConnectionPool
public class ConnectionPool
Implements a simple (thread-safe) connection pool for Scalaris connections.
| Constructor Summary | |
|---|---|
ConnectionPool(ConnectionFactory cFactory,
int maxConnections)
Creates a new connection pool. |
|
| Method Summary | |
|---|---|
void |
closeAll()
Closes all available pooled connections. |
void |
closeAllBut(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. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
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)| Method Detail |
|---|
public Connection getConnection()
throws ConnectionException
ConnectionException - if creating the connection fails
public 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(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()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||