org.opends.server.protocols.ldap
Class LDAPRequestHandler

java.lang.Object
  extended by java.lang.Thread
      extended by org.opends.server.api.DirectoryThread
          extended by org.opends.server.protocols.ldap.LDAPRequestHandler
All Implemented Interfaces:
java.lang.Runnable, ServerShutdownListener

public class LDAPRequestHandler
extends DirectoryThread
implements ServerShutdownListener

This class defines an LDAP request handler, which is associated with an LDAP connection handler and is responsible for reading and decoding any requests that LDAP clients may send to the server. Multiple request handlers may be used in conjunction with a single connection handler for better performance and scalability.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
static int BUFFER_SIZE
          The buffer size in bytes to use when reading data from a client.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
LDAPRequestHandler(LDAPConnectionHandler connectionHandler, int requestHandlerID)
          Creates a new LDAP request handler that will be associated with the provided connection handler.
 
Method Summary
 void deregisterAllClients()
          Deregisters all clients associated with this request handler.
 void deregisterClient(LDAPClientConnection clientConnection)
          Deregisters the provided client connection from this request handler so it will no longer look for requests from that client.
 java.util.Collection<LDAPClientConnection> getClientConnections()
          Retrieves the set of all client connections that are currently registered with this request handler.
 java.lang.String getShutdownListenerName()
          Retrieves the human-readable name for this shutdown listener.
 void processServerShutdown(Message reason)
          Indicates that the Directory Server has received a request to stop running and that this shutdown listener should take any action necessary to prepare for it.
 boolean registerClient(LDAPClientConnection clientConnection)
          Registers the provided client connection with this request handler so that any requests received from that client will be processed.
 void registerShutdownListener()
          Causes this request handler to register itself as a shutdown listener with the Directory Server.
 void run()
          Operates in a loop, waiting for client requests to arrive and ensuring that they are processed properly.
 
Methods inherited from class org.opends.server.api.DirectoryThread
getAssociatedTask, getCreationStackTrace, getDebugProperties, getParentThread, setAssociatedTask
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BUFFER_SIZE

public static final int BUFFER_SIZE
The buffer size in bytes to use when reading data from a client.

See Also:
Constant Field Values
Constructor Detail

LDAPRequestHandler

public LDAPRequestHandler(LDAPConnectionHandler connectionHandler,
                          int requestHandlerID)
                   throws InitializationException
Creates a new LDAP request handler that will be associated with the provided connection handler.

Parameters:
connectionHandler - The LDAP connection handler with which this request handler is associated.
requestHandlerID - The integer value that may be used to distingush this request handler from others associated with the same connection handler.
Throws:
InitializationException - If a problem occurs while initializing this request handler.
Method Detail

run

public void run()
Operates in a loop, waiting for client requests to arrive and ensuring that they are processed properly.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

registerClient

public boolean registerClient(LDAPClientConnection clientConnection)
Registers the provided client connection with this request handler so that any requests received from that client will be processed.

Parameters:
clientConnection - The client connection to be registered with this request handler.
Returns:
true if the client connection was properly registered with this request handler, or false if not.

deregisterClient

public void deregisterClient(LDAPClientConnection clientConnection)
Deregisters the provided client connection from this request handler so it will no longer look for requests from that client.

Parameters:
clientConnection - The client connection to deregister from this request handler.

deregisterAllClients

public void deregisterAllClients()
Deregisters all clients associated with this request handler.


getClientConnections

public java.util.Collection<LDAPClientConnection> getClientConnections()
Retrieves the set of all client connections that are currently registered with this request handler.

Returns:
The set of all client connections that are currently registered with this request handler.

getShutdownListenerName

public java.lang.String getShutdownListenerName()
Retrieves the human-readable name for this shutdown listener.

Specified by:
getShutdownListenerName in interface ServerShutdownListener
Returns:
The human-readable name for this shutdown listener.

registerShutdownListener

public void registerShutdownListener()
Causes this request handler to register itself as a shutdown listener with the Directory Server. This must be called if the connection handler is shut down without closing all associated connections, otherwise the thread would not be stopped by the server.


processServerShutdown

public void processServerShutdown(Message reason)
Indicates that the Directory Server has received a request to stop running and that this shutdown listener should take any action necessary to prepare for it.

Specified by:
processServerShutdown in interface ServerShutdownListener
Parameters:
reason - The human-readable reason for the shutdown.