public class MastersSlavesListener extends AbstractMastersSlavesListener
| Modifier and Type | Class and Description |
|---|---|
protected class |
MastersSlavesListener.PingLoop
private class to chech of currents connections are still ok.
|
AbstractMastersListener.FailLoop| Modifier and Type | Field and Description |
|---|---|
protected long |
lastQueryTime |
protected Protocol |
masterProtocol |
protected ScheduledFuture |
scheduledPing |
protected Protocol |
secondaryProtocol |
queriesSinceFailoverblacklist, currentConnectionAttempts, currentProtocol, currentReadOnlyAsked, executorService, explicitClosed, isLooping, jdbcUrl, lastRetry, proxy, scheduledFailover| Constructor and Description |
|---|
MastersSlavesListener(JDBCUrl jdbcUrl) |
| Modifier and Type | Method and Description |
|---|---|
void |
checkIfTypeHaveChanged(SearchFilter searchFilter) |
protected void |
checkInitialConnection() |
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 |
initializeConnection() |
void |
preClose() |
void |
preExecute() |
HandleErrorResult |
primaryFail(Method method,
Object[] args)
to handle the newly detected failover on the master connection
|
void |
reconnect() |
void |
reconnectFailedConnection(SearchFilter searchFilter)
Loop to connect
|
HandleErrorResult |
secondaryFail(Method method,
Object[] args)
to handle the newly detected failover on the secondary connection
|
boolean |
shouldReconnect()
When failing to a different type of host, when to retry
So he doesn't appear here.
|
void |
switchReadOnlyConnection(Boolean mustBeReadOnly)
switch to a read-only(secondary) or read and write connection(master)
|
void |
throwFailoverMessage(QueryException queryException,
boolean reconnected)
Throw a human readable message after a failoverException
|
getFilterForFailedHost, getSecondaryHostFailTimestamp, handleFailover, hasHostFail, isSecondaryHostFail, resetMasterFailoverData, resetSecondaryFailoverData, setSecondaryHostFailaddToBlacklist, getBlacklist, getCurrentProtocol, getJdbcUrl, getMasterHostFailTimestamp, getProxy, getRetriesAllDown, invoke, isAutoReconnect, isClosed, isExplicitClosed, isMasterHostFail, isReadOnly, launchFailLoopIfNotlaunched, relaunchOperation, resetOldsBlackListHosts, setExplicitClosed, setMasterHostFail, setProxy, setSessionReadOnly, stopFailover, syncConnectionprotected Protocol masterProtocol
protected Protocol secondaryProtocol
protected long lastQueryTime
protected ScheduledFuture scheduledPing
public MastersSlavesListener(JDBCUrl jdbcUrl)
public void initializeConnection()
throws QueryException
initializeConnection in interface ListenerinitializeConnection in class AbstractMastersListenerQueryExceptionprotected void checkInitialConnection()
public void preClose()
throws SQLException
preClose in interface ListenerpreClose in class AbstractMastersListenerSQLExceptionpublic void preExecute()
throws QueryException
preExecute in interface ListenerpreExecute in class AbstractMastersListenerQueryExceptionpublic boolean shouldReconnect()
shouldReconnect in interface ListenershouldReconnect in class AbstractMastersListenerpublic void reconnectFailedConnection(SearchFilter searchFilter) throws QueryException
reconnectFailedConnection in interface ListenerreconnectFailedConnection in class AbstractMastersListenerQueryException - if there is any error during reconnectionQueryException - sqlExceptionpublic void foundActiveMaster(Protocol newMasterProtocol)
newMasterProtocol - the new active connectionpublic void foundActiveSecondary(Protocol newSecondaryProtocol)
foundActiveSecondary in class AbstractMastersSlavesListenernewSecondaryProtocol - the new active connectionpublic 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 AbstractMastersListenerQueryExceptionpublic 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 checkIfTypeHaveChanged(SearchFilter searchFilter) throws QueryException
QueryExceptionpublic void throwFailoverMessage(QueryException queryException, boolean reconnected) throws QueryException
throwFailoverMessage in interface ListenerthrowFailoverMessage in class AbstractMastersListenerqueryException - internal errorreconnected - connection statusQueryException - error with failover informationCopyright © 2015. All rights reserved.