Class SingleThreadedConnectionPoolServer.ServerFarmer

  • All Implemented Interfaces:
    java.lang.Runnable
    Enclosing class:
    SingleThreadedConnectionPoolServer

    private class SingleThreadedConnectionPoolServer.ServerFarmer
    extends java.lang.Thread
    This thread is a low priority thread that checks all the current service providers periodically to determine if there's any commands pending.
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.lang.Thread

        java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int commands_run  
      private int commands_waited  
      private boolean farmer_closed
      If this is set to true, then the farmer run method should close off.
      private int poll_wait_time
      The number of milliseconds to wait between each poll of the 'available' method of the socket.
      private java.util.ArrayList server_connections_list
      The list of ServerConnection objects that are currently being serviced by this server.
      private int stat_display
      Staticial information collected.
      • Fields inherited from class java.lang.Thread

        MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
    • Constructor Summary

      Constructors 
      Constructor Description
      ServerFarmer()
      The Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void checkCurrentConnections()
      Checks each connection in the 'service_connection_list' list.
      void close()
      Call this method to stop the farmer thread.
      private void displayStatistics()
      Displays statistics about the server.
      private void doPings()
      Performs a ping on a single random connection.
      private void establishPendingConnections()
      Establishes a connection with any current pending connections in the 'pending_connections_list'.
      void run()
      The Runnable method of the farmer thread.
      • 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, toString, yield
      • Methods inherited from class java.lang.Object

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

      • server_connections_list

        private java.util.ArrayList server_connections_list
        The list of ServerConnection objects that are currently being serviced by this server.
      • stat_display

        private int stat_display
        Staticial information collected.
      • commands_run

        private int commands_run
      • commands_waited

        private int commands_waited
      • farmer_closed

        private boolean farmer_closed
        If this is set to true, then the farmer run method should close off.
      • poll_wait_time

        private int poll_wait_time
        The number of milliseconds to wait between each poll of the 'available' method of the socket. This value is determined by the configuration file during initialization.
    • Constructor Detail

      • ServerFarmer

        public ServerFarmer()
        The Constructor.
    • Method Detail

      • establishPendingConnections

        private void establishPendingConnections()
                                          throws java.io.IOException
        Establishes a connection with any current pending connections in the 'pending_connections_list'.
        Throws:
        java.io.IOException
      • checkCurrentConnections

        private void checkCurrentConnections()
        Checks each connection in the 'service_connection_list' list. If there is a command pending, and any previous commands on this connection have completed, then this will spawn off a new process to deal with the command.
      • doPings

        private void doPings()
        Performs a ping on a single random connection. If the ping fails then the connection is closed.
      • displayStatistics

        private void displayStatistics()
        Displays statistics about the server.
      • close

        public void close()
        Call this method to stop the farmer thread.
      • run

        public void run()
        The Runnable method of the farmer thread.
        Specified by:
        run in interface java.lang.Runnable
        Overrides:
        run in class java.lang.Thread