public abstract class AbstractMastersListener extends Object implements Listener
| Modifier and Type | Class and Description |
|---|---|
protected class |
AbstractMastersListener.FailLoop
Private class to permit a timer reconnection loop.
|
| Modifier and Type | Field and Description |
|---|---|
protected static Map<HostAddress,Long> |
blacklist
List the recent failedConnection.
|
protected AtomicInteger |
currentConnectionAttempts |
protected Protocol |
currentProtocol |
protected AtomicBoolean |
currentReadOnlyAsked |
protected ScheduledExecutorService |
executorService |
protected boolean |
explicitClosed |
protected AtomicBoolean |
isLooping |
protected long |
lastRetry |
protected FailoverProxy |
proxy |
protected ScheduledFuture |
scheduledFailover |
UrlParser |
urlParser |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractMastersListener(UrlParser urlParser) |
| Modifier and Type | Method and Description |
|---|---|
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.
|
static void |
clearBlacklist() |
Map<HostAddress,Long> |
getBlacklist() |
Protocol |
getCurrentProtocol() |
SearchFilter |
getFilterForFailedHost() |
long |
getMasterHostFailTimestamp() |
FailoverProxy |
getProxy() |
int |
getRetriesAllDown() |
UrlParser |
getUrlParser() |
HandleErrorResult |
handleFailover(Method method,
Object[] args)
Call when a failover is detected on master connection.
|
boolean |
hasHostFail() |
abstract void |
initializeConnection() |
Object |
invoke(Method method,
Object[] args) |
boolean |
isAutoReconnect() |
boolean |
isClosed() |
boolean |
isExplicitClosed() |
boolean |
isMasterHostFail() |
boolean |
isReadOnly() |
protected void |
launchFailLoopIfNotlaunched(boolean now)
launch the scheduler loop every 250 milliseconds, to reconnect a failed connection.
|
abstract void |
preClose() |
abstract void |
preExecute() |
abstract HandleErrorResult |
primaryFail(Method method,
Object[] args) |
abstract void |
reconnect() |
abstract void |
reconnectFailedConnection(SearchFilter filter) |
HandleErrorResult |
relaunchOperation(Method method,
Object[] args)
After a failover that has bean done, relaunche the operation that was in progress.
|
protected void |
resetMasterFailoverData() |
void |
resetOldsBlackListHosts()
Permit to remove Host to blacklist after loadBalanceBlacklistTimeout seconds.
|
void |
setExplicitClosed(boolean explicitClosed) |
boolean |
setMasterHostFail()
Set master fail variables.
|
void |
setProxy(FailoverProxy proxy) |
protected void |
setSessionReadOnly(boolean readOnly,
Protocol protocol) |
abstract boolean |
shouldReconnect() |
protected void |
stopFailover() |
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.
|
abstract void |
throwFailoverMessage(QueryException queryException,
boolean reconnected) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitfoundActiveMasterprotected static Map<HostAddress,Long> blacklist
public final UrlParser urlParser
protected AtomicInteger currentConnectionAttempts
protected AtomicBoolean currentReadOnlyAsked
protected AtomicBoolean isLooping
protected ScheduledFuture scheduledFailover
protected Protocol currentProtocol
protected FailoverProxy proxy
protected long lastRetry
protected boolean explicitClosed
protected ScheduledExecutorService executorService
protected AbstractMastersListener(UrlParser urlParser)
public FailoverProxy getProxy()
public void setProxy(FailoverProxy proxy)
public Map<HostAddress,Long> getBlacklist()
getBlacklist in interface Listenerpublic HandleErrorResult handleFailover(Method method, Object[] args) throws Throwable
handleFailover in interface Listenermethod - called methodargs - methods parametersThrowable - when method and parameters does not exist.public void addToBlacklist(HostAddress hostAddress)
hostAddress - the HostAddress to add to blacklistpublic void resetOldsBlackListHosts()
protected void resetMasterFailoverData()
protected void setSessionReadOnly(boolean readOnly,
Protocol protocol)
throws QueryException
QueryExceptionprotected void stopFailover()
protected void launchFailLoopIfNotlaunched(boolean now)
now - now will launch the loop immediatly, 250ms after if falsepublic Protocol getCurrentProtocol()
public long getMasterHostFailTimestamp()
public boolean setMasterHostFail()
public boolean isMasterHostFail()
public boolean hasHostFail()
public SearchFilter getFilterForFailedHost()
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 void syncConnection(Protocol from, Protocol to) throws QueryException
syncConnection in interface Listenerfrom - used connectionto - will-be-current connectionQueryException - if catalog cannot be setpublic boolean isReadOnly()
isReadOnly in interface Listenerpublic boolean isExplicitClosed()
isExplicitClosed in interface Listenerpublic void setExplicitClosed(boolean explicitClosed)
setExplicitClosed in interface Listenerpublic int getRetriesAllDown()
getRetriesAllDown in interface Listenerpublic boolean isAutoReconnect()
isAutoReconnect in interface Listenerpublic UrlParser getUrlParser()
getUrlParser in interface Listenerpublic abstract void initializeConnection()
throws QueryException
initializeConnection in interface ListenerQueryExceptionpublic abstract void preExecute()
throws QueryException
preExecute in interface ListenerQueryExceptionpublic abstract void preClose()
throws SQLException
preClose in interface ListenerSQLExceptionpublic abstract boolean shouldReconnect()
shouldReconnect in interface Listenerpublic abstract void reconnectFailedConnection(SearchFilter filter) throws QueryException
reconnectFailedConnection in interface ListenerQueryExceptionpublic abstract void switchReadOnlyConnection(Boolean readonly) throws QueryException
switchReadOnlyConnection in interface ListenerQueryExceptionpublic abstract HandleErrorResult primaryFail(Method method, Object[] args) throws Throwable
primaryFail in interface ListenerThrowablepublic abstract void throwFailoverMessage(QueryException queryException, boolean reconnected) throws QueryException
throwFailoverMessage in interface ListenerQueryExceptionpublic abstract void reconnect()
throws QueryException
reconnect in interface ListenerQueryExceptionpublic static void clearBlacklist()
Copyright © 2015. All rights reserved.