public abstract class AbstractConnectProtocol extends Object implements Protocol
Modifier and Type | Field and Description |
---|---|
Results |
activeStreamingResult |
protected boolean |
checkCallableResultSet |
protected boolean |
connected |
protected HostAddress |
currentHost |
protected String |
database |
int |
dataTypeMappingFlags |
protected boolean |
explicitClosed |
boolean |
hasWarnings |
protected ReentrantLock |
lock |
protected boolean |
moreResults |
protected Options |
options |
protected ReadPacketFetcher |
packetFetcher |
protected FailoverProxy |
proxy |
protected boolean |
readOnly |
protected ServerPrepareStatementCache |
serverPrepareStatementCache |
short |
serverStatus |
protected long |
serverThreadId |
protected Socket |
socket |
protected UrlParser |
urlParser |
protected PacketOutputStream |
writer |
Constructor and Description |
---|
AbstractConnectProtocol(UrlParser urlParser,
ReentrantLock lock)
Get a protocol instance.
|
Modifier and Type | Method and Description |
---|---|
void |
changeSocketSoTimeout(int setSoTimeout) |
void |
changeSocketTcpNoDelay(boolean setTcpNoDelay) |
boolean |
checkIfMaster() |
void |
close()
Closes socket and stream readers/writers Attempts graceful shutdown.
|
protected static void |
close(ReadPacketFetcher fetcher,
PacketOutputStream packetOutputStream,
Socket socket) |
void |
connect()
Connect to currentHost.
|
void |
connectWithoutProxy()
Connect without proxy.
|
protected void |
enabledSslCipherSuites(SSLSocket sslSocket)
Set ssl socket cipher according to options.
|
protected void |
enabledSslProtocolSuites(SSLSocket sslSocket)
Return possible protocols : values of option enabledSslProtocolSuites is set, or default to "TLSv1,TLSv1.1".
|
abstract void |
executeQuery(String sql) |
Results |
getActiveStreamingResult() |
Calendar |
getCalendar() |
String |
getDatabase() |
int |
getDataTypeMappingFlags() |
String |
getHost() |
HostAddress |
getHostAddress() |
ReentrantLock |
getLock() |
int |
getMajorServerVersion() |
int |
getMinorServerVersion() |
Options |
getOptions() |
ReadPacketFetcher |
getPacketFetcher() |
String |
getPassword() |
boolean |
getPinGlobalTxToPhysicalConnection() |
int |
getPort() |
FailoverProxy |
getProxy() |
boolean |
getReadonly() |
String |
getServerData(String code) |
long |
getServerThreadId() |
String |
getServerVersion() |
UrlParser |
getUrlParser() |
String |
getUsername() |
ByteBuffer |
getWriter() |
boolean |
hasMoreResults() |
boolean |
hasWarnings()
Has warnings.
|
boolean |
isClosed()
Is the connection closed.
|
boolean |
isConnected()
Is connected.
|
boolean |
isExplicitClosed() |
boolean |
isMasterConnection()
Indicate if current protocol is a master protocol.
|
boolean |
mustBeMasterConnection() |
boolean |
noBackslashEscapes() |
ServerPrepareStatementCache |
prepareStatementCache() |
void |
readEofPacket()
Check that next read packet is a End-of-file packet.
|
void |
releaseWriterBuffer() |
void |
removeActiveStreamingResult()
Remove stream result and since totally fetched, set fetch size to 0.
|
void |
setActiveStreamingResult(Results activeStreamingResult) |
void |
setHasWarnings(boolean hasWarnings) |
void |
setHostAddress(HostAddress host) |
void |
setHostFailedWithoutProxy() |
void |
setMoreResults(boolean moreResults) |
void |
setProxy(FailoverProxy proxy) |
void |
setReadonly(boolean readOnly) |
boolean |
shouldReconnectWithoutProxy() |
void |
skip()
Skip packets not read that are not needed.
|
void |
skipEofPacket()
Check that next read packet is a End-of-file packet.
|
boolean |
versionGreaterOrEqual(int major,
int minor,
int patch)
Utility method to check if database version is greater than parameters.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addPrepareInCache, cancelCurrentQuery, closeExplicit, executeBatch, executeBatchMulti, executeBatchMultiple, executeBatchRewrite, executePreparedQuery, executeQuery, executeQuery, forceReleasePrepareStatement, forceReleaseWaitingPrepareStatement, getAutocommit, getMaxRows, getResult, getTimeout, getTransactionIsolationLevel, inTransaction, ping, prepare, prepareAndExecute, prepareAndExecutes, prolog, prologProxy, releasePrepareStatement, rollback, setCatalog, setInternalMaxRows, setLocalInfileInputStream, setMaxRows, setTimeout, setTransactionIsolation
protected boolean checkCallableResultSet
protected final ReentrantLock lock
protected final UrlParser urlParser
protected final Options options
protected Socket socket
protected PacketOutputStream writer
protected boolean readOnly
protected ReadPacketFetcher packetFetcher
protected HostAddress currentHost
protected FailoverProxy proxy
protected volatile boolean connected
protected boolean explicitClosed
protected String database
protected long serverThreadId
protected ServerPrepareStatementCache serverPrepareStatementCache
protected boolean moreResults
public boolean hasWarnings
public Results activeStreamingResult
public int dataTypeMappingFlags
public short serverStatus
public AbstractConnectProtocol(UrlParser urlParser, ReentrantLock lock)
urlParser
- connection URL infoslock
- the lock for thread synchronisationpublic void skip() throws SQLException, QueryException
skip
in interface Protocol
QueryException
- exceptionSQLException
public void setMoreResults(boolean moreResults)
setMoreResults
in interface Protocol
public void close()
protected static void close(ReadPacketFetcher fetcher, PacketOutputStream packetOutputStream, Socket socket) throws QueryException
QueryException
public void connect() throws QueryException
connect
in interface Protocol
QueryException
- exceptionpublic boolean isClosed()
public String getServerData(String code)
getServerData
in interface Protocol
public boolean checkIfMaster() throws QueryException
checkIfMaster
in interface Protocol
QueryException
public void readEofPacket() throws QueryException, IOException
readEofPacket
in interface Protocol
QueryException
- if not a End-of-file packetIOException
- if connection error occurpublic void skipEofPacket() throws QueryException, IOException
skipEofPacket
in interface Protocol
QueryException
- if not a End-of-file packetIOException
- if connection error occurpublic void setHostFailedWithoutProxy()
setHostFailedWithoutProxy
in interface Protocol
public UrlParser getUrlParser()
getUrlParser
in interface Protocol
public boolean isMasterConnection()
isMasterConnection
in interface Protocol
public boolean mustBeMasterConnection()
mustBeMasterConnection
in interface Protocol
public boolean noBackslashEscapes()
noBackslashEscapes
in interface Protocol
public void connectWithoutProxy() throws QueryException
connectWithoutProxy
in interface Protocol
QueryException
- exceptionpublic boolean shouldReconnectWithoutProxy()
shouldReconnectWithoutProxy
in interface Protocol
public String getServerVersion()
getServerVersion
in interface Protocol
public boolean getReadonly()
getReadonly
in interface Protocol
public void setReadonly(boolean readOnly)
setReadonly
in interface Protocol
public HostAddress getHostAddress()
getHostAddress
in interface Protocol
public void setHostAddress(HostAddress host)
setHostAddress
in interface Protocol
public FailoverProxy getProxy()
public void setProxy(FailoverProxy proxy)
public String getDatabase()
getDatabase
in interface Protocol
public String getUsername()
getUsername
in interface Protocol
public String getPassword()
getPassword
in interface Protocol
public int getMajorServerVersion()
getMajorServerVersion
in interface Protocol
public int getMinorServerVersion()
getMinorServerVersion
in interface Protocol
protected void enabledSslProtocolSuites(SSLSocket sslSocket) throws QueryException
sslSocket
- current sslSocketQueryException
- if protocol isn't a supported protocolprotected void enabledSslCipherSuites(SSLSocket sslSocket) throws QueryException
sslSocket
- current ssl socketQueryException
- if a cipher isn't knownpublic boolean versionGreaterOrEqual(int major, int minor, int patch)
versionGreaterOrEqual
in interface Protocol
major
- major versionminor
- minor versionpatch
- patch versionpublic boolean getPinGlobalTxToPhysicalConnection()
getPinGlobalTxToPhysicalConnection
in interface Protocol
public boolean hasWarnings()
hasWarnings
in interface Protocol
public boolean isConnected()
isConnected
in interface Protocol
public long getServerThreadId()
getServerThreadId
in interface Protocol
public int getDataTypeMappingFlags()
getDataTypeMappingFlags
in interface Protocol
public boolean isExplicitClosed()
isExplicitClosed
in interface Protocol
public Calendar getCalendar()
getCalendar
in interface Protocol
public Options getOptions()
getOptions
in interface Protocol
public void setHasWarnings(boolean hasWarnings)
setHasWarnings
in interface Protocol
public Results getActiveStreamingResult()
getActiveStreamingResult
in interface Protocol
public void setActiveStreamingResult(Results activeStreamingResult)
setActiveStreamingResult
in interface Protocol
public void removeActiveStreamingResult()
removeActiveStreamingResult
in interface Protocol
public ReentrantLock getLock()
public boolean hasMoreResults()
hasMoreResults
in interface Protocol
public ServerPrepareStatementCache prepareStatementCache()
prepareStatementCache
in interface Protocol
public abstract void executeQuery(String sql) throws QueryException
executeQuery
in interface Protocol
QueryException
public void releaseWriterBuffer()
releaseWriterBuffer
in interface Protocol
public ByteBuffer getWriter()
public ReadPacketFetcher getPacketFetcher()
getPacketFetcher
in interface Protocol
public void changeSocketTcpNoDelay(boolean setTcpNoDelay) throws SocketException
changeSocketTcpNoDelay
in interface Protocol
SocketException
public void changeSocketSoTimeout(int setSoTimeout) throws SocketException
changeSocketSoTimeout
in interface Protocol
SocketException
Copyright © 2016. All rights reserved.