Class ConnectionPool
- All Implemented Interfaces:
Closeable
,AutoCloseable
,LdapClient
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 of LdapClients.CONNECT_TIMEOUT
seconds before being aborted with a TimeoutResultException
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
Modifier and TypeClassDescriptionstatic final record
Statistics for a connection pool. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Releases any resources associated with this connection pool.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.Retrieves the statistics for this connection pool.toString()
-
Method Details
-
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
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.
-
toString
-
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
Retrieves the statistics for this connection pool.- Returns:
- the statistics for this connection pool
-