public class MastersSlavesListener extends AbstractMastersSlavesListener
| Modifier and Type | Field and Description |
|---|---|
protected Protocol |
masterProtocol |
protected Protocol |
secondaryProtocol |
waitNewMasterProtocol, waitNewSecondaryProtocolcurrentConnectionAttempts, currentProtocol, currentReadOnlyAsked, explicitClosed, lastQueryNanos, lastRetry, proxy, urlParser| Constructor and Description |
|---|
MastersSlavesListener(UrlParser urlParser)
Initialisation.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
checkInitialConnection(QueryException queryException) |
boolean |
checkMasterStatus(SearchFilter searchFilter)
Check master status.
|
void |
checkWaitingConnection()
Verify that there is waiting connection that have to replace failing one.
|
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.
|
void |
handleFailLoop() |
void |
initializeConnection()
Initialize connections.
|
boolean |
isMasterConnected() |
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.
|
void |
preClose()
Called after a call on Connection.close().
|
void |
preExecute() |
HandleErrorResult |
primaryFail(Method method,
Object[] args)
To handle the newly detected failover on the master connection.
|
void |
reconnect()
Reconnect failed connection.
|
void |
reconnectFailedConnection(SearchFilter searchFilter)
Loop to connect.
|
protected void |
removeListenerFromSchedulers() |
void |
rePrepareOnSlave(ServerPrepareResult oldServerPrepareResult,
boolean mustBeOnMaster) |
HandleErrorResult |
secondaryFail(Method method,
Object[] args)
To handle the newly detected failover on the secondary connection.
|
void |
switchReadOnlyConnection(Boolean mustBeReadOnly)
Switch to a read-only(secondary) or read and write connection(master).
|
getFilterForFailedHost, getSecondaryHostFailNanos, handleFailover, hasHostFail, isMasterHostFailReconnect, isSecondaryHostFail, isSecondaryHostFailReconnect, resetMasterFailoverData, resetSecondaryFailoverData, setSecondaryHostFailaddToBlacklist, canRetryFailLoop, clearBlacklist, closeConnection, getBlacklistKeys, getCurrentProtocol, getLastQueryNanos, getMasterHostFailNanos, getProxy, getRetriesAllDown, getUrlParser, invoke, invoke, isAutoReconnect, isClosed, isExplicitClosed, isMasterHostFail, isQueryRelaunchable, isReadOnly, pingMasterProtocol, preAutoReconnect, relaunchOperation, removeFromBlacklist, resetOldsBlackListHosts, setMasterHostFail, setProxy, setSessionReadOnly, syncConnection, throwFailoverMessageprotected Protocol masterProtocol
protected Protocol secondaryProtocol
public MastersSlavesListener(UrlParser urlParser)
urlParser - connection string object.protected void removeListenerFromSchedulers()
removeListenerFromSchedulers in class AbstractMastersListenerpublic void initializeConnection()
throws QueryException
initializeConnection in interface ListenerinitializeConnection in class AbstractMastersListenerQueryException - if a connection error append.protected void checkInitialConnection(QueryException queryException) throws QueryException
QueryExceptionpublic void preClose()
throws SQLException
preClose in interface ListenerpreClose in class AbstractMastersListenerSQLException - if error append during closing those connections.public void preExecute()
throws QueryException
preExecute in interface ListenerpreExecute in class AbstractMastersListenerQueryExceptionpublic void checkWaitingConnection()
throws QueryException
QueryException - if error occurpublic void reconnectFailedConnection(SearchFilter searchFilter) throws QueryException
reconnectFailedConnection in interface ListenerreconnectFailedConnection in class AbstractMastersListenerQueryException - if there is any error during reconnectionpublic void foundActiveMaster(Protocol newMasterProtocol)
newMasterProtocol - the new active connectionpublic void lockAndSwitchMaster(Protocol newMasterProtocol) throws ReconnectDuringTransactionException
newMasterProtocol - new master connectionReconnectDuringTransactionException - if there was an active transaction.public void foundActiveSecondary(Protocol newSecondaryProtocol) throws QueryException
foundActiveSecondary in class AbstractMastersSlavesListenernewSecondaryProtocol - the new active connectionQueryExceptionpublic void lockAndSwitchSecondary(Protocol newSecondaryProtocol) throws QueryException
newSecondaryProtocol - new secondary connectionQueryException - if an error occur during setting session read-onlypublic void switchReadOnlyConnection(Boolean mustBeReadOnly) throws QueryException
switchReadOnlyConnection in interface ListenerswitchReadOnlyConnection in class AbstractMastersListenermustBeReadOnly - the read-only status askedQueryException - if operation hasn't change protocolpublic HandleErrorResult primaryFail(Method method, Object[] args) throws Throwable
primaryFail in interface ListenerprimaryFail in class AbstractMastersListenermethod - the initial called methodargs - the initial argsThrowable - if failover has not been catchpublic void reconnect()
throws QueryException
reconnect in interface Listenerreconnect in class AbstractMastersListenerQueryException - if reconnection has failedpublic HandleErrorResult secondaryFail(Method method, Object[] args) throws Throwable
secondaryFail in class AbstractMastersSlavesListenermethod - the initial called methodargs - the initial argsThrowable - if failover has not catch errorpublic void handleFailLoop()
handleFailLoop in class AbstractMastersListenerpublic boolean isMasterConnected()
public boolean checkMasterStatus(SearchFilter searchFilter)
checkMasterStatus in interface ListenercheckMasterStatus in class AbstractMastersListenersearchFilter - search filterpublic void rePrepareOnSlave(ServerPrepareResult oldServerPrepareResult, boolean mustBeOnMaster) throws QueryException
QueryExceptionCopyright © 2017. All rights reserved.