Class MastersReplicasProtocol
- java.lang.Object
-
- org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol
-
- org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol
-
- org.mariadb.jdbc.internal.protocol.MasterProtocol
-
- org.mariadb.jdbc.internal.protocol.MastersReplicasProtocol
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,Protocol
- Direct Known Subclasses:
AuroraProtocol
public class MastersReplicasProtocol extends MasterProtocol
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
masterConnection
private boolean
mustBeMasterConnection
-
Fields inherited from class org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol
activeStreamingResult, autoIncrementIncrement, CHECK_GALERA_STATE_QUERY, connected, database, eofDeprecated, exceptionFactory, explicitClosed, galeraAllowedStates, hasWarnings, lock, options, proxy, reader, readOnly, serverCapabilities, serverPrepareStatementCache, serverStatus, serverThreadId, socket, socketTimeout, traceCache, urlParser, writer
-
-
Constructor Summary
Constructors Constructor Description MastersReplicasProtocol(UrlParser url, GlobalStateInfo globalInfo, java.util.concurrent.locks.ReentrantLock lock, LruTraceCache traceCache)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static boolean
foundMaster(MastersReplicasListener listener, MastersReplicasProtocol protocol, SearchFilter searchFilter)
protected static boolean
foundSecondary(MastersReplicasListener listener, MastersReplicasProtocol protocol, SearchFilter searchFilter)
private static MastersReplicasProtocol
getNewProtocol(FailoverProxy proxy, GlobalStateInfo globalInfo, UrlParser urlParser)
Get new instance of MastersReplicasProtocol.static void
loop(MastersReplicasListener listener, GlobalStateInfo globalInfo, java.util.List<HostAddress> addresses, SearchFilter searchFilter)
loop until found the failed connection.boolean
mustBeMasterConnection()
private static void
resetHostList(MastersReplicasListener listener, java.util.Deque<HostAddress> loopAddresses)
Reinitialize loopAddresses with all servers in randomize order.void
setMustBeMasterConnection(boolean mustBeMasterConnection)
-
Methods inherited from class org.mariadb.jdbc.internal.protocol.MasterProtocol
loop
-
Methods inherited from class org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol
cancelCurrentQuery, closeExplicit, executeBatchClient, executeBatchServer, executeBatchStmt, executePreparedQuery, executeQuery, 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
-
Methods inherited from class org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol
abort, changeSocketSoTimeout, changeSocketTcpNoDelay, checkIfMaster, close, connect, connectWithoutProxy, destroySocket, getActiveStreamingResult, getDatabase, getHost, getHostAddress, getLock, getMajorServerVersion, getMinorServerVersion, getOptions, getPinGlobalTxToPhysicalConnection, getPort, getProxy, getReader, getReadonly, getServerThreadId, getServerVersion, getSocket, getTimeZone, getTraces, getUrlParser, getUsername, hasMoreResults, hasWarnings, isClosed, isConnected, isEofDeprecated, isExplicitClosed, isMasterConnection, isServerMariaDb, noBackslashEscapes, prepareStatementCache, readEofPacket, readPipelineCheckMaster, removeActiveStreamingResult, removeHasMoreResults, sessionStateAware, setActiveStreamingResult, setHasWarnings, setHostAddress, setHostFailedWithoutProxy, setProxy, setServerStatus, shouldReconnectWithoutProxy, skip, skipEofPacket, versionGreaterOrEqual
-
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
abort, changeSocketSoTimeout, changeSocketTcpNoDelay, checkIfMaster, close, connect, connectWithoutProxy, getActiveStreamingResult, getDatabase, getHost, getHostAddress, getLock, getMajorServerVersion, getMinorServerVersion, getOptions, getPinGlobalTxToPhysicalConnection, getPort, getProxy, getReader, getReadonly, getServerThreadId, getServerVersion, getSocket, getTimeZone, getTraces, getUrlParser, getUsername, hasMoreResults, hasWarnings, isClosed, isConnected, isEofDeprecated, isExplicitClosed, isMasterConnection, isServerMariaDb, noBackslashEscapes, prepareStatementCache, readEofPacket, removeActiveStreamingResult, removeHasMoreResults, sessionStateAware, setActiveStreamingResult, setHasWarnings, setHostAddress, setHostFailedWithoutProxy, setProxy, setServerStatus, shouldReconnectWithoutProxy, skip, skipEofPacket, versionGreaterOrEqual
-
-
-
-
Constructor Detail
-
MastersReplicasProtocol
public MastersReplicasProtocol(UrlParser url, GlobalStateInfo globalInfo, java.util.concurrent.locks.ReentrantLock lock, LruTraceCache traceCache)
-
-
Method Detail
-
loop
public static void loop(MastersReplicasListener listener, GlobalStateInfo globalInfo, java.util.List<HostAddress> addresses, SearchFilter searchFilter) throws java.sql.SQLException
loop until found the failed connection.- Parameters:
listener
- current failoverglobalInfo
- server global variables informationaddresses
- list of HostAddress to loopsearchFilter
- search parameter- Throws:
java.sql.SQLException
- if not found
-
resetHostList
private static void resetHostList(MastersReplicasListener listener, java.util.Deque<HostAddress> loopAddresses)
Reinitialize loopAddresses with all servers in randomize order.- Parameters:
listener
- current listenerloopAddresses
- the list to reinitialize
-
foundMaster
protected static boolean foundMaster(MastersReplicasListener listener, MastersReplicasProtocol protocol, SearchFilter searchFilter)
-
foundSecondary
protected static boolean foundSecondary(MastersReplicasListener listener, MastersReplicasProtocol protocol, SearchFilter searchFilter) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
getNewProtocol
private static MastersReplicasProtocol getNewProtocol(FailoverProxy proxy, GlobalStateInfo globalInfo, UrlParser urlParser)
Get new instance of MastersReplicasProtocol.- Parameters:
proxy
- proxyurlParser
- connection string Object.- Returns:
- a new MastersReplicasProtocol instance
-
mustBeMasterConnection
public boolean mustBeMasterConnection()
- Specified by:
mustBeMasterConnection
in interfaceProtocol
- Overrides:
mustBeMasterConnection
in classAbstractConnectProtocol
-
setMustBeMasterConnection
public void setMustBeMasterConnection(boolean mustBeMasterConnection)
-
-