public class MastersFailoverListener extends AbstractMastersListener
AbstractMastersListener.FailLoop
blacklist, currentConnectionAttempts, currentProtocol, currentReadOnlyAsked, executorService, explicitClosed, isLooping, lastRetry, proxy, scheduledFailover, urlParser
Constructor and Description |
---|
MastersFailoverListener(UrlParser urlParser)
Initialisation.
|
Modifier and Type | Method and Description |
---|---|
void |
foundActiveMaster(Protocol protocol)
method called when a new Master connection is found after a fallback.
|
void |
initializeConnection()
Connect to database.
|
void |
preClose() |
void |
preExecute()
Before executing query, reconnect if connection is closed, and autoReconnect option is set.
|
HandleErrorResult |
primaryFail(Method method,
Object[] args) |
void |
reconnect() |
void |
reconnectFailedConnection(SearchFilter searchFilter)
Loop to connect.
|
boolean |
shouldReconnect() |
void |
switchReadOnlyConnection(Boolean mustBeReadOnly)
Force session to read-only according to options.
|
void |
throwFailoverMessage(QueryException queryException,
boolean reconnected)
Throw a human readable message after a failoverException.
|
addToBlacklist, getBlacklist, getCurrentProtocol, getFilterForFailedHost, getMasterHostFailTimestamp, getProxy, getRetriesAllDown, getUrlParser, handleFailover, hasHostFail, invoke, isAutoReconnect, isClosed, isExplicitClosed, isMasterHostFail, isReadOnly, launchFailLoopIfNotlaunched, relaunchOperation, resetMasterFailoverData, resetOldsBlackListHosts, setExplicitClosed, setMasterHostFail, setProxy, setSessionReadOnly, stopFailover, syncConnection
public MastersFailoverListener(UrlParser urlParser)
urlParser
- url options.public void initializeConnection() throws QueryException
initializeConnection
in interface Listener
initializeConnection
in class AbstractMastersListener
QueryException
- if connection is on error.public void preExecute() throws QueryException
preExecute
in interface Listener
preExecute
in class AbstractMastersListener
QueryException
- if connection has been explicitly closed.public boolean shouldReconnect()
shouldReconnect
in interface Listener
shouldReconnect
in class AbstractMastersListener
public void preClose() throws SQLException
preClose
in interface Listener
preClose
in class AbstractMastersListener
SQLException
public HandleErrorResult primaryFail(Method method, Object[] args) throws Throwable
primaryFail
in interface Listener
primaryFail
in class AbstractMastersListener
Throwable
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 switchReadOnlyConnection(Boolean mustBeReadOnly) throws QueryException
switchReadOnlyConnection
in interface Listener
switchReadOnlyConnection
in class AbstractMastersListener
mustBeReadOnly
- is read-only flagQueryException
- if a connection error occurpublic void foundActiveMaster(Protocol protocol) throws QueryException
protocol
- the new active connectionQueryException
public void throwFailoverMessage(QueryException queryException, boolean reconnected) throws QueryException
throwFailoverMessage
in interface Listener
throwFailoverMessage
in class AbstractMastersListener
queryException
- internal errorreconnected
- connection statusQueryException
- error with failover informationpublic void reconnect() throws QueryException
reconnect
in interface Listener
reconnect
in class AbstractMastersListener
QueryException
Copyright © 2015. All rights reserved.