com.unboundid.ldap.sdk
Class LDAPConnectionPoolHealthCheck

java.lang.Object
  extended by com.unboundid.ldap.sdk.LDAPConnectionPoolHealthCheck
Direct Known Subclasses:
AggregateLDAPConnectionPoolHealthCheck, GetEntryLDAPConnectionPoolHealthCheck, PasswordExpirationLDAPConnectionPoolHealthCheck

@Extensible
@ThreadSafety(level=INTERFACE_THREADSAFE)
public class LDAPConnectionPoolHealthCheck
extends java.lang.Object

This class provides an API that may be used to determine whether connections associated with a connection pool are valid and suitable for use. It provides the ability to check the validity of a connection at the following times:

Note that health check implementations should be designed so that they are suitable for use with connections having any authentication state. The ensureNewConnectionValid(LDAPConnection) method will be invoked on unauthenticated connections, and the remaining health check methods will be invoked using whatever credentials are assigned to connections in the associated connection pool.


Constructor Summary
LDAPConnectionPoolHealthCheck()
          Creates a new instance of this LDAP connection pool health check.
 
Method Summary
 void ensureConnectionValidAfterAuthentication(LDAPConnection connection, BindResult bindResult)
          Performs any desired processing to determine whether the provided connection is valid after processing a bind operation with the provided result.
 void ensureConnectionValidAfterException(LDAPConnection connection, LDAPException exception)
          Indicates whether the provided connection may still be considered valid after an attempt to process an operation yielded the given exception.
 void ensureConnectionValidForCheckout(LDAPConnection connection)
          Performs any desired processing to determine whether the provided connection is available to be checked out and used for processing operations.
 void ensureConnectionValidForContinuedUse(LDAPConnection connection)
          Performs any desired processing to determine whether the provided connection is valid and should continue to be made available for processing operations.
 void ensureConnectionValidForRelease(LDAPConnection connection)
          Performs any desired processing to determine whether the provided connection is valid and should be released back to the pool to be used for processing other operations.
 void ensureNewConnectionValid(LDAPConnection connection)
          Performs any desired processing to determine whether the provided new connection is available to be checked out and used for processing operations.
 java.lang.String toString()
          Retrieves a string representation of this LDAP connection pool health check.
 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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LDAPConnectionPoolHealthCheck

public LDAPConnectionPoolHealthCheck()
Creates a new instance of this LDAP connection pool health check.

Method Detail

ensureNewConnectionValid

public void ensureNewConnectionValid(LDAPConnection connection)
                              throws LDAPException
Performs any desired processing to determine whether the provided new connection is available to be checked out and used for processing operations. This method will be invoked by either ServerSet used by the connection pool (if it supports enhanced health checking) or by the connection pool itself at the time that a new connection is created. No authentication will have been performed on this connection at the time the health check is invoked.

Parameters:
connection - The connection to be examined.
Throws:
LDAPException - If a problem is detected that suggests that the provided connection is not suitable for use.

ensureConnectionValidAfterAuthentication

public void ensureConnectionValidAfterAuthentication(LDAPConnection connection,
                                                     BindResult bindResult)
                                              throws LDAPException
Performs any desired processing to determine whether the provided connection is valid after processing a bind operation with the provided result.

This method will be invoked under the following circumstances:

Note that this health check method may be invoked even if the bind attempt was not successful. This is useful because it allows the health check to intercept a failed authentication attempt and differentiate it from other types of failures in the course of trying to create or check out a connection. In the event that it is invoked with a BindResult that has a result code other than ResultCode.SUCCESS, if this method throws an exception then that exception will be propagated to the caller. If this method does not throw an exception when provided with a non-SUCCESS result, then the connection pool itself will throw an exception using the information in the bind result.

Parameters:
connection - The connection to be examined.
bindResult - The bind result obtained from the authentication process.
Throws:
LDAPException - If a problem is detected that suggests that the provided connection is not suitable for use.

ensureConnectionValidForCheckout

public void ensureConnectionValidForCheckout(LDAPConnection connection)
                                      throws LDAPException
Performs any desired processing to determine whether the provided connection is available to be checked out and used for processing operations. This method will be invoked by the LDAPConnectionPool.getConnection() method before handing out a connection. This method should return normally if the connection is believed to be valid, or should throw an LDAPException if a problem is detected.

Parameters:
connection - The connection to be examined.
Throws:
LDAPException - If a problem is detected that suggests that the provided connection is not suitable for use.

ensureConnectionValidForRelease

public void ensureConnectionValidForRelease(LDAPConnection connection)
                                     throws LDAPException
Performs any desired processing to determine whether the provided connection is valid and should be released back to the pool to be used for processing other operations. This method will be invoked by the LDAPConnectionPool.releaseConnection(LDAPConnection) method before making the connection available for use in processing other operations. This method should return normally if the connection is believed to be valid, or should throw an LDAPException if a problem is detected.

Parameters:
connection - The connection to be examined.
Throws:
LDAPException - If a problem is detected that suggests that the provided connection is not suitable for use.

ensureConnectionValidForContinuedUse

public void ensureConnectionValidForContinuedUse(LDAPConnection connection)
                                          throws LDAPException
Performs any desired processing to determine whether the provided connection is valid and should continue to be made available for processing operations. This method will be periodically invoked by a background thread used to test availability of connections within the pool. This method should return normally if the connection is believed to be valid, or should throw an LDAPException if a problem is detected.

Parameters:
connection - The connection to be examined.
Throws:
LDAPException - If a problem is detected that suggests that the provided connection is not suitable for use.

ensureConnectionValidAfterException

public void ensureConnectionValidAfterException(LDAPConnection connection,
                                                LDAPException exception)
                                         throws LDAPException
Indicates whether the provided connection may still be considered valid after an attempt to process an operation yielded the given exception. This method will be invoked by the AbstractConnectionPool.releaseConnectionAfterException(com.unboundid.ldap.sdk.LDAPConnection, com.unboundid.ldap.sdk.LDAPException) method, and it may also be manually invoked by external callers if an exception is encountered while processing an operation on a connection checked out from the pool. It may make a determination based solely on the provided exception, or it may also attempt to use the provided connection to further test its validity. This method should return normally if the connection is believed to be valid, or should throw an LDAPException if a problem is detected.

Parameters:
connection - The connection to be examined.
exception - The exception that was caught while processing an operation on the connection.
Throws:
LDAPException - If a problem is detected that suggests that the provided connection is not suitable for use.

toString

public final java.lang.String toString()
Retrieves a string representation of this LDAP connection pool health check.

Overrides:
toString in class java.lang.Object
Returns:
A string representation of this LDAP connection pool health check.

toString

public void toString(java.lang.StringBuilder buffer)
Appends a string representation of this LDAP connection pool health check to the provided buffer.

Parameters:
buffer - The buffer to which the information should be appended.