Class MultiThreadedConnectionPoolServer

  • All Implemented Interfaces:
    ConnectionPoolServer

    final class MultiThreadedConnectionPoolServer
    extends java.lang.Object
    implements ConnectionPoolServer
    A multi-threaded implementation of a connection pool server. This starts a new thread for each connection made and processes each command as they arrive.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.ArrayList client_threads
      The list of all threads that were created to deal with incoming commands.
      private Database database
      The Database parent.
      private static boolean DISPLAY_STATS
      If this is set to true then the server periodically outputs statistics about the connections.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addConnection​(ServerConnection connection)
      Connects a new ServerConnection into the pool of connections to clients that this server maintains.
      void close()
      Closes this connection pool server down.
      DebugLogger Debug()
      Returns a DebugLogger object that we can log debug messages to.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DISPLAY_STATS

        private static final boolean DISPLAY_STATS
        If this is set to true then the server periodically outputs statistics about the connections.
        See Also:
        Constant Field Values
      • database

        private Database database
        The Database parent.
      • client_threads

        private java.util.ArrayList client_threads
        The list of all threads that were created to deal with incoming commands.
    • Constructor Detail

      • MultiThreadedConnectionPoolServer

        MultiThreadedConnectionPoolServer​(Database database)
        The Constructor. The argument is the configuration file.
    • Method Detail

      • Debug

        public final DebugLogger Debug()
        Returns a DebugLogger object that we can log debug messages to.
      • addConnection

        public void addConnection​(ServerConnection connection)
        Connects a new ServerConnection into the pool of connections to clients that this server maintains. We then cycle through these connections determining whether any commands are pending. If a command is pending we spawn off a worker thread to do the task.
        Specified by:
        addConnection in interface ConnectionPoolServer
      • close

        public void close()
        Closes this connection pool server down.
        Specified by:
        close in interface ConnectionPoolServer