public class MySQLProtocol extends Object implements Protocol
| Modifier and Type | Class and Description |
|---|---|
class |
MySQLProtocol.PrepareResult |
| Modifier and Type | Field and Description |
|---|---|
StreamingSelectResult |
activeResult |
protected HostAddress |
currentHost |
int |
datatypeMappingFlags |
boolean |
hasWarnings |
protected JDBCUrl |
jdbcUrl |
protected ReentrantReadWriteLock |
lock |
boolean |
moreResults |
protected SyncPacketFetcher |
packetFetcher |
protected FailoverProxy |
proxy |
protected boolean |
readOnly |
short |
serverStatus |
protected Socket |
socket |
protected PacketOutputStream |
writer |
| Constructor and Description |
|---|
MySQLProtocol(JDBCUrl jdbcUrl,
ReentrantReadWriteLock lock)
Get a protocol instance
|
| Modifier and Type | Method and Description |
|---|---|
void |
cancelCurrentQuery()
cancels the current query - clones the current protocol and executes a query using the new connection
|
boolean |
checkIfMaster() |
void |
close()
Closes socket and stream readers/writers
Attempts graceful shutdown.
|
protected static void |
close(PacketFetcher fetcher,
PacketOutputStream packetOutputStream,
Socket socket) |
void |
closeExplicit() |
void |
closeIfActiveResult() |
void |
closePreparedStatement(int statementId) |
void |
connect() |
void |
connectWithoutProxy() |
QueryResult |
executeQuery(List<Query> dQueries,
boolean streaming,
boolean isRewritable,
int rewriteOffset) |
QueryResult |
executeQuery(Query dQuery) |
QueryResult |
executeQuery(Query query,
boolean streaming) |
boolean |
getAutocommit() |
String |
getDatabase() |
int |
getDatatypeMappingFlags() |
String |
getHost() |
HostAddress |
getHostAddress() |
JDBCUrl |
getJdbcUrl() |
int |
getMajorServerVersion() |
int |
getMaxAllowedPacket() |
int |
getMaxRows() |
int |
getMinorServerVersion() |
QueryResult |
getMoreResults(boolean streaming) |
static MySQLProtocol |
getNewProtocol(FailoverProxy proxy,
JDBCUrl jdbcUrl) |
Options |
getOptions() |
String |
getPassword() |
boolean |
getPinGlobalTxToPhysicalConnection() |
int |
getPort() |
FailoverProxy |
getProxy() |
boolean |
getReadonly() |
QueryResult |
getResult(List<Query> dQueries,
boolean streaming) |
long |
getServerThreadId() |
String |
getServerVersion() |
int |
getTimeout()
Returns the connection timeout in milliseconds.
|
int |
getTransactionIsolationLevel() |
String |
getUsername() |
boolean |
hasMoreResults() |
boolean |
hasUnreadData() |
boolean |
hasWarnings() |
static String |
hexdump(byte[] buffer,
int offset) |
static String |
hexdump(ByteBuffer bb,
int offset) |
boolean |
inTransaction() |
boolean |
isClosed() |
boolean |
isConnected() |
boolean |
isExplicitClosed() |
boolean |
isMasterConnection() |
static void |
loop(Listener listener,
List<HostAddress> addresses,
Map<HostAddress,Long> blacklist,
SearchFilter searchFilter)
loop until found the failed connection.
|
boolean |
mustBeMasterConnection() |
boolean |
noBackslashEscapes() |
boolean |
ping() |
MySQLProtocol.PrepareResult |
prepare(String sql) |
void |
rollback() |
void |
setCatalog(String database) |
void |
setHostAddress(HostAddress host) |
void |
setHostFailedWithoutProxy() |
void |
setInternalMaxRows(int max) |
void |
setLocalInfileInputStream(InputStream inputStream) |
void |
setMaxAllowedPacket(int maxAllowedPacket) |
void |
setMaxRows(int max) |
void |
setProxy(FailoverProxy proxy) |
void |
setReadonly(boolean readOnly) |
void |
setTimeout(int timeout)
Sets the connection timeout.
|
void |
setTransactionIsolation(int level) |
boolean |
shouldReconnectWithoutProxy() |
boolean |
versionGreaterOrEqual(int major,
int minor,
int patch) |
protected final ReentrantReadWriteLock lock
protected Socket socket
protected PacketOutputStream writer
protected boolean readOnly
protected SyncPacketFetcher packetFetcher
public boolean moreResults
public boolean hasWarnings
public StreamingSelectResult activeResult
public int datatypeMappingFlags
public short serverStatus
protected final JDBCUrl jdbcUrl
protected HostAddress currentHost
protected FailoverProxy proxy
public MySQLProtocol(JDBCUrl jdbcUrl, ReentrantReadWriteLock lock)
jdbcUrl - connection URL infoslock - the lock for thread synchronisationpublic boolean checkIfMaster()
throws QueryException
checkIfMaster in interface ProtocolQueryExceptionpublic MySQLProtocol.PrepareResult prepare(String sql) throws QueryException
prepare in interface ProtocolQueryExceptionpublic void closePreparedStatement(int statementId)
throws QueryException
closePreparedStatement in interface ProtocolQueryExceptionpublic void setHostFailedWithoutProxy()
setHostFailedWithoutProxy in interface Protocolpublic JDBCUrl getJdbcUrl()
getJdbcUrl in interface Protocolpublic static MySQLProtocol getNewProtocol(FailoverProxy proxy, JDBCUrl jdbcUrl)
public boolean getAutocommit()
getAutocommit in interface Protocolpublic boolean isMasterConnection()
isMasterConnection in interface Protocolpublic boolean mustBeMasterConnection()
mustBeMasterConnection in interface Protocolpublic boolean noBackslashEscapes()
noBackslashEscapes in interface Protocolpublic void connect()
throws QueryException
connect in interface ProtocolQueryExceptionpublic void connectWithoutProxy()
throws QueryException
connectWithoutProxy in interface ProtocolQueryExceptionpublic boolean shouldReconnectWithoutProxy()
shouldReconnectWithoutProxy in interface Protocolpublic static void loop(Listener listener, List<HostAddress> addresses, Map<HostAddress,Long> blacklist, SearchFilter searchFilter) throws QueryException
listener - current listeneraddresses - list of HostAddress to loopblacklist - current blacklistsearchFilter - search parameterQueryException - if not foundpublic boolean inTransaction()
inTransaction in interface Protocolpublic Options getOptions()
getOptions in interface Protocolpublic boolean hasMoreResults()
hasMoreResults in interface Protocolprotected static void close(PacketFetcher fetcher, PacketOutputStream packetOutputStream, Socket socket) throws QueryException
QueryExceptionpublic void closeExplicit()
closeExplicit in interface Protocolpublic void close()
public boolean isClosed()
public void setCatalog(String database) throws QueryException
setCatalog in interface ProtocolQueryExceptionpublic String getServerVersion()
getServerVersion in interface Protocolpublic void setReadonly(boolean readOnly)
setReadonly in interface Protocolpublic boolean getReadonly()
getReadonly in interface Protocolpublic HostAddress getHostAddress()
getHostAddress in interface Protocolpublic void setHostAddress(HostAddress host)
setHostAddress in interface Protocolpublic void setProxy(FailoverProxy proxy)
public FailoverProxy getProxy()
public String getDatabase()
getDatabase in interface Protocolpublic String getUsername()
getUsername in interface Protocolpublic String getPassword()
getPassword in interface Protocolpublic boolean ping()
throws QueryException
ping in interface ProtocolQueryExceptionpublic QueryResult executeQuery(Query dQuery) throws QueryException
executeQuery in interface ProtocolQueryExceptionpublic QueryResult getResult(List<Query> dQueries, boolean streaming) throws QueryException
getResult in interface ProtocolQueryExceptionpublic QueryResult executeQuery(Query query, boolean streaming) throws QueryException
executeQuery in interface ProtocolQueryExceptionpublic QueryResult executeQuery(List<Query> dQueries, boolean streaming, boolean isRewritable, int rewriteOffset) throws QueryException
executeQuery in interface ProtocolQueryExceptionpublic void cancelCurrentQuery()
throws QueryException,
IOException
cancelCurrentQuery in interface ProtocolQueryException - never thrownIOException - if Host is not respondingpublic QueryResult getMoreResults(boolean streaming) throws QueryException
getMoreResults in interface ProtocolQueryExceptionpublic static String hexdump(byte[] buffer, int offset)
public static String hexdump(ByteBuffer bb, int offset)
public boolean hasUnreadData()
hasUnreadData in interface Protocolpublic void setMaxRows(int max)
throws QueryException
setMaxRows in interface ProtocolQueryExceptionpublic void setInternalMaxRows(int max)
setInternalMaxRows in interface Protocolpublic int getMaxRows()
getMaxRows in interface Protocolpublic int getMajorServerVersion()
getMajorServerVersion in interface Protocolpublic int getMinorServerVersion()
getMinorServerVersion in interface Protocolpublic boolean versionGreaterOrEqual(int major,
int minor,
int patch)
versionGreaterOrEqual in interface Protocolpublic void setLocalInfileInputStream(InputStream inputStream)
setLocalInfileInputStream in interface Protocolpublic int getMaxAllowedPacket()
getMaxAllowedPacket in interface Protocolpublic void setMaxAllowedPacket(int maxAllowedPacket)
setMaxAllowedPacket in interface Protocolpublic void setTimeout(int timeout)
throws SocketException
setTimeout in interface Protocoltimeout - the timeout, in millisecondsSocketException - if there is an error in the underlying protocol, such as a TCP error.public int getTimeout()
throws SocketException
getTimeout in interface ProtocolSocketException - if there is an error in the underlying protocol, such as a TCP error.public boolean getPinGlobalTxToPhysicalConnection()
getPinGlobalTxToPhysicalConnection in interface Protocolpublic void setTransactionIsolation(int level)
throws QueryException
setTransactionIsolation in interface ProtocolQueryExceptionpublic int getTransactionIsolationLevel()
getTransactionIsolationLevel in interface Protocolpublic boolean hasWarnings()
hasWarnings in interface Protocolpublic boolean isConnected()
isConnected in interface Protocolpublic long getServerThreadId()
getServerThreadId in interface Protocolpublic int getDatatypeMappingFlags()
getDatatypeMappingFlags in interface Protocolpublic void closeIfActiveResult()
closeIfActiveResult in interface Protocolpublic boolean isExplicitClosed()
isExplicitClosed in interface ProtocolCopyright © 2015. All rights reserved.