Class BaseContext

  • All Implemented Interfaces:
    Context
    Direct Known Subclasses:
    RedoContext

    public class BaseContext
    extends java.lang.Object
    implements Context
    Context (current connection state) of a connection
    • Field Detail

      • serverCapabilities

        private final long serverCapabilities
      • clientCapabilities

        private final long clientCapabilities
      • seed

        private final byte[] seed
      • eofDeprecated

        private final boolean eofDeprecated
      • skipMeta

        private final boolean skipMeta
      • canUseTransactionIsolation

        private final boolean canUseTransactionIsolation
      • prepareCache

        private final PrepareCache prepareCache
        LRU prepare cache object
      • serverStatus

        protected int serverStatus
        Server status context
      • autoIncrement

        private java.lang.Long autoIncrement
      • threadId

        private long threadId
      • charset

        private java.lang.String charset
      • database

        private java.lang.String database
        Server current database
      • transactionIsolationLevel

        private java.lang.Integer transactionIsolationLevel
        Server current transaction isolation level
      • warning

        private int warning
        Server current warning count
      • stateFlag

        private int stateFlag
        Connection state use flag
      • redirectUrl

        private java.lang.String redirectUrl
      • connectionTimeZone

        private java.util.TimeZone connectionTimeZone
    • Constructor Detail

      • BaseContext

        public BaseContext​(HostAddress hostAddress,
                           InitialHandshakePacket handshake,
                           long clientCapabilities,
                           Configuration conf,
                           ExceptionFactory exceptionFactory,
                           PrepareCache prepareCache)
        Constructor of connection context
        Parameters:
        hostAddress - host address
        handshake - server handshake
        clientCapabilities - client capabilities
        conf - connection configuration
        exceptionFactory - connection exception factory
        prepareCache - LRU prepare cache
    • Method Detail

      • getThreadId

        public long getThreadId()
        Description copied from interface: Context
        return current thread id
        Specified by:
        getThreadId in interface Context
        Returns:
        current server thread id
      • setThreadId

        public void setThreadId​(long connectionId)
        Description copied from interface: Context
        Indicate server connection Id (not truncated)
        Specified by:
        setThreadId in interface Context
        Parameters:
        connectionId - connection id
      • getSeed

        public byte[] getSeed()
        Description copied from interface: Context
        Get connection initial seed
        Specified by:
        getSeed in interface Context
        Returns:
        initial seed
      • hasServerCapability

        public boolean hasServerCapability​(long flag)
        Description copied from interface: Context
        has server capability
        Specified by:
        hasServerCapability in interface Context
        Parameters:
        flag - capability to check
        Returns:
        true if server has capability
      • hasClientCapability

        public boolean hasClientCapability​(long flag)
        Description copied from interface: Context
        has client capability
        Specified by:
        hasClientCapability in interface Context
        Parameters:
        flag - capability to check
        Returns:
        true if client has capability
      • permitPipeline

        public boolean permitPipeline()
        Description copied from interface: Context
        Does server and client permit pipeline
        Specified by:
        permitPipeline in interface Context
        Returns:
        true if permitted
      • getServerStatus

        public int getServerStatus()
        Description copied from interface: Context
        Get server connection state
        Specified by:
        getServerStatus in interface Context
        Returns:
        server status
      • setServerStatus

        public void setServerStatus​(int serverStatus)
        Description copied from interface: Context
        Set server connection state
        Specified by:
        setServerStatus in interface Context
        Parameters:
        serverStatus - server status
      • getDatabase

        public java.lang.String getDatabase()
        Description copied from interface: Context
        Get current connection database
        Specified by:
        getDatabase in interface Context
        Returns:
        database
      • setDatabase

        public void setDatabase​(java.lang.String database)
        Description copied from interface: Context
        set current database context
        Specified by:
        setDatabase in interface Context
        Parameters:
        database - database
      • getVersion

        public ServerVersion getVersion()
        Description copied from interface: Context
        Retrieve server version information
        Specified by:
        getVersion in interface Context
        Returns:
        server version
      • isEofDeprecated

        public boolean isEofDeprecated()
        Description copied from interface: Context
        does protocol remove EOF in exchanges
        Specified by:
        isEofDeprecated in interface Context
        Returns:
        if EOF packet are deprecated
      • canSkipMeta

        public boolean canSkipMeta()
        Description copied from interface: Context
        Can server skip prepared statement metadata
        Specified by:
        canSkipMeta in interface Context
        Returns:
        true if possible
      • getWarning

        public int getWarning()
        Description copied from interface: Context
        has server warnings
        Specified by:
        getWarning in interface Context
        Returns:
        has warnings
      • setWarning

        public void setWarning​(int warning)
        Description copied from interface: Context
        set server state warning number
        Specified by:
        setWarning in interface Context
        Parameters:
        warning - warning number
      • getConf

        public Configuration getConf()
        Description copied from interface: Context
        Get connection configuration
        Specified by:
        getConf in interface Context
        Returns:
        configuration
      • getTransactionIsolationLevel

        public java.lang.Integer getTransactionIsolationLevel()
        Description copied from interface: Context
        Get connection transaction isolation level
        Specified by:
        getTransactionIsolationLevel in interface Context
        Returns:
        connection transaction isolation level
      • setTransactionIsolationLevel

        public void setTransactionIsolationLevel​(java.lang.Integer transactionIsolationLevel)
        Description copied from interface: Context
        Set current connection transaction isolation level
        Specified by:
        setTransactionIsolationLevel in interface Context
        Parameters:
        transactionIsolationLevel - new connection transaction isolation level
      • getPrepareCacheCmd

        public Prepare getPrepareCacheCmd​(java.lang.String sql,
                                          BasePreparedStatement preparedStatement)
        Description copied from interface: Context
        Return cached prepare if key match
        Specified by:
        getPrepareCacheCmd in interface Context
        Parameters:
        sql - sql command
        preparedStatement - current statement
        Returns:
        Prepare if found, null if not
      • putPrepareCacheCmd

        public Prepare putPrepareCacheCmd​(java.lang.String sql,
                                          Prepare result,
                                          BasePreparedStatement preparedStatement)
        Description copied from interface: Context
        Put prepare result in cache
        Specified by:
        putPrepareCacheCmd in interface Context
        Parameters:
        sql - sql command
        result - prepare result
        preparedStatement - current statement
        Returns:
        Prepare if was already cached
      • resetPrepareCache

        public void resetPrepareCache()
        Description copied from interface: Context
        Reset prepare cache (after a failover)
        Specified by:
        resetPrepareCache in interface Context
      • getStateFlag

        public int getStateFlag()
        Description copied from interface: Context
        return connection current state change flag
        Specified by:
        getStateFlag in interface Context
        Returns:
        connection current state change flag
      • resetStateFlag

        public void resetStateFlag()
        Description copied from interface: Context
        reset connection state change flag
        Specified by:
        resetStateFlag in interface Context
      • addStateFlag

        public void addStateFlag​(int state)
        Description copied from interface: Context
        Indicate connection state (for pooling)
        Specified by:
        addStateFlag in interface Context
        Parameters:
        state - indicate that some connection state has changed
      • setTreadsConnected

        public void setTreadsConnected​(long threadsConnected)
        Description copied from interface: Context
        Indicate the number of connection on this server
        Specified by:
        setTreadsConnected in interface Context
        Parameters:
        threadsConnected - number of connected threads
      • getAutoIncrement

        public java.lang.Long getAutoIncrement()
        Description copied from interface: Context
        Get server current auto_increment value
        Specified by:
        getAutoIncrement in interface Context
        Returns:
        server auto increment
      • setAutoIncrement

        public void setAutoIncrement​(long autoIncrement)
        Description copied from interface: Context
        Set server autoincrement value
        Specified by:
        setAutoIncrement in interface Context
        Parameters:
        autoIncrement - current server autoincrement value
      • getCharset

        public java.lang.String getCharset()
        Description copied from interface: Context
        Retrieve current charset if session state get it
        Specified by:
        getCharset in interface Context
        Returns:
        current charset
      • setCharset

        public void setCharset​(java.lang.String charset)
        Description copied from interface: Context
        Indicate server charset change
        Specified by:
        setCharset in interface Context
        Parameters:
        charset - server charset
      • getRedirectUrl

        public java.lang.String getRedirectUrl()
        Description copied from interface: Context
        get redirect Url if server indicate reconnection url
        Specified by:
        getRedirectUrl in interface Context
        Returns:
        null if no redirection required, value if so
      • canUseTransactionIsolation

        public boolean canUseTransactionIsolation()
        Description copied from interface: Context
        Can rely on transaction_isolation or keep using deprecated tx_isolation variable
        Specified by:
        canUseTransactionIsolation in interface Context
        Returns:
        true if you can use transaction_isolation
      • setRedirectUrl

        public void setRedirectUrl​(java.lang.String redirectUrl)
        Description copied from interface: Context
        Set server redirection url
        Specified by:
        setRedirectUrl in interface Context
        Parameters:
        redirectUrl - redirect url
      • getConnectionTimeZone

        public java.util.TimeZone getConnectionTimeZone()
        Description copied from interface: Context
        Get current connection timezone
        Specified by:
        getConnectionTimeZone in interface Context
        Returns:
        connection timezone
      • setConnectionTimeZone

        public void setConnectionTimeZone​(java.util.TimeZone connectionTimeZone)
        Description copied from interface: Context
        Set current connection timezone
        Specified by:
        setConnectionTimeZone in interface Context
        Parameters:
        connectionTimeZone - connection timezone
      • getDefaultCalendar

        public java.util.Calendar getDefaultCalendar()
        Description copied from interface: Context
        Get calendar depending on configuration
        Specified by:
        getDefaultCalendar in interface Context
        Returns:
        calendar