Interface ConnectionPool
- All Superinterfaces:
AutoCloseable, Closeable
- All Known Implementing Classes:
AbstractConnectionPool, DuplexConnectionPool, LeakTrackingConnectionPool, MultiplexConnectionPool, RandomConnectionPool, RoundRobinConnectionPool, ValidatingConnectionPool
Client-side connection pool abstraction.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceFactory for ConnectionPool instances.static interfaceMarks a connection pool as supporting multiplexed connections. -
Method Summary
Modifier and TypeMethodDescriptionacquire()Returns an idle connection, if available, or schedules the opening of a new connection and returnsnull.voidclose()Closes this ConnectionPool.booleanisActive(Connection connection) booleanisClosed()booleanisEmpty()default CompletableFuture<Void> preCreateConnections(int connectionCount) Optionally pre-create up toconnectionCountconnections so they are immediately ready for use.booleanrelease(Connection connection) Returns the given connection, previously obtained viaacquire(), back to this ConnectionPool.booleanremove(Connection connection) Removes the given connection from this ConnectionPool.
-
Method Details
-
preCreateConnections
Optionally pre-create up toconnectionCountconnections so they are immediately ready for use.- Parameters:
connectionCount- the number of connections to pre-start.
-
isActive
- Parameters:
connection- the connection to test- Returns:
- whether the given connection is currently in use
-
isEmpty
boolean isEmpty()- Returns:
- whether this ConnectionPool has no open connections
-
isClosed
boolean isClosed()- Returns:
- whether this ConnectionPool has been closed
- See Also:
-
acquire
Connection acquire()Returns an idle connection, if available, or schedules the opening of a new connection and returns
null.- Returns:
- an available connection, or null
-
release
Returns the given connection, previously obtained via
acquire(), back to this ConnectionPool.- Parameters:
connection- the connection to release- Returns:
- true if the connection has been released, false if the connection should be closed
-
remove
Removes the given connection from this ConnectionPool.
- Parameters:
connection- the connection to remove- Returns:
- true if the connection was removed from this ConnectionPool
-
close
void close()Closes this ConnectionPool.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- See Also:
-