org.mariadb.jdbc.internal.protocol

## Class MastersSlavesProtocol

- java.lang.Object
- - org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol
  - - org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol
    - - org.mariadb.jdbc.internal.protocol.MasterProtocol
      - - org.mariadb.jdbc.internal.protocol.MastersSlavesProtocol

All Implemented Interfaces:
  Protocol

Direct Known Subclasses:
  AuroraProtocol

    public class MastersSlavesProtocol
    extends MasterProtocol

### Field Summary

### Fields inherited from class org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol

`activeResult, charset, connected, currentHost, database, dataTypeMappingFlags, explicitClosed, hasWarnings, lock, moreResults, packetFetcher, prepareStatementCache, proxy, readOnly, serverStatus, serverThreadId, socket, urlParser, writer`

### Constructor Summary

Constructors
Constructor and Description
`MastersSlavesProtocol(UrlParser url, ReentrantLock lock)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`protected static boolean` `foundMaster(MastersSlavesListener listener, MastersSlavesProtocol protocol, SearchFilter searchFilter)`
`protected static boolean` `foundSecondary(MastersSlavesListener listener, MastersSlavesProtocol protocol, SearchFilter searchFilter)`
`static MastersSlavesProtocol` `getNewProtocol(FailoverProxy proxy, UrlParser urlParser)` Get new instance of MastersSlavesProtocol.
`static void` `loop(MastersSlavesListener listener, List<HostAddress> addresses, SearchFilter searchFilter)` loop until found the failed connection.
`boolean` `mustBeMasterConnection()`
`void` `setMustBeMasterConnection(boolean mustBeMasterConnection)`

### Methods inherited from class org.mariadb.jdbc.internal.protocol.MasterProtocol

`loop`

### Methods inherited from class org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol

`cancelCurrentQuery, closeExplicit, closeIfActiveResult, closePreparedStatement, executeBatch, executePreparedQuery, executePreparedQueryAfterFailover, executeQuery, executeQuery, executeQuery, getAutocommit, getMaxRows, getMoreResults, getResult, getTimeout, getTransactionIsolationLevel, hasMoreResults, hasUnreadData, hexdump, hexdump, inTransaction, ping, prepare, prepareStatementCache, releasePrepareStatement, rollback, setCatalog, setInternalMaxRows, setLocalInfileInputStream, setMaxRows, setTimeout, setTransactionIsolation`

### Methods inherited from class org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol

`checkIfMaster, close, close, connect, connectWithoutProxy, getCalendar, getDatabase, getDataTypeMappingFlags, getHost, getHostAddress, getMajorServerVersion, getMinorServerVersion, getOptions, getPassword, getPinGlobalTxToPhysicalConnection, getPort, getProxy, getReadonly, getServerData, getServerThreadId, getServerVersion, getUrlParser, getUsername, hasWarnings, isClosed, isConnected, isExplicitClosed, isMasterConnection, noBackslashEscapes, readEofPacket, setHostAddress, setHostFailedWithoutProxy, setProxy, setReadonly, shouldReconnectWithoutProxy, versionGreaterOrEqual`

### Methods inherited from class java.lang.Object

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

### Methods inherited from interface org.mariadb.jdbc.internal.protocol.Protocol

`checkIfMaster, close, connect, connectWithoutProxy, getCalendar, getDatabase, getDataTypeMappingFlags, getHost, getHostAddress, getMajorServerVersion, getMinorServerVersion, getOptions, getPassword, getPinGlobalTxToPhysicalConnection, getPort, getProxy, getReadonly, getServerData, getServerThreadId, getServerVersion, getUrlParser, getUsername, hasWarnings, isClosed, isConnected, isExplicitClosed, isMasterConnection, noBackslashEscapes, setHostAddress, setHostFailedWithoutProxy, setProxy, setReadonly, shouldReconnectWithoutProxy, versionGreaterOrEqual`

### Constructor Detail

#### MastersSlavesProtocol

    public MastersSlavesProtocol(UrlParser url,
                                 ReentrantLock lock)

### Method Detail

#### loop

    public static void loop(MastersSlavesListener listener,
                            List<HostAddress> addresses,
                            SearchFilter searchFilter)
                     throws QueryException

loop until found the failed connection.

Parameters:
  `listener` - current failover
  `addresses` - list of HostAddress to loop
  `searchFilter` - search parameter
Throws:
  `QueryException` - if not found

#### foundMaster

    protected static boolean foundMaster(MastersSlavesListener listener,
                                         MastersSlavesProtocol protocol,
                                         SearchFilter searchFilter)

#### foundSecondary

    protected static boolean foundSecondary(MastersSlavesListener listener,
                                            MastersSlavesProtocol protocol,
                                            SearchFilter searchFilter)
                                     throws QueryException

Throws:
  `QueryException`

#### getNewProtocol

    public static MastersSlavesProtocol getNewProtocol(FailoverProxy proxy,
                                                       UrlParser urlParser)

Get new instance of MastersSlavesProtocol.

Parameters:
  `proxy` - proxy
  `urlParser` - connection string Object.
Returns:
  a new MastersSlavesProtocol instance

#### mustBeMasterConnection

    public boolean mustBeMasterConnection()

Specified by:
  `mustBeMasterConnection` in interface `Protocol`
Overrides:
  `mustBeMasterConnection` in class `AbstractConnectProtocol`

#### setMustBeMasterConnection

    public void setMustBeMasterConnection(boolean mustBeMasterConnection)