Class ClientHandlerThread

  • All Implemented Interfaces:
    java.lang.Runnable

    public class ClientHandlerThread
    extends java.lang.Thread
    This class handles a connection from a single client to the database server.
    • 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 ForwardingOutputStream commandOutput  
      private int id
      The unique ID assigned to this client.
      private static org.apache.logging.log4j.Logger logger
      A logging object for reporting anything interesting that happens.
      private java.io.ObjectInputStream objectInput
      An input-stream for de-serializing objects sent from the client.
      private java.io.ObjectOutputStream objectOutput
      An output-stream for serializing objects to send to the client.
      private java.io.PrintStream printOutput
      A print-stream that will send printed output to the client.
      private NanoDBServer server
      A reference to the NanoDB server object.
      private java.net.Socket sock
      The socket this client-handler uses to interact with its client.
      private TupleSender tupleSender
      A tuple-processor for sending tuples to the client.
      • Fields inherited from class java.lang.Thread

        MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
    • Constructor Summary

      Constructors 
      Constructor Description
      ClientHandlerThread​(NanoDBServer server, int id, java.net.Socket sock)
      Initialize a new client handler with the specified ID and socket.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void doCommand​(Command cmd)  
      void run()
      This is the main loop that handles the commands from the client.
      void shutdownClient()  
      • 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

      • logger

        private static org.apache.logging.log4j.Logger logger
        A logging object for reporting anything interesting that happens.
      • server

        private NanoDBServer server
        A reference to the NanoDB server object.
      • id

        private int id
        The unique ID assigned to this client.
      • sock

        private java.net.Socket sock
        The socket this client-handler uses to interact with its client.
      • objectInput

        private java.io.ObjectInputStream objectInput
        An input-stream for de-serializing objects sent from the client.
      • objectOutput

        private java.io.ObjectOutputStream objectOutput
        An output-stream for serializing objects to send to the client.
      • printOutput

        private java.io.PrintStream printOutput
        A print-stream that will send printed output to the client.
      • tupleSender

        private TupleSender tupleSender
        A tuple-processor for sending tuples to the client.
    • Constructor Detail

      • ClientHandlerThread

        public ClientHandlerThread​(NanoDBServer server,
                                   int id,
                                   java.net.Socket sock)
        Initialize a new client handler with the specified ID and socket.
        Parameters:
        id - The unique ID assigned to this client.
        sock - The socket used to communicate with the client.
    • Method Detail

      • run

        public void run()
        This is the main loop that handles the commands from the client.
        Specified by:
        run in interface java.lang.Runnable
        Overrides:
        run in class java.lang.Thread
      • doCommand

        private void doCommand​(Command cmd)
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • shutdownClient

        public void shutdownClient()