Class ConnectionPool
- java.lang.Object
-
- org.forgerock.opendj.ldap.ConnectionPool
-
- All Implemented Interfaces:
Closeable,AutoCloseable,LdapClient
public final class ConnectionPool extends Object implements LdapClient
A connection pool which maintains a cache of client sockets with a configurable core pool size, maximum size, and expiration policy.When connection pool is no longer needed it must be explicitly closed in order to close any remaining pooled connections.
Since pooled connections are re-used, applications must use operations such as binds and StartTLS with extreme caution.
Trying to get a connection when the pool has no connection available, will delegate the connection request to the provided
LdapClientunless the maximum number of connection configured for the pool is reached. At which point the connection request will be queued for a maximum duration ofLdapClients.CONNECT_TIMEOUTseconds before being aborted with aTimeoutResultExceptionif the requests have not been fulfilled by the release of a connection to the pool.Effectively, receiving
ResultCode.CLIENT_SIDE_CONNECT_ERRORas a result of a connection request could be the sign of an undersized connection pool.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classConnectionPool.StatisticsStatistics for a connection pool.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Releases any resources associated with this connection pool.Single<LdapClientSocket>connect()Returns aSinglewhich connects to a peer each time it is subscribed.protected voidfinalize()Provide a finalizer because connection pools are expensive resources to accidentally leave around.ConnectionPool.StatisticsgetStatistics()Retrieves the statistics for this connection pool.StringtoString()
-
-
-
Method Detail
-
close
public void close()
Releases any resources associated with this connection pool. Pooled connections will be permanently closed and this connection pool will no longer be available for use.Attempts to use this connection pool after it has been closed will result in an
IllegalStateException.Calling
closeon a connection pool which is already closed has no effect.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceLdapClient
-
connect
public Single<LdapClientSocket> connect()
Description copied from interface:LdapClientReturns aSinglewhich connects to a peer each time it is subscribed.- Specified by:
connectin interfaceLdapClient- Returns:
- A
Singlewhich connects to a peer each time it is subscribed.
-
finalize
protected void finalize()
Provide a finalizer because connection pools are expensive resources to accidentally leave around. Also, since they won't be created all that frequently, there's little risk of overloading the finalizer.
-
getStatistics
public ConnectionPool.Statistics getStatistics()
Retrieves the statistics for this connection pool.- Returns:
- the statistics for this connection pool
-
-