public class MySQLProtocol extends Object implements Protocol
| 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 |
executeBatch(List<Query> dQueries,
boolean streaming,
boolean isRewritable,
int rewriteOffset) |
QueryResult |
executePreparedQuery(String sql,
ParameterHolder[] parameters,
PrepareResult prepareResult,
MySQLType[] parameterTypeHeader,
boolean isStreaming) |
QueryResult |
executePreparedQueryAfterFailover(String sql,
ParameterHolder[] parameters,
PrepareResult oldPrepareResult,
MySQLType[] parameterTypeHeader,
boolean isStreaming) |
QueryResult |
executeQuery(List<Query> dQueries,
boolean streaming,
boolean isRewritable,
int rewriteOffset) |
QueryResult |
executeQuery(Query dQuery) |
QueryResult |
executeQuery(Query query,
boolean streaming) |
boolean |
getAutocommit() |
Calendar |
getCalendar() |
String |
getDatabase() |
int |
getDatatypeMappingFlags() |
String |
getHost() |
HostAddress |
getHostAddress() |
JDBCUrl |
getJdbcUrl() |
int |
getMajorServerVersion() |
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(Object dQueries,
boolean streaming,
boolean binaryProtocol) |
String |
getServerData(String code) |
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() |
PrepareResult |
prepare(String sql) |
PrepareStatementCache |
prepareStatementCache() |
void |
releasePrepareStatement(String sql,
int statementId) |
void |
rollback() |
void |
setCatalog(String database) |
void |
setHostAddress(HostAddress host) |
void |
setHostFailedWithoutProxy() |
void |
setInternalMaxRows(int max) |
void |
setLocalInfileInputStream(InputStream inputStream) |
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 final JDBCUrl jdbcUrl
public boolean moreResults
public boolean hasWarnings
public StreamingSelectResult activeResult
public int datatypeMappingFlags
public short serverStatus
protected Socket socket
protected PacketOutputStream writer
protected boolean readOnly
protected SyncPacketFetcher packetFetcher
protected HostAddress currentHost
protected FailoverProxy proxy
public MySQLProtocol(JDBCUrl jdbcUrl, ReentrantReadWriteLock lock)
jdbcUrl - connection URL infoslock - the lock for thread synchronisationpublic static MySQLProtocol getNewProtocol(FailoverProxy proxy, JDBCUrl jdbcUrl)
public 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 foundprotected static void close(PacketFetcher fetcher, PacketOutputStream packetOutputStream, Socket socket) throws QueryException
QueryExceptionpublic static String hexdump(byte[] buffer, int offset)
public static String hexdump(ByteBuffer bb, int offset)
public String getServerData(String code)
getServerData in interface Protocolpublic boolean checkIfMaster()
throws QueryException
checkIfMaster in interface ProtocolQueryExceptionpublic 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 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 boolean inTransaction()
inTransaction in interface Protocolpublic Options getOptions()
getOptions in interface Protocolpublic boolean hasMoreResults()
hasMoreResults in interface Protocolpublic 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 boolean getReadonly()
getReadonly in interface Protocolpublic void setReadonly(boolean readOnly)
setReadonly in interface Protocolpublic HostAddress getHostAddress()
getHostAddress in interface Protocolpublic void setHostAddress(HostAddress host)
setHostAddress in interface Protocolpublic FailoverProxy getProxy()
public void setProxy(FailoverProxy proxy)
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(Object dQueries, boolean streaming, boolean binaryProtocol) 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 QueryResult executeBatch(List<Query> dQueries, boolean streaming, boolean isRewritable, int rewriteOffset) throws QueryException
QueryExceptionpublic QueryResult executePreparedQueryAfterFailover(String sql, ParameterHolder[] parameters, PrepareResult oldPrepareResult, MySQLType[] parameterTypeHeader, boolean isStreaming) throws QueryException
executePreparedQueryAfterFailover in interface ProtocolQueryExceptionpublic QueryResult executePreparedQuery(String sql, ParameterHolder[] parameters, PrepareResult prepareResult, MySQLType[] parameterTypeHeader, boolean isStreaming) throws QueryException
executePreparedQuery in interface ProtocolQueryExceptionpublic void releasePrepareStatement(String sql, int statementId) throws QueryException
releasePrepareStatement 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 boolean hasUnreadData()
hasUnreadData in interface Protocolpublic void setInternalMaxRows(int max)
setInternalMaxRows in interface Protocolpublic int getMaxRows()
getMaxRows in interface Protocolpublic void setMaxRows(int max)
throws QueryException
setMaxRows in interface ProtocolQueryExceptionpublic 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 getTimeout()
throws SocketException
getTimeout in interface ProtocolSocketException - if there is an error in the underlying protocol, such as a TCP error.public 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 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 Protocolpublic PrepareStatementCache prepareStatementCache()
prepareStatementCache in interface Protocolpublic Calendar getCalendar()
getCalendar in interface ProtocolCopyright © 2015. All rights reserved.