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
LdapClient
unless 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_TIMEOUT
seconds before being aborted with aTimeoutResultException
if the requests have not been fulfilled by the release of a connection to the pool.Effectively, receiving
ResultCode.CLIENT_SIDE_CONNECT_ERROR
as 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 class
ConnectionPool.Statistics
Statistics for a connection pool.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Releases any resources associated with this connection pool.io.reactivex.rxjava3.core.Single<LdapClientSocket>
connect()
Returns aSingle
which connects to a peer each time it is subscribed.protected void
finalize()
Provide a finalizer because connection pools are expensive resources to accidentally leave around.ConnectionPool.Statistics
getStatistics()
Retrieves the statistics for this connection pool.String
toString()
-
-
-
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
close
on a connection pool which is already closed has no effect.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceLdapClient
-
connect
public io.reactivex.rxjava3.core.Single<LdapClientSocket> connect()
Description copied from interface:LdapClient
Returns aSingle
which connects to a peer each time it is subscribed.- Specified by:
connect
in interfaceLdapClient
- Returns:
- A
Single
which 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
-
-