com.unboundid.ldap.sdk
Class ServerSet

java.lang.Object
  extended by com.unboundid.ldap.sdk.ServerSet
Direct Known Subclasses:
DNSSRVRecordServerSet, FailoverServerSet, FastestConnectServerSet, FewestConnectionsServerSet, RoundRobinDNSServerSet, RoundRobinServerSet, SingleServerSet

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

This class defines an API that can be used to select between multiple directory servers when establishing a connection. Implementations are free to use any kind of logic that they desire when selecting the server to which the connection is to be established. They may also support the use of health checks to determine whether the created connections are suitable for use.

Implementations MUST be threadsafe to allow for multiple concurrent attempts to establish new connections.


Constructor Summary
protected ServerSet()
          Creates a new instance of this server set.
 
Method Summary
abstract  LDAPConnection getConnection()
          Attempts to establish a connection to one of the directory servers in this server set.
 LDAPConnection getConnection(LDAPConnectionPoolHealthCheck healthCheck)
          Attempts to establish a connection to one of the directory servers in this server set, using the provided health check to further validate the connection.
 java.lang.String toString()
          Retrieves a string representation of this server set.
 void toString(java.lang.StringBuilder buffer)
          Appends a string representation of this server set to the provided buffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ServerSet

protected ServerSet()
Creates a new instance of this server set.

Method Detail

getConnection

public abstract LDAPConnection getConnection()
                                      throws LDAPException
Attempts to establish a connection to one of the directory servers in this server set. The connection should be established but unauthenticated. The caller may determine the server to which the connection is established using the LDAPConnection.getConnectedAddress() and LDAPConnection.getConnectedPort() methods.

Returns:
An LDAPConnection object that is established to one of the servers in this server set.
Throws:
LDAPException - If it is not possible to establish a connection to any of the servers in this server set.

getConnection

public LDAPConnection getConnection(LDAPConnectionPoolHealthCheck healthCheck)
                             throws LDAPException
Attempts to establish a connection to one of the directory servers in this server set, using the provided health check to further validate the connection. The connection should be established but unauthenticated. The caller may determine the server to which the connection is established using the LDAPConnection.getConnectedAddress() and LDAPConnection.getConnectedPort() methods.

Parameters:
healthCheck - The health check to use to make the determination, or null if no additional health check should be performed.
Returns:
An LDAPConnection object that is established to one of the servers in this server set.
Throws:
LDAPException - If it is not possible to establish a connection to any of the servers in this server set.

toString

public java.lang.String toString()
Retrieves a string representation of this server set.

Overrides:
toString in class java.lang.Object
Returns:
A string representation of this server set.

toString

public void toString(java.lang.StringBuilder buffer)
Appends a string representation of this server set to the provided buffer.

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