Class ConnectionHandler<T extends ConnectionHandlerCfg>

    • Field Detail

      • LISTEN_TIMEOUT_MS

        protected static final long LISTEN_TIMEOUT_MS
        Maximum time a start() 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 the start-ds timeout (DirectoryServer.DEFAULT_TIMEOUT, 200 seconds), which is generous for a bind().

    • 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:
        true if the provided configuration is acceptable for this connection handler, or false if not.
      • run

        public abstract void run()
        Operates in a loop, accepting new connections and ensuring that requests on those connections are handled properly.
        Specified by:
        run in interface Runnable
        Overrides:
        run in class Thread
      • getConnectionHandlerMonitor

        public final ConnectionHandlerMonitor getConnectionHandlerMonitor()
        Retrieves the monitor instance for this connection handler.
        Returns:
        The monitor instance for this connection handler, or null if 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.
        Overrides:
        toString in class Thread
        Returns:
        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.