Package org.opends.server.api
Class ConnectionHandler<T extends ConnectionHandlerCfg>
- java.lang.Object
-
- java.lang.Thread
-
- org.opends.server.api.DirectoryThread
-
- org.opends.server.api.ConnectionHandler<T>
-
- Type Parameters:
T- The type of connection handler configuration handled by this connection handler implementation.
- All Implemented Interfaces:
Runnable
- Direct Known Subclasses:
HTTPConnectionHandler,InternalConnectionHandler,JmxConnectionHandler,LDAPConnectionHandler,LDAPConnectionHandler2,LDIFConnectionHandler,SNMPConnectionHandler
@PublicAPI(stability=VOLATILE, mayInstantiate=false, mayExtend=true, mayInvoke=false) public abstract class ConnectionHandler<T extends ConnectionHandlerCfg> extends DirectoryThread
This class defines the set of methods and structures that must be implemented by a Directory Server connection handler.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.opends.server.api.DirectoryThread
DirectoryThread.Factory
-
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
-
-
Field Summary
Fields Modifier and Type Field Description protected static longLISTEN_TIMEOUT_MSMaximum time astart()implementation waits for its handler thread to attempt to open the listen socket.-
Fields inherited from class org.opends.server.api.DirectoryThread
DIRECTORY_THREAD_GROUP
-
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedConnectionHandler(String threadName)Creates a new instance of this connection handler.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidfinalizeConnectionHandler(org.forgerock.i18n.LocalizableMessage finalizeReason)Closes this connection handler so that it will no longer accept new client connections.abstract Collection<ClientConnection>getClientConnections()Retrieves the set of active client connections that have been established through this connection handler.abstract DNgetComponentEntryDN()Retrieves the DN of the configuration entry with which this alert generator is associated.ConnectionHandlerMonitorgetConnectionHandlerMonitor()Retrieves the monitor instance for this connection handler.abstract StringgetConnectionHandlerName()Retrieves a name that may be used to refer to this connection handler.Collection<String>getEnabledSSLCipherSuites()Retrieves an unmodifiable set of enabled SSL cipher suites configured for this connection handler, if applicable.Collection<String>getEnabledSSLProtocols()Retrieves the set of enabled SSL protocols configured for this connection handler.abstract Collection<HostPort>getListeners()Retrieves information about the listener(s) that will be used to accept client connections.intgetNumRequestHandlers(Integer numRequestHandlers, String friendlyName)Determine the number of request handlers.abstract StringgetProtocol()Retrieves the name of the protocol used to communicate with clients.abstract voidinitializeConnectionHandler(ServerContext serverContext, T configuration)Initializes this connection handler provider based on the information in the provided connection handler configuration.booleanisAdminConnectionHandler()Returns whether this connection handler is the admin connection handler.booleanisConfigurationAcceptable(ConnectionHandlerCfg configuration, List<org.forgerock.i18n.LocalizableMessage> unacceptableReasons)Indicates whether the provided configuration is acceptable for this connection handler.abstract voidrun()Operates in a loop, accepting new connections and ensuring that requests on those connections are handled properly.voidsetAdminConnectionHandler()Sets this connection handler as the admin connection handler.voidsetConnectionHandlerMonitor(ConnectionHandlerMonitor monitor)Sets the monitor instance for this connection handler.StringtoString()Retrieves a string representation of this connection handler.abstract voidtoString(StringBuilder buffer)Appends a string representation of this connection handler to the provided buffer.-
Methods inherited from class org.opends.server.api.DirectoryThread
getAssociatedTask, getCreationStackTrace, getDebugProperties, getParentThread, initiateShutdown, isShutdownInitiated, setAssociatedTask, startWork, stopWork
-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, yield
-
-
-
-
Field Detail
-
LISTEN_TIMEOUT_MS
protected static final long LISTEN_TIMEOUT_MS
Maximum time astart()implementation waits for its handler thread to attempt to open the listen socket. The wait is bounded so that a handler thread dying before it reaches the listen code cannot hang the whole server startup.DirectoryServer.startConnectionHandlers()starts the handlers one after another, so the worst case for a start is this value multiplied by the number of configured handlers. It is therefore kept far below thestart-dstimeout (DirectoryServer.DEFAULT_TIMEOUT, 200 seconds), which is generous for abind().
-
-
Constructor Detail
-
ConnectionHandler
protected ConnectionHandler(String threadName)
Creates a new instance of this connection handler. This must be called by all connection handlers, and all connection handlers must provide default constructors (i.e., those that do not take any arguments) that invoke this constructor.- Parameters:
threadName- The name to use for this thread.
-
-
Method Detail
-
finalizeConnectionHandler
public abstract void finalizeConnectionHandler(org.forgerock.i18n.LocalizableMessage finalizeReason)
Closes this connection handler so that it will no longer accept new client connections. Implementations should disconnect any existing connections.- Parameters:
finalizeReason- The reason that this connection handler should be finalized.
-
getConnectionHandlerName
public abstract String getConnectionHandlerName()
Retrieves a name that may be used to refer to this connection handler. Every connection handler instance (even handlers of the same type) must have a unique name.- Returns:
- A unique name that may be used to refer to this connection handler.
-
getEnabledSSLCipherSuites
public Collection<String> getEnabledSSLCipherSuites()
Retrieves an unmodifiable set of enabled SSL cipher suites configured for this connection handler, if applicable. Implementations must return an empty set if use of SSL/TLS is not possible.- Returns:
- The set of enabled SSL cipher suites configured for this connection handler.
-
getEnabledSSLProtocols
public Collection<String> getEnabledSSLProtocols()
Retrieves the set of enabled SSL protocols configured for this connection handler. Implementations must return an empty set if use of SSL/TLS is not possible.- Returns:
- The set of enabled SSL protocols configured for this connection handler.
-
getComponentEntryDN
public abstract DN getComponentEntryDN()
Retrieves the DN of the configuration entry with which this alert generator is associated.- Returns:
- The DN of the configuration entry with which this alert generator is associated.
-
getProtocol
public abstract String getProtocol()
Retrieves the name of the protocol used to communicate with clients. It should take into account any special naming that may be needed to express any security mechanisms or other constraints in place (e.g., "LDAPS" for LDAP over SSL).- Returns:
- The name of the protocol used to communicate with clients.
-
getListeners
public abstract Collection<HostPort> getListeners()
Retrieves information about the listener(s) that will be used to accept client connections.- Returns:
- Information about the listener(s) that will be used to accept client connections, or an empty list if this connection handler does not accept connections from network clients.
-
getClientConnections
public abstract Collection<ClientConnection> getClientConnections()
Retrieves the set of active client connections that have been established through this connection handler.- Returns:
- The set of active client connections that have been established through this connection handler.
-
initializeConnectionHandler
public abstract void initializeConnectionHandler(ServerContext serverContext, T configuration) throws ConfigException, InitializationException
Initializes this connection handler provider based on the information in the provided connection handler configuration.- Parameters:
serverContext- The server context.configuration- The connection handler configuration that contains the information to use to initialize this connection handler.- Throws:
ConfigException- If an unrecoverable problem arises in the process of performing the initialization as a result of the server configuration.InitializationException- If a problem occurs during initialization that is not related to the server configuration.
-
isConfigurationAcceptable
public boolean isConfigurationAcceptable(ConnectionHandlerCfg configuration, List<org.forgerock.i18n.LocalizableMessage> unacceptableReasons)
Indicates whether the provided configuration is acceptable for this connection handler. It should be possible to call this method on an uninitialized connection handler instance in order to determine whether the connection handler would be able to use the provided configuration.
Note that implementations which use a subclass of the provided configuration class will likely need to cast the configuration to the appropriate subclass type.- Parameters:
configuration- The connection handler configuration for which to make the determination.unacceptableReasons- A list that may be used to hold the reasons that the provided configuration is not acceptable.- Returns:
trueif the provided configuration is acceptable for this connection handler, orfalseif not.
-
run
public abstract void run()
Operates in a loop, accepting new connections and ensuring that requests on those connections are handled properly.
-
getConnectionHandlerMonitor
public final ConnectionHandlerMonitor getConnectionHandlerMonitor()
Retrieves the monitor instance for this connection handler.- Returns:
- The monitor instance for this connection handler, or
nullif none has been provided.
-
setConnectionHandlerMonitor
public final void setConnectionHandlerMonitor(ConnectionHandlerMonitor monitor)
Sets the monitor instance for this connection handler.- Parameters:
monitor- The monitor instance for this connection handler.
-
setAdminConnectionHandler
public void setAdminConnectionHandler()
Sets this connection handler as the admin connection handler.
-
isAdminConnectionHandler
public boolean isAdminConnectionHandler()
Returns whether this connection handler is the admin connection handler.- Returns:
- boolean True if this connection handler is the admin connection handler, false otherwise
-
getNumRequestHandlers
public int getNumRequestHandlers(Integer numRequestHandlers, String friendlyName)
Determine the number of request handlers.- Parameters:
numRequestHandlers- the number of request handlers from the configuration.friendlyName- the friendly name of this connection handler- Returns:
- the number of request handlers from the configuration determined from the configuration or from the number of available processors on the current machine
-
toString
public String toString()
Retrieves a string representation of this connection handler.
-
toString
public abstract void toString(StringBuilder buffer)
Appends a string representation of this connection handler to the provided buffer.- Parameters:
buffer- The buffer to which the information should be appended.
-
-