JavaScript is disabled on your browser.
Field Summary
Fields
List the recent failedConnection.
protected boolean
protected long
protected long
private long
Constructor Summary
Constructors
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
void
Utility to force close existing connection.
void
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
abstract boolean
static void
void
Utility to close existing connection.
long
int
long
int
int
abstract void
Call when a failover is detected on master connection.
boolean
void
boolean
boolean
boolean
boolean
boolean
boolean
boolean
Check if query can be re-executed.
boolean
boolean
boolean
boolean
protected boolean
protected void
abstract void
abstract void
void
abstract void
abstract void
After a failover that has bean done, relaunch the operation that was in progress.
void
After a successfull connection, permit to remove a hostAddress from blacklist.
protected void
protected void
void
Permit to remove Host to blacklist after loadBalanceBlacklistTimeout seconds.
boolean
boolean
Set master fail variables.
void
protected void
abstract void
void
When switching between 2 connections, report existing connection parameter to the new used
connection.
void
Throw a human readable message after a failoverException.
boolean
Methods inherited from class java.lang.Object
clone , equals , finalize , getClass , hashCode , notify , notifyAll , toString , wait , wait , wait
Field Details
blacklist
List the recent failedConnection.
logger
private static final Logger logger
currentConnectionAttempts
currentReadOnlyAsked
protected volatile boolean currentReadOnlyAsked
lastRetry
protected long lastRetry
lastQueryNanos
protected long lastQueryNanos
masterHostFailNanos
private volatile long masterHostFailNanos
Method Details
clearBlacklist
public static void clearBlacklist ()
Clear blacklist data.
initializeConnection
Initialize Listener. This listener will be added to the connection validation loop according to
option value so the connection will be verified periodically. (Important for aurora, for other,
connection pool often have this functionality)
Specified by:
initializeConnection
in interface Listener
Throws:
SQLException
- if any exception occur.
removeListenerFromSchedulers
protected void removeListenerFromSchedulers ()
handleFailover
Call when a failover is detected on master connection. Will :
set fail variable
try to reconnect
relaunch query if possible
Specified by:
handleFailover
in interface Listener
Parameters:
method
- called method
args
- methods parameters
protocol
- current protocol
Returns:
a HandleErrorResult object to indicate if query has been relaunched, and the exception
if not
Throws:
SQLException
- when method and parameters does not exist.
addToBlacklist
After a failover, put the hostAddress in a static list so the other connection will not take
this host in account for a time.
Specified by:
addToBlacklist
in interface Listener
Parameters:
hostAddress
- the HostAddress to add to blacklist
removeFromBlacklist
public void removeFromBlacklist (HostAddress hostAddress)
After a successfull connection, permit to remove a hostAddress from blacklist.
Specified by:
removeFromBlacklist
in interface Listener
Parameters:
hostAddress
- the host address tho be remove of blacklist
resetOldsBlackListHosts
public void resetOldsBlackListHosts ()
Permit to remove Host to blacklist after loadBalanceBlacklistTimeout seconds.
resetMasterFailoverData
protected void resetMasterFailoverData ()
handleFailLoop
public abstract void handleFailLoop ()
getMasterHostFailNanos
public long getMasterHostFailNanos ()
setMasterHostFail
public boolean setMasterHostFail ()
Set master fail variables.
Specified by:
setMasterHostFail
in interface Listener
Returns:
true if was already failed
relaunchOperation
After a failover that has bean done, relaunch the operation that was in progress. In case of
special operation that crash server, doesn't relaunched it;
Parameters:
method
- the method accessed
args
- the parameters
Returns:
An object that indicate the result or that the exception as to be thrown
Throws:
SQLException
- if there is any error relaunching initial method
isQueryRelaunchable
public boolean isQueryRelaunchable (Method method,
Object [] args)
Check if query can be re-executed.
Parameters:
method
- invoke method
args
- invoke arguments
Returns:
true if can be re-executed
syncConnection
When switching between 2 connections, report existing connection parameter to the new used
connection.
Specified by:
syncConnection
in interface Listener
Parameters:
from
- used connection
to
- will-be-current connection
Throws:
SQLException
- if catalog cannot be set
versionGreaterOrEqual
public boolean versionGreaterOrEqual (int major,
int minor,
int patch)
Specified by:
versionGreaterOrEqual
in interface Listener
preClose
public abstract void preClose ()
Specified by:
preClose
in interface Listener
throwFailoverMessage
Throw a human readable message after a failoverException.
Specified by:
throwFailoverMessage
in interface Listener
Parameters:
failHostAddress
- failedHostAddress
wasMaster
- was failed connection master
queryException
- internal error
reconnected
- connection status
Throws:
SQLException
- error with failover information
pingMasterProtocol
protected boolean pingMasterProtocol (Protocol protocol)
closeConnection
public void closeConnection (Protocol protocol)
Utility to close existing connection.
Parameters:
protocol
- connection to close.
abortConnection
public void abortConnection (Protocol protocol)
Utility to force close existing connection.
Parameters:
protocol
- connection to close.