Class AbstractConnectProtocol
java.lang.Object
org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol
- All Implemented Interfaces:
Protocol
- Direct Known Subclasses:
AbstractQueryProtocol
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected static final Stringprotected booleanprotected Stringprotected booleanprotected ExceptionFactoryprotected booleanbooleanprotected final ReentrantLockprotected final Optionsprotected FailoverProxyprotected PacketInputStreamprotected booleanprotected longprotected ServerPrepareStatementCacheshortprotected longprotected Socketprotected intprotected final LruTraceCacheprotected final UrlParserprotected PacketOutputStream -
Constructor Summary
ConstructorsConstructorDescriptionAbstractConnectProtocol(UrlParser urlParser, GlobalStateInfo globalInfo, ReentrantLock lock, LruTraceCache traceCache) Get a protocol instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidabort()Force closes socket and stream readers/writers.voidchangeSocketSoTimeout(int setSoTimeout) voidchangeSocketTcpNoDelay(boolean setTcpNoDelay) Change Socket TcpNoDelay option.booleanCheck that current connection is a master connection (not read-only).voidclose()Closes socket and stream readers/writers Attempts graceful shutdown.voidconnect()Connect to currentHost.voidConnect without proxy.voidClosing socket in case of Connection error after socket creation.abstract voidexecuteQuery(String sql) getHost()getLock()intintintbooleanintgetPort()getProxy()booleanlongGet a String containing readable information about last 10 send/received packets.booleanbooleanHas warnings.booleanisClosed()Is the connection closed.booleanIs connected.booleanbooleanbooleanIndicate if current protocol is a master protocol.booleanbooleanbooleanvoidCheck that next read packet is a End-of-file packet.voidvoidRemove exception result and since totally fetched, set fetch size to 0.voidRemove flag has more results.booleanvoidsetActiveStreamingResult(Results activeStreamingResult) voidsetHasWarnings(boolean hasWarnings) voidsetHostAddress(HostAddress host) voidvoidsetProxy(FailoverProxy proxy) voidsetServerStatus(short serverStatus) booleanIndicate for Old reconnection if can reconnect without throwing exception.voidskip()Skip packets not read that are not needed.voidCheck that next read packet is a End-of-file packet.booleanversionGreaterOrEqual(int major, int minor, int patch) Utility method to check if database version is greater than parameters.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Protocol
cancelCurrentQuery, closeExplicit, executeBatchClient, executeBatchServer, executeBatchStmt, executePreparedQuery, executeQuery, executeQuery, executeQuery, executeQuery, forceReleasePrepareStatement, forceReleaseWaitingPrepareStatement, getAutocommit, getAutoIncrementIncrement, getCatalog, getMaxRows, getResult, getTimeout, getTransactionIsolationLevel, handleIoException, interrupt, inTransaction, isInterrupted, isValid, ping, prepare, prolog, prologProxy, putInCache, releasePrepareStatement, reset, resetDatabase, resetStateAfterFailover, rollback, setActiveFutureTask, setCatalog, setLocalInfileInputStream, setMaxRows, setReadonly, setTimeout, setTransactionIsolation, stopIfInterrupted
-
Field Details
-
CHECK_GALERA_STATE_QUERY
- See Also:
-
lock
-
urlParser
-
options
-
traceCache
-
hasWarnings
public boolean hasWarnings -
activeStreamingResult
-
serverStatus
public short serverStatus -
autoIncrementIncrement
protected int autoIncrementIncrement -
socket
-
writer
-
readOnly
protected boolean readOnly -
reader
-
proxy
-
connected
protected volatile boolean connected -
explicitClosed
protected boolean explicitClosed -
database
-
serverThreadId
protected long serverThreadId -
serverPrepareStatementCache
-
eofDeprecated
protected boolean eofDeprecated -
serverCapabilities
protected long serverCapabilities -
socketTimeout
protected int socketTimeout -
exceptionFactory
-
galeraAllowedStates
-
-
Constructor Details
-
AbstractConnectProtocol
public AbstractConnectProtocol(UrlParser urlParser, GlobalStateInfo globalInfo, ReentrantLock lock, LruTraceCache traceCache) Get a protocol instance.- Parameters:
urlParser- connection URL informationglobalInfo- server global variables informationlock- the lock for thread synchronisationtraceCache- trace cache
-
-
Method Details
-
close
-
abort
-
skip
Skip packets not read that are not needed. Packets are read according to needs. If some data have not been read before next execution, skip it. Lock must be set before using this method- Specified by:
skipin interfaceProtocol- Throws:
SQLException- exception
-
setServerStatus
public void setServerStatus(short serverStatus) - Specified by:
setServerStatusin interfaceProtocol
-
removeHasMoreResults
public void removeHasMoreResults()Remove flag has more results.- Specified by:
removeHasMoreResultsin interfaceProtocol
-
connect
Connect to currentHost.- Specified by:
connectin interfaceProtocol- Throws:
SQLException- exception
-
destroySocket
public void destroySocket()Closing socket in case of Connection error after socket creation. -
isClosed
-
checkIfMaster
Check that current connection is a master connection (not read-only).- Specified by:
checkIfMasterin interfaceProtocol- Returns:
- true if master
- Throws:
SQLException- if requesting infos for server fail.
-
readEofPacket
Check that next read packet is a End-of-file packet.- Specified by:
readEofPacketin interfaceProtocol- Throws:
SQLException- if not a End-of-file packetIOException- if connection error occur
-
skipEofPacket
Check that next read packet is a End-of-file packet.- Specified by:
skipEofPacketin interfaceProtocol- Throws:
SQLException- if not a End-of-file packetIOException- if connection error occur
-
setHostFailedWithoutProxy
public void setHostFailedWithoutProxy()- Specified by:
setHostFailedWithoutProxyin interfaceProtocol
-
getUrlParser
- Specified by:
getUrlParserin interfaceProtocol
-
isMasterConnection
public boolean isMasterConnection()Indicate if current protocol is a master protocol.- Specified by:
isMasterConnectionin interfaceProtocol- Returns:
- is master flag
-
readPipelineCheckMaster
- Throws:
SQLException
-
mustBeMasterConnection
public boolean mustBeMasterConnection()- Specified by:
mustBeMasterConnectionin interfaceProtocol
-
noBackslashEscapes
public boolean noBackslashEscapes()- Specified by:
noBackslashEscapesin interfaceProtocol
-
connectWithoutProxy
Connect without proxy. (use basic failover implementation)- Specified by:
connectWithoutProxyin interfaceProtocol- Throws:
SQLException- exception
-
shouldReconnectWithoutProxy
public boolean shouldReconnectWithoutProxy()Indicate for Old reconnection if can reconnect without throwing exception.- Specified by:
shouldReconnectWithoutProxyin interfaceProtocol- Returns:
- true if can reconnect without issue
-
getServerVersion
- Specified by:
getServerVersionin interfaceProtocol
-
getReadonly
public boolean getReadonly()- Specified by:
getReadonlyin interfaceProtocol
-
getHostAddress
- Specified by:
getHostAddressin interfaceProtocol
-
getSocketIp
-
setHostAddress
- Specified by:
setHostAddressin interfaceProtocol
-
getHost
-
getProxy
-
setProxy
-
getPort
-
getDatabase
- Specified by:
getDatabasein interfaceProtocol
-
getUsername
- Specified by:
getUsernamein interfaceProtocol
-
getMajorServerVersion
public int getMajorServerVersion()- Specified by:
getMajorServerVersionin interfaceProtocol
-
getMinorServerVersion
public int getMinorServerVersion()- Specified by:
getMinorServerVersionin interfaceProtocol
-
getPatchServerVersion
public int getPatchServerVersion()- Specified by:
getPatchServerVersionin interfaceProtocol
-
versionGreaterOrEqual
public boolean versionGreaterOrEqual(int major, int minor, int patch) Utility method to check if database version is greater than parameters.- Specified by:
versionGreaterOrEqualin interfaceProtocol- Parameters:
major- major versionminor- minor versionpatch- patch version- Returns:
- true if version is greater than parameters
-
getPinGlobalTxToPhysicalConnection
public boolean getPinGlobalTxToPhysicalConnection()- Specified by:
getPinGlobalTxToPhysicalConnectionin interfaceProtocol
-
hasWarnings
public boolean hasWarnings()Has warnings.- Specified by:
hasWarningsin interfaceProtocol- Returns:
- true if as warnings.
-
isConnected
public boolean isConnected()Is connected.- Specified by:
isConnectedin interfaceProtocol- Returns:
- true if connected
-
getServerThreadId
public long getServerThreadId()- Specified by:
getServerThreadIdin interfaceProtocol
-
getSocket
-
isExplicitClosed
public boolean isExplicitClosed()- Specified by:
isExplicitClosedin interfaceProtocol
-
getTimeZone
- Specified by:
getTimeZonein interfaceProtocol
-
getOptions
- Specified by:
getOptionsin interfaceProtocol
-
setHasWarnings
public void setHasWarnings(boolean hasWarnings) - Specified by:
setHasWarningsin interfaceProtocol
-
getActiveStreamingResult
- Specified by:
getActiveStreamingResultin interfaceProtocol
-
setActiveStreamingResult
- Specified by:
setActiveStreamingResultin interfaceProtocol
-
removeActiveStreamingResult
public void removeActiveStreamingResult()Remove exception result and since totally fetched, set fetch size to 0.- Specified by:
removeActiveStreamingResultin interfaceProtocol
-
getLock
-
hasMoreResults
public boolean hasMoreResults()- Specified by:
hasMoreResultsin interfaceProtocol
-
prepareStatementCache
- Specified by:
prepareStatementCachein interfaceProtocol
-
executeQuery
- Specified by:
executeQueryin interfaceProtocol- Throws:
SQLException
-
changeSocketTcpNoDelay
public void changeSocketTcpNoDelay(boolean setTcpNoDelay) Change Socket TcpNoDelay option.- Specified by:
changeSocketTcpNoDelayin interfaceProtocol- Parameters:
setTcpNoDelay- value to set.
-
changeSocketSoTimeout
- Specified by:
changeSocketSoTimeoutin interfaceProtocol- Throws:
SocketException
-
isServerMariaDb
public boolean isServerMariaDb()- Specified by:
isServerMariaDbin interfaceProtocol
-
getReader
-
isEofDeprecated
public boolean isEofDeprecated()- Specified by:
isEofDeprecatedin interfaceProtocol
-
sessionStateAware
public boolean sessionStateAware()- Specified by:
sessionStateAwarein interfaceProtocol
-
getTraces
-