Class SessionState


  • public class SessionState
    extends java.lang.Object
    This class holds all session state associated with a particular client accessing the database. This object can be stored in thread-local storage to ensure that it can be accessed throughout the database engine to determine current client settings.
    • Field Detail

      • nextSessionID

        private static java.util.concurrent.atomic.AtomicInteger nextSessionID
        This static variable holds the next session ID to assign to a client session. It must be accessed in a synchronized manner.
      • threadLocalState

        private static java.lang.ThreadLocal<SessionState> threadLocalState
      • sessionID

        private int sessionID
        The unique session ID assigned to this client session.
      • outputStream

        private java.io.PrintStream outputStream
        This is the output stream for the current client. If there are multiple clients, writing to this stream will go to the client associated with this session.
      • txnState

        private TransactionState txnState
        The transaction state of this session.
      • cmdState

        private CommandState cmdState
        The command state of this session.
    • Constructor Detail

      • SessionState

        private SessionState​(int sessionID)
    • Method Detail

      • get

        public static SessionState get()
        Returns the current session state, possibly initializing a new session with its own unique ID in the process. This value is stored in thread-local storage, so no thread-safety is required when manipulating the returned object.
        Returns:
        the session-state for this local thread.
      • remove

        public static void remove()
        Removes the session-state from the thread's thread-local storage.
      • getSessionID

        public int getSessionID()
        Returns the unique session ID for this client.
        Returns:
        the unique session ID for this client.
      • getOutputStream

        public java.io.PrintStream getOutputStream()
      • setOutputStream

        public void setOutputStream​(java.io.PrintStream out)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object