Package com.unboundid.ldap.sdk
Class PruneUnneededConnectionsLDAPConnectionPoolHealthCheck
- java.lang.Object
-
- com.unboundid.ldap.sdk.LDAPConnectionPoolHealthCheck
-
- com.unboundid.ldap.sdk.PruneUnneededConnectionsLDAPConnectionPoolHealthCheck
-
@ThreadSafety(level=COMPLETELY_THREADSAFE) public final class PruneUnneededConnectionsLDAPConnectionPoolHealthCheck extends LDAPConnectionPoolHealthCheck
This class provides an implementation of an LDAP connection pool health check that periodically monitors the number of available connections in the pool. If the number of available connections has been consistently greater than a specified minimum for at least a given length of time, then the number of available connections will be reduced to that minimum. Note that the size of the pool will only be checked at interval's specified by theAbstractConnectionPool.getHealthCheckIntervalMillis()
method, so it is possible that the number of available connections may have dipped below that minimum on one or more occasions between checks. Also note that this health check can only be used on instances of theLDAPConnectionPool
class; it cannot be used withLDAPThreadLocalConnectionPool
instances.
-
-
Constructor Summary
Constructors Constructor Description PruneUnneededConnectionsLDAPConnectionPoolHealthCheck(int minAvailableConnections, long minDurationMillisExceedingMinAvailableConnections)
Creates a new instance of this LDAP connection pool health check with the provided information.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getMinAvailableConnections()
Retrieves the minimum number of connections that should be maintained in the connection pool.long
getMinDurationMillisExceedingMinAvailableConnections()
Retrieves the minimum length of time in milliseconds that the pool should have reported at least the specified minimum number of available connections before any connections may be removed.void
performPoolMaintenance(AbstractConnectionPool pool)
Performs any processing that may be appropriate on an ongoing basis for the connection pool that is not related to the pool itself rather than any individual connection.void
toString(java.lang.StringBuilder buffer)
Appends a string representation of this LDAP connection pool health check to the provided buffer.-
Methods inherited from class com.unboundid.ldap.sdk.LDAPConnectionPoolHealthCheck
ensureConnectionValidAfterAuthentication, ensureConnectionValidAfterException, ensureConnectionValidForCheckout, ensureConnectionValidForContinuedUse, ensureConnectionValidForRelease, ensureNewConnectionValid, toString
-
-
-
-
Constructor Detail
-
PruneUnneededConnectionsLDAPConnectionPoolHealthCheck
public PruneUnneededConnectionsLDAPConnectionPoolHealthCheck(int minAvailableConnections, long minDurationMillisExceedingMinAvailableConnections)
Creates a new instance of this LDAP connection pool health check with the provided information.- Parameters:
minAvailableConnections
- The minimum number of connections that should be maintained in the connection pool. This health check will only remove connections if the pool has more than this number of connections for at least the specified duration. A value that is less than or equal to zero indicates that no minimum number of connections needs to be maintained.minDurationMillisExceedingMinAvailableConnections
- The minimum length of time in milliseconds that the pool should have reported at least the specified minimum number of available connections before any connections may be removed. Note that the number of connections will only be checked at intervals specified by theAbstractConnectionPool.getHealthCheckIntervalMillis()
method, so it may be possible for the number of available connections to dip below this value one or more time between intervals and still cause the pool to be reduced in size. A value that is less than or equal to zero indicates that the pool size should be reduced to the configured minimum any time there are more than that number of connections available.
-
-
Method Detail
-
getMinAvailableConnections
public int getMinAvailableConnections()
Retrieves the minimum number of connections that should be maintained in the connection pool. This health check will only remove connections if the pool has more than this number of connections for at least the specified duration.- Returns:
- The minimum number of connections that should be maintained in the connection pool.
-
getMinDurationMillisExceedingMinAvailableConnections
public long getMinDurationMillisExceedingMinAvailableConnections()
Retrieves the minimum length of time in milliseconds that the pool should have reported at least the specified minimum number of available connections before any connections may be removed. Note that the number of connections will only be checked at intervals specified by theAbstractConnectionPool.getHealthCheckIntervalMillis()
method, so it may be possible for the number of available connections to dip below this value one or more time between intervals and still cause the pool to be reduced in size.- Returns:
- The minimum length of time in milliseconds that the pool should have reported at least the specified minimum number of available connections before any connections may be removed.
-
performPoolMaintenance
public void performPoolMaintenance(@NotNull AbstractConnectionPool pool)
Performs any processing that may be appropriate on an ongoing basis for the connection pool that is not related to the pool itself rather than any individual connection. This method will be invoked by the pool'sLDAPConnectionPoolHealthCheckThread
at an interval specified by the pool'sAbstractConnectionPool.getHealthCheckIntervalMillis()
method. This method will be invoked after all other periodic processing (for example, after callingLDAPConnectionPoolHealthCheck.ensureConnectionValidForContinuedUse(com.unboundid.ldap.sdk.LDAPConnection)
on each available connection, if appropriate for the pool implementation) has been performed during the interval.- Overrides:
performPoolMaintenance
in classLDAPConnectionPoolHealthCheck
- Parameters:
pool
- The connection pool on which to perform maintenance.
-
toString
public void toString(@NotNull java.lang.StringBuilder buffer)
Appends a string representation of this LDAP connection pool health check to the provided buffer.- Overrides:
toString
in classLDAPConnectionPoolHealthCheck
- Parameters:
buffer
- The buffer to which the information should be appended.
-
-