public class MastersSlavesListener extends AbstractMastersSlavesListener
| 限定符和类型 | 字段和说明 |
|---|---|
protected List<HostAddress> |
hostAddresses |
protected static Logger |
lockLogger |
protected Protocol |
masterProtocol |
protected Protocol |
secondaryProtocol |
waitNewMasterProtocol, waitNewSecondaryProtocolcurrentConnectionAttempts, currentProtocol, currentReadOnlyAsked, explicitClosed, globalInfo, lastQueryNanos, lastRetry, proxy, urlParser| 构造器和说明 |
|---|
MastersSlavesListener(UrlParser urlParser,
GlobalStateInfo globalInfo)
Initialisation.
|
| 限定符和类型 | 方法和说明 |
|---|---|
protected void |
checkInitialConnection(SQLException queryException) |
boolean |
checkMasterStatus(SearchFilter searchFilter)
Check master status.
|
void |
checkWaitingConnection()
Verify that there is waiting connection that have to replace failing one.
|
List<HostAddress> |
connectedHosts()
List current connected HostAddress.
|
void |
foundActiveMaster(Protocol newMasterProtocol)
Method called when a new Master connection is found after a fallback.
|
void |
foundActiveSecondary(Protocol newSecondaryProtocol)
Method called when a new secondary connection is found after a fallback.
|
String |
getCatalog() |
int |
getMajorServerVersion() |
long |
getServerThreadId()
Get current connection server id.
|
int |
getTimeout()
Get timeout (master connection possibly down).
|
void |
handleFailLoop() |
void |
initializeConnection()
Initialize connections.
|
boolean |
inTransaction()
Indicate if connection has an active transaction.
|
Object |
invoke(Method method,
Object[] args) |
boolean |
isClosed() |
boolean |
isMasterConnected() |
boolean |
isMasterConnection() |
boolean |
isServerMariaDb() |
boolean |
isValid(int timeout) |
void |
lockAndSwitchMaster(Protocol newMasterProtocol)
Use the parameter newMasterProtocol as new current master connection.
|
void |
lockAndSwitchSecondary(Protocol newSecondaryProtocol)
Use the parameter newSecondaryProtocol as new current secondary connection.
|
boolean |
noBackslashEscapes() |
void |
preAbort() |
void |
preClose()
Called after a call on Connection.close().
|
void |
preExecute() |
HandleErrorResult |
primaryFail(Method method,
Object[] args,
boolean killCmd,
boolean isClosed)
To handle the newly detected failover on the master connection.
|
void |
prolog(long maxRows,
OceanBaseConnection connection,
OceanBaseStatement statement) |
void |
reconnect()
Reconnect failed connection.
|
void |
reconnectFailedConnection(SearchFilter searchFilter)
Loop to connect.
|
protected void |
removeListenerFromSchedulers() |
void |
rePrepareOnSlave(ServerPrepareResult oldServerPrepareResult,
boolean mustBeOnMaster) |
void |
reset()
Reset state of master and slave connection.
|
HandleErrorResult |
secondaryFail(Method method,
Object[] args,
boolean killCmd)
To handle the newly detected failover on the secondary connection.
|
boolean |
sessionStateAware() |
void |
switchReadOnlyConnection(Boolean mustBeReadOnly)
Switch to a read-only(secondary) or read and write connection(master).
|
boolean |
versionGreaterOrEqual(int major,
int minor,
int patch) |
getFilterForFailedHost, getSecondaryHostFailNanos, handleFailover, hasHostFail, isMasterHostFailReconnect, isSecondaryHostFail, isSecondaryHostFailReconnect, resetMasterFailoverData, resetSecondaryFailoverData, setSecondaryHostFailabortConnection, addToBlacklist, addToPickedList, canRetryFailLoop, clearBlacklist, closeConnection, getBlacklist, getBlacklistKeys, getCurrentLoadBalanceInfo, getCurrentProtocol, getLastQueryNanos, getMasterHostFailNanos, getPickedlist, getProxy, getRetriesAllDown, getRetryAllDowns, getUrlParser, invoke, isAutoReconnect, isExplicitClosed, isMasterHostFail, isQueryRelaunchable, isReadOnly, pingMasterProtocol, preAutoReconnect, relaunchOperation, removeFromBlacklist, removeFromPickedList, resetHostStateInfo, resetOldsBlackListHosts, setCurrentLoadBalanceInfo, setMasterHostFail, setProxy, setRetryAllDowns, setSessionReadOnly, syncConnection, throwFailoverMessageprotected Protocol masterProtocol
protected Protocol secondaryProtocol
protected List<HostAddress> hostAddresses
protected static final Logger lockLogger
public MastersSlavesListener(UrlParser urlParser, GlobalStateInfo globalInfo)
urlParser - connection string object.globalInfo - server global variables informationprotected void removeListenerFromSchedulers()
public void initializeConnection()
throws SQLException
initializeConnection 在接口中 ListenerinitializeConnection 在类中 AbstractMastersListenerSQLException - if a connection error append.public boolean isClosed()
isClosed 在接口中 ListenerisClosed 在类中 AbstractMastersListenerpublic Object invoke(Method method, Object[] args) throws Throwable
invoke 在接口中 Listenerinvoke 在类中 AbstractMastersListenerThrowablepublic boolean versionGreaterOrEqual(int major,
int minor,
int patch)
versionGreaterOrEqual 在接口中 ListenerversionGreaterOrEqual 在类中 AbstractMastersListenerpublic boolean isServerMariaDb()
isServerMariaDb 在接口中 ListenerisServerMariaDb 在类中 AbstractMastersListenerpublic boolean sessionStateAware()
sessionStateAware 在接口中 ListenersessionStateAware 在类中 AbstractMastersListenerpublic String getCatalog() throws SQLException
getCatalog 在接口中 ListenergetCatalog 在类中 AbstractMastersListenerSQLExceptionpublic int getMajorServerVersion()
getMajorServerVersion 在接口中 ListenergetMajorServerVersion 在类中 AbstractMastersListenerpublic boolean isMasterConnection()
isMasterConnection 在接口中 ListenerisMasterConnection 在类中 AbstractMastersListenerpublic int getTimeout()
throws SocketException
getTimeout 在接口中 ListenergetTimeout 在类中 AbstractMastersListenerSocketException - if socket exceptionpublic void prolog(long maxRows,
OceanBaseConnection connection,
OceanBaseStatement statement)
throws SQLException
prolog 在接口中 Listenerprolog 在类中 AbstractMastersListenerSQLExceptionpublic boolean noBackslashEscapes()
noBackslashEscapes 在接口中 ListenernoBackslashEscapes 在类中 AbstractMastersListenerpublic long getServerThreadId()
protected void checkInitialConnection(SQLException queryException) throws SQLException
SQLExceptionpublic void preClose()
preClose 在接口中 ListenerpreClose 在类中 AbstractMastersListenerpublic void preAbort()
public void preExecute()
throws SQLException
preExecute 在接口中 ListenerpreExecute 在类中 AbstractMastersListenerSQLExceptionpublic boolean isValid(int timeout)
throws SQLException
isValid 在接口中 ListenerisValid 在类中 AbstractMastersListenerSQLExceptionpublic void checkWaitingConnection()
throws SQLException
SQLException - if error occurpublic void reconnectFailedConnection(SearchFilter searchFilter) throws SQLException
reconnectFailedConnection 在接口中 ListenerreconnectFailedConnection 在类中 AbstractMastersListenerSQLException - if there is any error during reconnectionpublic void foundActiveMaster(Protocol newMasterProtocol)
newMasterProtocol - the new active connectionpublic void lockAndSwitchMaster(Protocol newMasterProtocol) throws ReconnectDuringTransactionException
Lock must be set
newMasterProtocol - new master connectionReconnectDuringTransactionException - if there was an active transaction.public void foundActiveSecondary(Protocol newSecondaryProtocol) throws SQLException
foundActiveSecondary 在类中 AbstractMastersSlavesListenernewSecondaryProtocol - the new active connectionSQLException - if switch failedpublic void lockAndSwitchSecondary(Protocol newSecondaryProtocol) throws SQLException
newSecondaryProtocol - new secondary connectionSQLException - if an error occur during setting session read-onlypublic void switchReadOnlyConnection(Boolean mustBeReadOnly) throws SQLException
switchReadOnlyConnection 在接口中 ListenerswitchReadOnlyConnection 在类中 AbstractMastersListenermustBeReadOnly - the read-only status askedSQLException - if operation hasn't change protocolpublic HandleErrorResult primaryFail(Method method, Object[] args, boolean killCmd, boolean isClosed)
primaryFail 在接口中 ListenerprimaryFail 在类中 AbstractMastersListenermethod - the initial called methodargs - the initial argskillCmd - is the fail due to a KILL cmdpublic void reconnect()
throws SQLException
reconnect 在接口中 Listenerreconnect 在类中 AbstractMastersListenerSQLException - if reconnection has failedpublic HandleErrorResult secondaryFail(Method method, Object[] args, boolean killCmd) throws SQLException
secondaryFail 在类中 AbstractMastersSlavesListenermethod - the initial called methodargs - the initial argskillCmd - is fail due to a KILL commandSQLException - if relaunch operation failspublic void handleFailLoop()
handleFailLoop 在类中 AbstractMastersListenerpublic boolean isMasterConnected()
public boolean inTransaction()
inTransaction 在接口中 ListenerinTransaction 在类中 AbstractMastersListenerpublic boolean checkMasterStatus(SearchFilter searchFilter)
checkMasterStatus 在接口中 ListenercheckMasterStatus 在类中 AbstractMastersListenersearchFilter - search filterpublic void rePrepareOnSlave(ServerPrepareResult oldServerPrepareResult, boolean mustBeOnMaster) throws SQLException
SQLExceptionpublic List<HostAddress> connectedHosts()
public void reset()
throws SQLException
SQLException - if command fail.Copyright © 2024 oceanbase.com. All rights reserved.