# Class AbstractMastersReplicasListener

java.lang.Object
org.mariadb.jdbc.internal.failover.AbstractMastersListener
org.mariadb.jdbc.internal.failover.AbstractMastersReplicasListener

All Implemented Interfaces:
  `Listener`

Direct Known Subclasses:
  `MastersReplicasListener`

public abstract class AbstractMastersReplicasListener extends AbstractMastersListener

## Field Summary

Fields
Modifier and Type
Field
Description
`protected final AtomicReference<Protocol>`
`waitNewMasterProtocol`
`protected final AtomicReference<Protocol>`
`waitNewSecondaryProtocol`

### Fields inherited from class AbstractMastersListener

`currentConnectionAttempts, currentProtocol, currentReadOnlyAsked, explicitClosed, globalInfo, lastQueryNanos, lastRetry, proxy, urlParser`

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`AbstractMastersReplicasListener(UrlParser urlParser, GlobalStateInfo globalInfo)`

## Method Summary

Modifier and Type
Method
Description
`abstract void`
`foundActiveSecondary(Protocol newSecondaryProtocol)`
`SearchFilter`
`getFilterForFailedHost()`
`long`
`getSecondaryHostFailNanos()`
`HandleErrorResult`
`handleFailover(SQLException qe, Method method, Object[] args, Protocol protocol, boolean isClosed)`
Handle failover on master or replica connection.
`boolean`
`hasHostFail()`
`boolean`
`isMasterHostFailReconnect()`
`boolean`
`isSecondaryHostFail()`
`boolean`
`isSecondaryHostFailReconnect()`
`protected void`
`resetMasterFailoverData()`
`protected void`
`resetSecondaryFailoverData()`
`abstract HandleErrorResult`
`secondaryFail(Method method, Object[] args, boolean killCmd)`
`boolean`
`setSecondaryHostFail()`
Set replica connection lost variables.

### Methods inherited from class AbstractMastersListener

`abortConnection, addToBlacklist, canRetryFailLoop, checkMasterStatus, clearBlacklist, closeConnection, getBlacklistKeys, getCatalog, getCurrentProtocol, getLastQueryNanos, getMajorServerVersion, getMasterHostFailNanos, getProxy, getRetriesAllDown, getTimeout, getUrlParser, handleFailLoop, initializeConnection, inTransaction, invoke, invoke, isAutoReconnect, isClosed, isExplicitClosed, isMasterConnection, isMasterHostFail, isQueryRelaunchable, isReadOnly, isServerMariaDb, isValid, noBackslashEscapes, pingMasterProtocol, preAutoReconnect, preClose, preExecute, primaryFail, prolog, reconnect, reconnectFailedConnection, relaunchOperation, removeFromBlacklist, removeListenerFromSchedulers, resetOldsBlackListHosts, sessionStateAware, setMasterHostFail, setProxy, setSessionReadOnly, switchReadOnlyConnection, syncConnection, throwFailoverMessage, versionGreaterOrEqual`

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface Listener

`foundActiveMaster, getServerThreadId, isMasterConnected, preAbort, rePrepareOnReplica, reset`

## Field Details

### waitNewSecondaryProtocol

protected final AtomicReference<Protocol> waitNewSecondaryProtocol

### waitNewMasterProtocol

protected final AtomicReference<Protocol> waitNewMasterProtocol

## Constructor Details

### AbstractMastersReplicasListener

protected AbstractMastersReplicasListener(UrlParser urlParser, GlobalStateInfo globalInfo)

## Method Details

### handleFailover

public HandleErrorResult handleFailover(SQLException qe, Method method, Object[] args, Protocol protocol, boolean isClosed) throws SQLException
Handle failover on master or replica connection.

Specified by:
  `handleFailover` in interface `Listener`
Overrides:
  `handleFailover` in class `AbstractMastersListener`
Parameters:
  `method` - called method
  `args` - methods parameters
  `protocol` - current protocol
Returns:
  HandleErrorResult object to indicate if query has finally been relaunched or exception if not.
Throws:
  `SQLException` - if primary fail reconnection fails

### resetMasterFailoverData

protected void resetMasterFailoverData()

Overrides:
  `resetMasterFailoverData` in class `AbstractMastersListener`

### resetSecondaryFailoverData

protected void resetSecondaryFailoverData()

### getSecondaryHostFailNanos

public long getSecondaryHostFailNanos()

### setSecondaryHostFail

public boolean setSecondaryHostFail()
Set replica connection lost variables.

Returns:
  true if fail wasn't seen before

### isSecondaryHostFail

public boolean isSecondaryHostFail()

### isSecondaryHostFailReconnect

public boolean isSecondaryHostFailReconnect()

### isMasterHostFailReconnect

public boolean isMasterHostFailReconnect()

### hasHostFail

public boolean hasHostFail()

Specified by:
  `hasHostFail` in interface `Listener`
Overrides:
  `hasHostFail` in class `AbstractMastersListener`

### getFilterForFailedHost

public SearchFilter getFilterForFailedHost()

Specified by:
  `getFilterForFailedHost` in interface `Listener`
Overrides:
  `getFilterForFailedHost` in class `AbstractMastersListener`

### secondaryFail

public abstract HandleErrorResult secondaryFail(Method method, Object[] args, boolean killCmd) throws SQLException

Throws:
  `SQLException`

### foundActiveSecondary

public abstract void foundActiveSecondary(Protocol newSecondaryProtocol) throws SQLException

Throws:
  `SQLException`