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 |
queriesSinceFailover
blacklist, currentConnectionAttempts, currentProtocol, currentReadOnlyAsked, executorService, explicitClosed, isLooping, lastRetry, proxy, scheduledFailover, urlParser
Constructor and Description |
---|
MastersSlavesListener(UrlParser urlParser)
Initialisation.
|
Modifier and Type | Method and Description |
---|---|
protected void |
checkInitialConnection() |
void |
checkMasterStatus(SearchFilter searchFilter)
Check master status.
|
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()
Initialize connections.
|
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.
|
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, setSecondaryHostFail
addToBlacklist, getBlacklist, getCurrentProtocol, getMasterHostFailTimestamp, getProxy, getRetriesAllDown, getUrlParser, invoke, isAutoReconnect, isClosed, isExplicitClosed, isMasterHostFail, isReadOnly, launchFailLoopIfNotlaunched, relaunchOperation, resetOldsBlackListHosts, setExplicitClosed, setMasterHostFail, setProxy, setSessionReadOnly, stopFailover, syncConnection
protected Protocol masterProtocol
protected Protocol secondaryProtocol
protected long lastQueryTime
protected ScheduledFuture scheduledPing
public MastersSlavesListener(UrlParser urlParser)
urlParser
- connection string object.public void initializeConnection() throws QueryException
initializeConnection
in interface Listener
initializeConnection
in class AbstractMastersListener
QueryException
- if a connection error append.protected void checkInitialConnection()
public void preClose() throws SQLException
preClose
in interface Listener
preClose
in class AbstractMastersListener
SQLException
- if error append during closing those connections.public void preExecute() throws QueryException
preExecute
in interface Listener
preExecute
in class AbstractMastersListener
QueryException
public boolean shouldReconnect()
shouldReconnect
in interface Listener
shouldReconnect
in class AbstractMastersListener
public void reconnectFailedConnection(SearchFilter searchFilter) throws QueryException
reconnectFailedConnection
in interface Listener
reconnectFailedConnection
in class AbstractMastersListener
QueryException
- if there is any error during reconnectionQueryException
- sqlExceptionpublic void foundActiveMaster(Protocol newMasterProtocol)
newMasterProtocol
- the new active connectionpublic void foundActiveSecondary(Protocol newSecondaryProtocol) throws QueryException
foundActiveSecondary
in class AbstractMastersSlavesListener
newSecondaryProtocol
- the new active connectionQueryException
public void switchReadOnlyConnection(Boolean mustBeReadOnly) throws QueryException
switchReadOnlyConnection
in interface Listener
switchReadOnlyConnection
in class AbstractMastersListener
mustBeReadOnly
- the read-only status askedQueryException
- if operation hasn't change protocolpublic HandleErrorResult primaryFail(Method method, Object[] args) throws Throwable
primaryFail
in interface Listener
primaryFail
in class AbstractMastersListener
method
- the initial called methodargs
- the initial argsThrowable
- if failover has not been catchpublic void reconnect() throws QueryException
reconnect
in interface Listener
reconnect
in class AbstractMastersListener
QueryException
- if reconnection has failedpublic HandleErrorResult secondaryFail(Method method, Object[] args) throws Throwable
secondaryFail
in class AbstractMastersSlavesListener
method
- the initial called methodargs
- the initial argsThrowable
- if failover has not catch errorpublic void checkMasterStatus(SearchFilter searchFilter) throws QueryException
searchFilter
- search filterQueryException
- exceptionpublic void throwFailoverMessage(QueryException queryException, boolean reconnected) throws QueryException
throwFailoverMessage
in interface Listener
throwFailoverMessage
in class AbstractMastersListener
queryException
- internal errorreconnected
- connection statusQueryException
- error with failover informationCopyright © 2015. All rights reserved.