Class BaseContext
java.lang.Object
org.mariadb.jdbc.client.context.BaseContext
- All Implemented Interfaces:
Context
- Direct Known Subclasses:
RedoContext
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Longprivate final booleanprivate Stringprivate final longprivate final Function<ReadableByteBuf, ColumnDecoder> private final Configurationprivate final Runnableprivate TimeZoneprivate StringServer current databaseprivate final booleanprivate final ExceptionFactoryprivate final HostAddressprivate booleanprivate final Booleanprivate Stringprivate final PrepareCacheLRU prepare cache objectprivate Stringprivate final byte[]private final longprivate booleanRead-only state currently applied on the server sessionprotected intServer status contextprivate final booleanprivate intConnection state use flagprivate longprivate IntegerServer current transaction isolation levelprivate final ServerVersionprivate intServer current warning count -
Constructor Summary
ConstructorsConstructorDescriptionBaseContext(HostAddress hostAddress, InitialHandshakePacket handshake, long clientCapabilities, Configuration conf, ExceptionFactory exceptionFactory, PrepareCache prepareCache, Boolean loopbackAddress, Runnable connectionCloser) Constructor of connection context -
Method Summary
Modifier and TypeMethodDescriptionvoidaddStateFlag(int state) Indicate connection state (for pooling)booleanCan server skip prepared statement metadatabooleanCan rely on transaction_isolation or keep using deprecated tx_isolation variableGet server current auto_increment valueRetrieve current charset if session state get itColumn decoder functiongetConf()Get connection configurationGet current connection timezoneGet current connection databaseGet calendar depending on configurationGet connection exception factoryRetrieve maxscaleVersion or null if not the casegetPrepareCacheCmd(String sql, BasePreparedStatement preparedStatement) Return cached prepare if key matchget redirect Url if server indicate reconnection urlbyte[]getSeed()Get connection initial seedintGet server connection stateintreturn connection current state change flaglongreturn current thread idGet connection transaction isolation levelRetrieve server version informationinthas server warningsbooleanhasClientCapability(long flag) has client capabilitybooleanhasServerCapability(long flag) has server capabilitybooleandoes protocol remove EOF in exchangesreturn if host is a local addressbooleanRead-only state currently applied on the server session, i.e.booleanDoes server and client permit pipelineputPrepareCacheCmd(String sql, Prepare result, BasePreparedStatement preparedStatement) Put prepare result in cacheprivate voidrejectNonUtf8(String what, String charset) voidReset prepare cache (after a failover)voidreset connection state change flagvoidsetAutoIncrement(long autoIncrement) Set server autoincrement valuevoidsetCharset(String charset) Indicate server charset change.voidsetCharsetResults(String charset) Indicate server character_set_results change.voidsetConnectionTimeZone(TimeZone connectionTimeZone) Set current connection timezonevoidsetDatabase(String database) set current database contextvoidIndicate that connection is initialized and ready to handle commands.voidsetMaxscaleVersion(String maxscaleVersion) Set Maxscale version.voidsetRedirectUrl(String redirectUrl) Set server redirection urlvoidsetServerReadOnly(boolean serverReadOnly) Record the read-only state currently applied on the server session.voidsetServerStatus(int serverStatus) Set server connection statevoidsetThreadId(long connectionId) Indicate server connection Id (not truncated)voidsetTransactionIsolationLevel(Integer transactionIsolationLevel) Set current connection transaction isolation levelvoidsetTreadsConnected(long threadsConnected) Indicate the number of connection on this servervoidsetWarning(int warning) set server state warning number
-
Field Details
-
serverCapabilities
private final long serverCapabilities -
clientCapabilities
private final long clientCapabilities -
seed
private final byte[] seed -
version
-
eofDeprecated
private final boolean eofDeprecated -
skipMeta
private final boolean skipMeta -
columnDecoderFunction
-
conf
-
exceptionFactory
-
canUseTransactionIsolation
private final boolean canUseTransactionIsolation -
loopbackAddress
-
prepareCache
LRU prepare cache object -
hostAddress
-
serverStatus
protected int serverStatusServer status context -
autoIncrement
-
maxscaleVersion
-
threadId
private long threadId -
charset
-
initialized
private boolean initialized -
connectionCloser
-
database
Server current database -
transactionIsolationLevel
Server current transaction isolation level -
warning
private int warningServer current warning count -
stateFlag
private int stateFlagConnection state use flag -
serverReadOnly
private boolean serverReadOnlyRead-only state currently applied on the server session -
redirectUrl
-
connectionTimeZone
-
-
Constructor Details
-
BaseContext
public BaseContext(HostAddress hostAddress, InitialHandshakePacket handshake, long clientCapabilities, Configuration conf, ExceptionFactory exceptionFactory, PrepareCache prepareCache, Boolean loopbackAddress, Runnable connectionCloser) Constructor of connection context- Parameters:
hostAddress- host addresshandshake- server handshakeclientCapabilities- client capabilitiesconf- connection configurationexceptionFactory- connection exception factoryprepareCache- LRU prepare cacheloopbackAddress- is local address
-
-
Method Details
-
isLoopbackAddress
Description copied from interface:Contextreturn if host is a local address- Specified by:
isLoopbackAddressin interfaceContext- Returns:
- true if host is local
-
getThreadId
public long getThreadId()Description copied from interface:Contextreturn current thread id- Specified by:
getThreadIdin interfaceContext- Returns:
- current server thread id
-
setThreadId
public void setThreadId(long connectionId) Description copied from interface:ContextIndicate server connection Id (not truncated)- Specified by:
setThreadIdin interfaceContext- Parameters:
connectionId- connection id
-
getSeed
-
hasServerCapability
public boolean hasServerCapability(long flag) Description copied from interface:Contexthas server capability- Specified by:
hasServerCapabilityin interfaceContext- Parameters:
flag- capability to check- Returns:
- true if server has capability
-
hasClientCapability
public boolean hasClientCapability(long flag) Description copied from interface:Contexthas client capability- Specified by:
hasClientCapabilityin interfaceContext- Parameters:
flag- capability to check- Returns:
- true if client has capability
-
permitPipeline
public boolean permitPipeline()Description copied from interface:ContextDoes server and client permit pipeline- Specified by:
permitPipelinein interfaceContext- Returns:
- true if permitted
-
getServerStatus
public int getServerStatus()Description copied from interface:ContextGet server connection state- Specified by:
getServerStatusin interfaceContext- Returns:
- server status
-
setServerStatus
public void setServerStatus(int serverStatus) Description copied from interface:ContextSet server connection state- Specified by:
setServerStatusin interfaceContext- Parameters:
serverStatus- server status
-
getDatabase
Description copied from interface:ContextGet current connection database- Specified by:
getDatabasein interfaceContext- Returns:
- database
-
setMaxscaleVersion
Description copied from interface:ContextSet Maxscale version.- Specified by:
setMaxscaleVersionin interfaceContext- Parameters:
maxscaleVersion- maxscale version
-
setDatabase
Description copied from interface:Contextset current database context- Specified by:
setDatabasein interfaceContext- Parameters:
database- database
-
getMaxscaleVersion
Description copied from interface:ContextRetrieve maxscaleVersion or null if not the case- Specified by:
getMaxscaleVersionin interfaceContext- Returns:
- maxscale version
-
getVersion
Description copied from interface:ContextRetrieve server version information- Specified by:
getVersionin interfaceContext- Returns:
- server version
-
isEofDeprecated
public boolean isEofDeprecated()Description copied from interface:Contextdoes protocol remove EOF in exchanges- Specified by:
isEofDeprecatedin interfaceContext- Returns:
- if EOF packet are deprecated
-
getColumnDecoderFunction
Description copied from interface:ContextColumn decoder function- Specified by:
getColumnDecoderFunctionin interfaceContext- Returns:
- Column decoder function
-
canSkipMeta
public boolean canSkipMeta()Description copied from interface:ContextCan server skip prepared statement metadata- Specified by:
canSkipMetain interfaceContext- Returns:
- true if possible
-
getWarning
public int getWarning()Description copied from interface:Contexthas server warnings- Specified by:
getWarningin interfaceContext- Returns:
- has warnings
-
setWarning
public void setWarning(int warning) Description copied from interface:Contextset server state warning number- Specified by:
setWarningin interfaceContext- Parameters:
warning- warning number
-
getExceptionFactory
Description copied from interface:ContextGet connection exception factory- Specified by:
getExceptionFactoryin interfaceContext- Returns:
- exception factory
-
getConf
Description copied from interface:ContextGet connection configuration -
getTransactionIsolationLevel
Description copied from interface:ContextGet connection transaction isolation level- Specified by:
getTransactionIsolationLevelin interfaceContext- Returns:
- connection transaction isolation level
-
setTransactionIsolationLevel
Description copied from interface:ContextSet current connection transaction isolation level- Specified by:
setTransactionIsolationLevelin interfaceContext- Parameters:
transactionIsolationLevel- new connection transaction isolation level
-
getPrepareCacheCmd
Description copied from interface:ContextReturn cached prepare if key match- Specified by:
getPrepareCacheCmdin interfaceContext- Parameters:
sql- sql commandpreparedStatement- current statement- Returns:
- Prepare if found, null if not
-
putPrepareCacheCmd
public Prepare putPrepareCacheCmd(String sql, Prepare result, BasePreparedStatement preparedStatement) Description copied from interface:ContextPut prepare result in cache- Specified by:
putPrepareCacheCmdin interfaceContext- Parameters:
sql- sql commandresult- prepare resultpreparedStatement- current statement- Returns:
- Prepare if was already cached
-
resetPrepareCache
public void resetPrepareCache()Description copied from interface:ContextReset prepare cache (after a failover)- Specified by:
resetPrepareCachein interfaceContext
-
getStateFlag
public int getStateFlag()Description copied from interface:Contextreturn connection current state change flag- Specified by:
getStateFlagin interfaceContext- Returns:
- connection current state change flag
-
resetStateFlag
public void resetStateFlag()Description copied from interface:Contextreset connection state change flag- Specified by:
resetStateFlagin interfaceContext
-
addStateFlag
public void addStateFlag(int state) Description copied from interface:ContextIndicate connection state (for pooling)- Specified by:
addStateFlagin interfaceContext- Parameters:
state- indicate that some connection state has changed
-
isServerReadOnly
public boolean isServerReadOnly()Description copied from interface:ContextRead-only state currently applied on the server session, i.e. whether the last effectiveSET SESSION TRANSACTION READ ONLY / READ WRITEleft the session read-only. Used with thereadOnlyPropagatesToServeroption to avoid issuing redundant statements and to replay the state on failover.- Specified by:
isServerReadOnlyin interfaceContext- Returns:
- true if the server session is currently in read-only mode
-
setServerReadOnly
public void setServerReadOnly(boolean serverReadOnly) Description copied from interface:ContextRecord the read-only state currently applied on the server session.- Specified by:
setServerReadOnlyin interfaceContext- Parameters:
serverReadOnly- true if the server session is read-only
-
setTreadsConnected
public void setTreadsConnected(long threadsConnected) Description copied from interface:ContextIndicate the number of connection on this server- Specified by:
setTreadsConnectedin interfaceContext- Parameters:
threadsConnected- number of connected threads
-
getAutoIncrement
Description copied from interface:ContextGet server current auto_increment value- Specified by:
getAutoIncrementin interfaceContext- Returns:
- server auto increment
-
setAutoIncrement
public void setAutoIncrement(long autoIncrement) Description copied from interface:ContextSet server autoincrement value- Specified by:
setAutoIncrementin interfaceContext- Parameters:
autoIncrement- current server autoincrement value
-
getCharset
Description copied from interface:ContextRetrieve current charset if session state get it- Specified by:
getCharsetin interfaceContext- Returns:
- current charset
-
setCharset
Description copied from interface:ContextIndicate server charset change. Throws when the new charset isn't compatible with the driver's UTF-8 assumption (only utf8 / utf8mb3 / utf8mb4 are accepted post-init).- Specified by:
setCharsetin interfaceContext- Parameters:
charset- server charset- Throws:
SQLNonTransientConnectionException
-
setCharsetResults
Description copied from interface:ContextIndicate server character_set_results change. Throws when the new charset isn't compatible with the driver's UTF-8 result decoding (only utf8 / utf8mb3 / utf8mb4, or no conversion, are accepted post-init).- Specified by:
setCharsetResultsin interfaceContext- Parameters:
charset- results charset, empty when results are sent without conversion- Throws:
SQLNonTransientConnectionException
-
rejectNonUtf8
-
setInitialized
public void setInitialized()Description copied from interface:ContextIndicate that connection is initialized and ready to handle commands. Used to avoid accepting server- Specified by:
setInitializedin interfaceContext
-
getRedirectUrl
Description copied from interface:Contextget redirect Url if server indicate reconnection url- Specified by:
getRedirectUrlin interfaceContext- Returns:
- null if no redirection required, value if so
-
canUseTransactionIsolation
public boolean canUseTransactionIsolation()Description copied from interface:ContextCan rely on transaction_isolation or keep using deprecated tx_isolation variable- Specified by:
canUseTransactionIsolationin interfaceContext- Returns:
- true if you can use transaction_isolation
-
setRedirectUrl
Description copied from interface:ContextSet server redirection url- Specified by:
setRedirectUrlin interfaceContext- Parameters:
redirectUrl- redirect url
-
getConnectionTimeZone
Description copied from interface:ContextGet current connection timezone- Specified by:
getConnectionTimeZonein interfaceContext- Returns:
- connection timezone
-
setConnectionTimeZone
Description copied from interface:ContextSet current connection timezone- Specified by:
setConnectionTimeZonein interfaceContext- Parameters:
connectionTimeZone- connection timezone
-
getDefaultCalendar
Description copied from interface:ContextGet calendar depending on configuration- Specified by:
getDefaultCalendarin interfaceContext- Returns:
- calendar
-