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 the
AbstractConnectionPool.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 the
LDAPConnectionPool class; it cannot be used with
LDAPThreadLocalConnectionPool instances.-
Constructor Summary
ConstructorsConstructorDescriptionPruneUnneededConnectionsLDAPConnectionPoolHealthCheck(int minAvailableConnections, long minDurationMillisExceedingMinAvailableConnections) Creates a new instance of this LDAP connection pool health check with the provided information. -
Method Summary
Modifier and TypeMethodDescriptionintRetrieves the minimum number of connections that should be maintained in the connection pool.longRetrieves 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.voidPerforms any processing that may be appropriate on an ongoing basis for the connection pool that is related to the pool itself rather than any individual connection.voidtoString(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 Details
-
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 Details
-
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
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
Performs any processing that may be appropriate on an ongoing basis for the connection pool that is related to the pool itself rather than any individual connection. This method will be invoked by the pool'sLDAPConnectionPoolHealthCheckThreadat 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:
performPoolMaintenancein classLDAPConnectionPoolHealthCheck- Parameters:
pool- The connection pool on which to perform maintenance.
-
toString
Appends a string representation of this LDAP connection pool health check to the provided buffer.- Overrides:
toStringin classLDAPConnectionPoolHealthCheck- Parameters:
buffer- The buffer to which the information should be appended.
-