|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mariadb.jdbc.internal.failover.AbstractMastersListener
org.mariadb.jdbc.internal.failover.AbstractMastersSlavesListener
org.mariadb.jdbc.internal.failover.impl.MastersSlavesListener
public class MastersSlavesListener
this class handle the operation when multiple hosts.
| Field Summary | |
|---|---|
protected Protocol |
masterProtocol
|
protected Protocol |
secondaryProtocol
|
| Fields inherited from class org.mariadb.jdbc.internal.failover.AbstractMastersSlavesListener |
|---|
waitNewMasterProtocol, waitNewSecondaryProtocol |
| Fields inherited from class org.mariadb.jdbc.internal.failover.AbstractMastersListener |
|---|
currentConnectionAttempts, currentProtocol, currentReadOnlyAsked, explicitClosed, lastQueryNanos, lastRetry, proxy, urlParser |
| Constructor Summary | |
|---|---|
MastersSlavesListener(UrlParser urlParser)
Initialisation. |
|
| Method Summary | |
|---|---|
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. |
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). |
| Methods inherited from class org.mariadb.jdbc.internal.failover.AbstractMastersSlavesListener |
|---|
getFilterForFailedHost, getSecondaryHostFailNanos, handleFailover, hasHostFail, isMasterHostFailReconnect, isSecondaryHostFail, isSecondaryHostFailReconnect, resetMasterFailoverData, resetSecondaryFailoverData, setSecondaryHostFail |
| Methods inherited from class org.mariadb.jdbc.internal.failover.AbstractMastersListener |
|---|
addToBlacklist, 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, throwFailoverMessage |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Protocol masterProtocol
protected Protocol secondaryProtocol
| Constructor Detail |
|---|
public MastersSlavesListener(UrlParser urlParser)
urlParser - connection string object.| Method Detail |
|---|
protected void removeListenerFromSchedulers()
removeListenerFromSchedulers in class AbstractMastersListener
public void initializeConnection()
throws SQLException
initializeConnection in interface ListenerinitializeConnection in class AbstractMastersListenerSQLException - if a connection error append.
protected void checkInitialConnection(SQLException queryException)
throws SQLException
SQLException
public void preClose()
throws SQLException
preClose in interface ListenerpreClose in class AbstractMastersListenerSQLException - if error append during closing those connections.
public void preExecute()
throws SQLException
preExecute in interface ListenerpreExecute in class AbstractMastersListenerSQLException
public void checkWaitingConnection()
throws SQLException
SQLException - if error occur
public void reconnectFailedConnection(SearchFilter searchFilter)
throws SQLException
reconnectFailedConnection in interface ListenerreconnectFailedConnection in class AbstractMastersListenerSQLException - if there is any error during reconnectionpublic void foundActiveMaster(Protocol newMasterProtocol)
newMasterProtocol - the new active connection
public void lockAndSwitchMaster(Protocol newMasterProtocol)
throws ReconnectDuringTransactionException
Lock must be set
newMasterProtocol - new master connection
ReconnectDuringTransactionException - if there was an active transaction.
public void foundActiveSecondary(Protocol newSecondaryProtocol)
throws SQLException
foundActiveSecondary in class AbstractMastersSlavesListenernewSecondaryProtocol - the new active connection
SQLException - if switch failed
public void lockAndSwitchSecondary(Protocol newSecondaryProtocol)
throws SQLException
newSecondaryProtocol - new secondary connection
SQLException - if an error occur during setting session read-only
public void switchReadOnlyConnection(Boolean mustBeReadOnly)
throws SQLException
switchReadOnlyConnection in interface ListenerswitchReadOnlyConnection in class AbstractMastersListenermustBeReadOnly - the read-only status asked
SQLException - if operation hasn't change protocol
public HandleErrorResult primaryFail(Method method,
Object[] args)
throws Throwable
primaryFail in interface ListenerprimaryFail in class AbstractMastersListenermethod - the initial called methodargs - the initial args
Throwable - if failover has not been catch
public void reconnect()
throws SQLException
reconnect in interface Listenerreconnect in class AbstractMastersListenerSQLException - if reconnection has failed
public HandleErrorResult secondaryFail(Method method,
Object[] args)
throws Throwable
secondaryFail in class AbstractMastersSlavesListenermethod - the initial called methodargs - the initial args
Throwable - 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 filter
public void rePrepareOnSlave(ServerPrepareResult oldServerPrepareResult,
boolean mustBeOnMaster)
throws SQLException
SQLExceptionpublic List<HostAddress> connectedHosts()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||