Class PruneUnneededConnectionsLDAPConnectionPoolHealthCheck

java.lang.Object
com.unboundid.ldap.sdk.LDAPConnectionPoolHealthCheck
com.unboundid.ldap.sdk.PruneUnneededConnectionsLDAPConnectionPoolHealthCheck

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 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 the AbstractConnectionPool.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 the AbstractConnectionPool.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's LDAPConnectionPoolHealthCheckThread at an interval specified by the pool's AbstractConnectionPool.getHealthCheckIntervalMillis() method. This method will be invoked after all other periodic processing (for example, after calling LDAPConnectionPoolHealthCheck.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 class LDAPConnectionPoolHealthCheck
      Parameters:
      pool - The connection pool on which to perform maintenance.
    • toString

      public void toString(@NotNull StringBuilder buffer)
      Appends a string representation of this LDAP connection pool health check to the provided buffer.
      Overrides:
      toString in class LDAPConnectionPoolHealthCheck
      Parameters:
      buffer - The buffer to which the information should be appended.