public abstract class AbstractMastersListener extends Object implements Listener
Modifier and Type | Field and Description |
---|---|
protected AtomicInteger |
currentConnectionAttempts |
protected Protocol |
currentProtocol |
protected boolean |
currentReadOnlyAsked |
protected AtomicBoolean |
explicitClosed |
protected GlobalStateInfo |
globalInfo |
protected long |
lastQueryNanos |
protected long |
lastRetry |
protected FailoverProxy |
proxy |
UrlParser |
urlParser |
Modifier | Constructor and Description |
---|---|
protected |
AbstractMastersListener(UrlParser urlParser,
GlobalStateInfo globalInfo) |
Modifier and Type | Method and Description |
---|---|
void |
abortConnection(Protocol protocol)
Utility to force close existing connection.
|
void |
addToBlacklist(HostAddress hostAddress)
After a failover, put the hostAddress in a static list so the other connection will not take this host in account for a time.
|
boolean |
canRetryFailLoop() |
abstract boolean |
checkMasterStatus(SearchFilter searchFilter) |
static void |
clearBlacklist()
Clear blacklist data.
|
void |
closeConnection(Protocol protocol)
Utility to close existing connection.
|
Set<HostAddress> |
getBlacklistKeys() |
String |
getCatalog() |
Protocol |
getCurrentProtocol() |
SearchFilter |
getFilterForFailedHost() |
long |
getLastQueryNanos() |
int |
getMajorServerVersion() |
long |
getMasterHostFailNanos() |
FailoverProxy |
getProxy() |
int |
getRetriesAllDown() |
int |
getTimeout() |
UrlParser |
getUrlParser() |
abstract void |
handleFailLoop() |
HandleErrorResult |
handleFailover(SQLException qe,
Method method,
Object[] args,
Protocol protocol)
Call when a failover is detected on master connection.
|
boolean |
hasHostFail() |
void |
initializeConnection()
Initialize Listener.
|
Object |
invoke(Method method,
Object[] args) |
Object |
invoke(Method method,
Object[] args,
Protocol specificProtocol) |
boolean |
isAutoReconnect() |
boolean |
isClosed() |
boolean |
isExplicitClosed() |
boolean |
isMasterConnection() |
boolean |
isMasterHostFail() |
boolean |
isQueryRelaunchable(Method method,
Object[] args)
Check if query can be re-executed.
|
boolean |
isReadOnly() |
boolean |
isValid(int timeout) |
boolean |
noBackslashEscapes() |
protected boolean |
pingMasterProtocol(Protocol protocol) |
protected void |
preAutoReconnect() |
abstract void |
preClose() |
abstract void |
preExecute() |
abstract HandleErrorResult |
primaryFail(Method method,
Object[] args,
boolean killCmd) |
void |
prolog(long maxRows,
MariaDbConnection connection,
MariaDbStatement statement) |
abstract void |
reconnect() |
abstract void |
reconnectFailedConnection(SearchFilter filter) |
HandleErrorResult |
relaunchOperation(Method method,
Object[] args)
After a failover that has bean done, relaunch the operation that was in progress.
|
void |
removeFromBlacklist(HostAddress hostAddress)
After a successfull connection, permit to remove a hostAddress from blacklist.
|
protected void |
removeListenerFromSchedulers() |
protected void |
resetMasterFailoverData() |
void |
resetOldsBlackListHosts()
Permit to remove Host to blacklist after loadBalanceBlacklistTimeout seconds.
|
boolean |
sessionStateAware() |
boolean |
setMasterHostFail()
Set master fail variables.
|
void |
setProxy(FailoverProxy proxy) |
protected void |
setSessionReadOnly(boolean readOnly,
Protocol protocol) |
abstract void |
switchReadOnlyConnection(Boolean readonly) |
void |
syncConnection(Protocol from,
Protocol to)
When switching between 2 connections, report existing connection parameter to the new used connection.
|
void |
throwFailoverMessage(HostAddress failHostAddress,
boolean wasMaster,
SQLException queryException,
boolean reconnected)
Throw a human readable message after a failoverException.
|
boolean |
versionGreaterOrEqual(int major,
int minor,
int patch) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
foundActiveMaster, getServerThreadId, isMasterConnected, preAbort, rePrepareOnSlave, reset
public final UrlParser urlParser
protected final AtomicInteger currentConnectionAttempts
protected volatile boolean currentReadOnlyAsked
protected Protocol currentProtocol
protected FailoverProxy proxy
protected long lastRetry
protected final AtomicBoolean explicitClosed
protected long lastQueryNanos
protected final GlobalStateInfo globalInfo
protected AbstractMastersListener(UrlParser urlParser, GlobalStateInfo globalInfo)
public static void clearBlacklist()
public void initializeConnection() throws SQLException
initializeConnection
in interface Listener
SQLException
- if any exception occur.protected void removeListenerFromSchedulers()
protected void preAutoReconnect() throws SQLException
SQLException
public FailoverProxy getProxy()
public void setProxy(FailoverProxy proxy)
public Set<HostAddress> getBlacklistKeys()
getBlacklistKeys
in interface Listener
public HandleErrorResult handleFailover(SQLException qe, Method method, Object[] args, Protocol protocol) throws Throwable
handleFailover
in interface Listener
method
- called methodargs
- methods parametersprotocol
- current protocolThrowable
- when method and parameters does not exist.public void addToBlacklist(HostAddress hostAddress)
addToBlacklist
in interface Listener
hostAddress
- the HostAddress to add to blacklistpublic void removeFromBlacklist(HostAddress hostAddress)
removeFromBlacklist
in interface Listener
hostAddress
- the host address tho be remove of blacklistpublic void resetOldsBlackListHosts()
protected void resetMasterFailoverData()
protected void setSessionReadOnly(boolean readOnly, Protocol protocol) throws SQLException
SQLException
public abstract void handleFailLoop()
public Protocol getCurrentProtocol()
getCurrentProtocol
in interface Listener
public long getMasterHostFailNanos()
public boolean setMasterHostFail()
setMasterHostFail
in interface Listener
public boolean isMasterHostFail()
isMasterHostFail
in interface Listener
public boolean hasHostFail()
hasHostFail
in interface Listener
public SearchFilter getFilterForFailedHost()
getFilterForFailedHost
in interface Listener
public HandleErrorResult relaunchOperation(Method method, Object[] args) throws IllegalAccessException, InvocationTargetException
method
- the methode accessedargs
- the parametersIllegalAccessException
- if the initial call is not permitInvocationTargetException
- if there is any error relaunching initial methodpublic boolean isQueryRelaunchable(Method method, Object[] args)
method
- invoke methodargs
- invoke argumentspublic Object invoke(Method method, Object[] args, Protocol specificProtocol) throws Throwable
public void syncConnection(Protocol from, Protocol to) throws SQLException
syncConnection
in interface Listener
from
- used connectionto
- will-be-current connectionSQLException
- if catalog cannot be setpublic boolean versionGreaterOrEqual(int major, int minor, int patch)
versionGreaterOrEqual
in interface Listener
public boolean sessionStateAware()
sessionStateAware
in interface Listener
public boolean noBackslashEscapes()
noBackslashEscapes
in interface Listener
public int getMajorServerVersion()
getMajorServerVersion
in interface Listener
public boolean isValid(int timeout) throws SQLException
isValid
in interface Listener
SQLException
public boolean isReadOnly()
isReadOnly
in interface Listener
public boolean isMasterConnection()
isMasterConnection
in interface Listener
public boolean isExplicitClosed()
isExplicitClosed
in interface Listener
public int getRetriesAllDown()
getRetriesAllDown
in interface Listener
public boolean isAutoReconnect()
isAutoReconnect
in interface Listener
public UrlParser getUrlParser()
getUrlParser
in interface Listener
public abstract void preExecute() throws SQLException
preExecute
in interface Listener
SQLException
public abstract void reconnectFailedConnection(SearchFilter filter) throws SQLException
reconnectFailedConnection
in interface Listener
SQLException
public abstract void switchReadOnlyConnection(Boolean readonly) throws SQLException
switchReadOnlyConnection
in interface Listener
SQLException
public abstract HandleErrorResult primaryFail(Method method, Object[] args, boolean killCmd) throws Throwable
primaryFail
in interface Listener
Throwable
public void throwFailoverMessage(HostAddress failHostAddress, boolean wasMaster, SQLException queryException, boolean reconnected) throws SQLException
throwFailoverMessage
in interface Listener
failHostAddress
- failedHostAddresswasMaster
- was failed connection masterqueryException
- internal errorreconnected
- connection statusSQLException
- error with failover informationpublic boolean canRetryFailLoop()
canRetryFailLoop
in interface Listener
public void prolog(long maxRows, MariaDbConnection connection, MariaDbStatement statement) throws SQLException
prolog
in interface Listener
SQLException
public String getCatalog() throws SQLException
getCatalog
in interface Listener
SQLException
public int getTimeout() throws SocketException
getTimeout
in interface Listener
SocketException
public abstract void reconnect() throws SQLException
reconnect
in interface Listener
SQLException
public abstract boolean checkMasterStatus(SearchFilter searchFilter)
checkMasterStatus
in interface Listener
public long getLastQueryNanos()
getLastQueryNanos
in interface Listener
protected boolean pingMasterProtocol(Protocol protocol)
public void closeConnection(Protocol protocol)
protocol
- connection to close.public void abortConnection(Protocol protocol)
protocol
- connection to close.Copyright © 2018 mariadb.org. All rights reserved.