Pooling ldap connections provides a way to mitigate the overhead of creating LDAP connections. A connection pool is controlled by the following properties:
size the pool should be initialized to and pruned to
maximum size the pool can grow to
whether connections should be validated when returned to the pool
whether connections should be validated when loaned out from the pool
whether connections should be validated periodically when the pool is idle
class to activate connections as they are checked out of the pool for use
class to passivate connections as they are returned to the pool
class to validate that a connection is viable for use
class to remove unneeded connections from the pool
Ldaptive provides a PooledConnectionFactory implementation which uses a blocking connection pool.
Unlike a DefaultConnectionFactory, this implementation must be initialized before use and closed to free the pool resources.
Ldaptive supports validating a connection on check out and check in. By default a SearchConnectionValidator is used if validation is configured. Connections that fail validation are evicted from the pool. The interface for validators looks like:
Ldaptive provides the following validator implementations:
Validates a connection by performing a compare operation. By default this validator performs a rootDSE compare on objectClass: top.
Validation is successful if the compare operation returns any result.
Validates a connection by performing a search operation. By default this validator performs an object level rootDSE search for (objectClass=*).
Validation is successful if the search operation returns any result.
You can also configure validation to occur when the pool is idle instead of during check outs and check ins. By performing validation periodically rather than for every checkIn/checkOut you will improve performance during peak periods of load. This functionality can also serve as a keep-alive for long lived connections.
Extra connections are removed from the pool using a PruneStrategy. The interface for prune strategy looks like:
Prunes connections from the pool based on how long they have been idle. This is the default prune strategy and it has the following properties:
period at which pool should be pruned
time at which a connection should be considered idle and become a candidate for removal from the pool
A custom idle prune strategy can be configured by setting the prune strategy on the connection pool.
Ldaptive is an open source project developed and supported by
at Virginia Tech