Class AbstractConnectProtocol
- java.lang.Object
-
- org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol
-
- All Implemented Interfaces:
Protocol
- Direct Known Subclasses:
AbstractQueryProtocol
public abstract class AbstractConnectProtocol extends Object implements Protocol
-
-
Field Summary
Fields Modifier and Type Field Description ResultsactiveStreamingResultprotected intautoIncrementIncrementprotected static StringCHECK_GALERA_STATE_QUERYprotected booleanconnectedprotected Stringdatabaseprotected booleaneofDeprecatedprotected ExceptionFactoryexceptionFactoryprotected booleanexplicitClosedprotected List<String>galeraAllowedStatesbooleanhasWarningsprotected ReentrantLocklockprotected Optionsoptionsprotected FailoverProxyproxyprotected PacketInputStreamreaderprotected booleanreadOnlyprotected longserverCapabilitiesprotected ServerPrepareStatementCacheserverPrepareStatementCacheshortserverStatusprotected longserverThreadIdprotected Socketsocketprotected intsocketTimeoutprotected LruTraceCachetraceCacheprotected UrlParserurlParserprotected PacketOutputStreamwriter
-
Constructor Summary
Constructors Constructor Description AbstractConnectProtocol(UrlParser urlParser, GlobalStateInfo globalInfo, ReentrantLock lock, LruTraceCache traceCache)Get a protocol instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidabort()Force closes socket and stream readers/writers.voidchangeSocketSoTimeout(int setSoTimeout)voidchangeSocketTcpNoDelay(boolean setTcpNoDelay)Change Socket TcpNoDelay option.booleancheckIfMaster()Check that current connection is a master connection (not read-only).voidclose()Closes socket and stream readers/writers Attempts graceful shutdown.voidconnect()Connect to currentHost.voidconnectWithoutProxy()Connect without proxy.voiddestroySocket()Closing socket in case of Connection error after socket creation.abstract voidexecuteQuery(String sql)ResultsgetActiveStreamingResult()StringgetDatabase()StringgetHost()HostAddressgetHostAddress()ReentrantLockgetLock()intgetMajorServerVersion()intgetMinorServerVersion()OptionsgetOptions()intgetPatchServerVersion()booleangetPinGlobalTxToPhysicalConnection()intgetPort()FailoverProxygetProxy()PacketInputStreamgetReader()booleangetReadonly()longgetServerThreadId()StringgetServerVersion()SocketgetSocket()TimeZonegetTimeZone()StringgetTraces()Get a String containing readable information about last 10 send/received packets.UrlParsergetUrlParser()StringgetUsername()booleanhasMoreResults()booleanhasWarnings()Has warnings.booleanisClosed()Is the connection closed.booleanisConnected()Is connected.booleanisEofDeprecated()booleanisExplicitClosed()booleanisMasterConnection()Indicate if current protocol is a master protocol.booleanisServerMariaDb()booleanmustBeMasterConnection()booleannoBackslashEscapes()ServerPrepareStatementCacheprepareStatementCache()voidreadEofPacket()Check that next read packet is a End-of-file packet.voidreadPipelineCheckMaster()voidremoveActiveStreamingResult()Remove exception result and since totally fetched, set fetch size to 0.voidremoveHasMoreResults()Remove flag has more results.booleansessionStateAware()voidsetActiveStreamingResult(Results activeStreamingResult)voidsetHasWarnings(boolean hasWarnings)voidsetHostAddress(HostAddress host)voidsetHostFailedWithoutProxy()voidsetProxy(FailoverProxy proxy)voidsetServerStatus(short serverStatus)booleanshouldReconnectWithoutProxy()Indicate for Old reconnection if can reconnect without throwing exception.voidskip()Skip packets not read that are not needed.voidskipEofPacket()Check 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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.mariadb.jdbc.internal.protocol.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 Detail
-
CHECK_GALERA_STATE_QUERY
protected static final String CHECK_GALERA_STATE_QUERY
- See Also:
- Constant Field Values
-
lock
protected final ReentrantLock lock
-
urlParser
protected final UrlParser urlParser
-
options
protected final Options options
-
traceCache
protected final LruTraceCache traceCache
-
hasWarnings
public boolean hasWarnings
-
activeStreamingResult
public Results activeStreamingResult
-
serverStatus
public short serverStatus
-
autoIncrementIncrement
protected int autoIncrementIncrement
-
socket
protected Socket socket
-
writer
protected PacketOutputStream writer
-
readOnly
protected boolean readOnly
-
reader
protected PacketInputStream reader
-
proxy
protected FailoverProxy proxy
-
connected
protected volatile boolean connected
-
explicitClosed
protected boolean explicitClosed
-
database
protected String database
-
serverThreadId
protected long serverThreadId
-
serverPrepareStatementCache
protected ServerPrepareStatementCache serverPrepareStatementCache
-
eofDeprecated
protected boolean eofDeprecated
-
serverCapabilities
protected long serverCapabilities
-
socketTimeout
protected int socketTimeout
-
exceptionFactory
protected ExceptionFactory exceptionFactory
-
-
Constructor Detail
-
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 Detail
-
close
public void close()
Closes socket and stream readers/writers Attempts graceful shutdown.
-
abort
public void abort()
Force closes socket and stream readers/writers.
-
skip
public void skip() throws SQLExceptionSkip 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
public void connect() throws SQLExceptionConnect to currentHost.- Specified by:
connectin interfaceProtocol- Throws:
SQLException- exception
-
destroySocket
public void destroySocket()
Closing socket in case of Connection error after socket creation.
-
isClosed
public boolean isClosed()
Is the connection closed.
-
checkIfMaster
public boolean checkIfMaster() throws SQLExceptionCheck 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
public void readEofPacket() throws SQLException, IOExceptionCheck 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
public void skipEofPacket() throws SQLException, IOExceptionCheck 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
public UrlParser 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
public void readPipelineCheckMaster() throws SQLException- Throws:
SQLException
-
mustBeMasterConnection
public boolean mustBeMasterConnection()
- Specified by:
mustBeMasterConnectionin interfaceProtocol
-
noBackslashEscapes
public boolean noBackslashEscapes()
- Specified by:
noBackslashEscapesin interfaceProtocol
-
connectWithoutProxy
public void connectWithoutProxy() throws SQLExceptionConnect 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
public String getServerVersion()
- Specified by:
getServerVersionin interfaceProtocol
-
getReadonly
public boolean getReadonly()
- Specified by:
getReadonlyin interfaceProtocol
-
getHostAddress
public HostAddress getHostAddress()
- Specified by:
getHostAddressin interfaceProtocol
-
setHostAddress
public void setHostAddress(HostAddress host)
- Specified by:
setHostAddressin interfaceProtocol
-
getProxy
public FailoverProxy getProxy()
-
setProxy
public void setProxy(FailoverProxy proxy)
-
getDatabase
public String getDatabase()
- Specified by:
getDatabasein interfaceProtocol
-
getUsername
public String 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
-
isExplicitClosed
public boolean isExplicitClosed()
- Specified by:
isExplicitClosedin interfaceProtocol
-
getTimeZone
public TimeZone getTimeZone()
- Specified by:
getTimeZonein interfaceProtocol
-
getOptions
public Options getOptions()
- Specified by:
getOptionsin interfaceProtocol
-
setHasWarnings
public void setHasWarnings(boolean hasWarnings)
- Specified by:
setHasWarningsin interfaceProtocol
-
getActiveStreamingResult
public Results getActiveStreamingResult()
- Specified by:
getActiveStreamingResultin interfaceProtocol
-
setActiveStreamingResult
public void setActiveStreamingResult(Results activeStreamingResult)
- 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
public ReentrantLock getLock()
-
hasMoreResults
public boolean hasMoreResults()
- Specified by:
hasMoreResultsin interfaceProtocol
-
prepareStatementCache
public ServerPrepareStatementCache prepareStatementCache()
- Specified by:
prepareStatementCachein interfaceProtocol
-
executeQuery
public abstract void executeQuery(String sql) throws SQLException
- 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
public void changeSocketSoTimeout(int setSoTimeout) throws SocketException- Specified by:
changeSocketSoTimeoutin interfaceProtocol- Throws:
SocketException
-
isServerMariaDb
public boolean isServerMariaDb()
- Specified by:
isServerMariaDbin interfaceProtocol
-
getReader
public PacketInputStream getReader()
-
isEofDeprecated
public boolean isEofDeprecated()
- Specified by:
isEofDeprecatedin interfaceProtocol
-
sessionStateAware
public boolean sessionStateAware()
- Specified by:
sessionStateAwarein interfaceProtocol
-
-