Package org.mariadb.jdbc.client.impl

## Class MultiPrimaryClient

- java.lang.Object
- - org.mariadb.jdbc.client.impl.MultiPrimaryClient

All Implemented Interfaces:
  `AutoCloseable`, `org.mariadb.jdbc.client.Client`

Direct Known Subclasses:
  `MultiPrimaryReplicaClient`

    public class MultiPrimaryClient
    extends Object
    implements org.mariadb.jdbc.client.Client

Handling connection failing automatic reconnection transparently when possible for multi-master Topology.

remark: would have been better using proxy, but for AOT compilation, avoiding to using not supported proxy class.

### Field Summary

Fields
`protected boolean` `closed`
`protected Configuration` `conf`
`protected org.mariadb.jdbc.client.Client` `currentClient`
`protected long` `deniedListTimeout`
`protected static ConcurrentMap<HostAddress,​Long>` `denyList`
`protected ReentrantLock` `lock`

### Constructor Summary

Constructors
`MultiPrimaryClient​(Configuration conf, ReentrantLock lock)`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `abort​(Executor executor)`
`void` `close()`
`void` `closePrepare​(Prepare prepare)`
`protected org.mariadb.jdbc.client.Client` `connectHost​(boolean readOnly, boolean failFast)` Trying connecting server.
`List<org.mariadb.jdbc.client.Completion>` `execute​(org.mariadb.jdbc.message.ClientMessage message)`
`List<org.mariadb.jdbc.client.Completion>` `execute​(org.mariadb.jdbc.message.ClientMessage message, Statement stmt)`
`List<org.mariadb.jdbc.client.Completion>` `execute​(org.mariadb.jdbc.message.ClientMessage message, Statement stmt, int fetchSize, long maxRows, int resultSetConcurrency, int resultSetType, boolean closeOnCompletion)`
`List<org.mariadb.jdbc.client.Completion>` `executePipeline​(org.mariadb.jdbc.message.ClientMessage[] messages, Statement stmt, int fetchSize, long maxRows, int resultSetConcurrency, int resultSetType, boolean closeOnCompletion)`
`protected void` `executeTransactionReplay​(org.mariadb.jdbc.client.Client oldCli)`
`org.mariadb.jdbc.client.Context` `getContext()`
`ExceptionFactory` `getExceptionFactory()`
`HostAddress` `getHostAddress()`
`int` `getSocketTimeout()`
`int` `getWaitTimeout()`
`boolean` `isClosed()`
`boolean` `isPrimary()`
`void` `readStreamingResults​(List<org.mariadb.jdbc.client.Completion> completions, int fetchSize, long maxRows, int resultSetConcurrency, int resultSetType, boolean closeOnCompletion)`
`protected void` `reConnect()`
`void` `reset()`
`void` `setReadOnly​(boolean readOnly)`
`void` `setSocketTimeout​(int milliseconds)`
`void` `syncNewState​(org.mariadb.jdbc.client.Client oldCli)`

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

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

### Field Detail

#### denyList

    protected static final ConcurrentMap<HostAddress,​Long> denyList

#### deniedListTimeout

    protected final long deniedListTimeout

#### conf

    protected final Configuration conf

#### closed

    protected boolean closed

#### lock

    protected final ReentrantLock lock

#### currentClient

    protected org.mariadb.jdbc.client.Client currentClient

### Constructor Detail

#### MultiPrimaryClient

    public MultiPrimaryClient​(Configuration conf,
                              ReentrantLock lock)
                       throws SQLException

Throws:
  `SQLException`

### Method Detail

#### connectHost

    protected org.mariadb.jdbc.client.Client connectHost​(boolean readOnly,
                                                         boolean failFast)
                                                  throws SQLException

Trying connecting server.

searching each connecting primary / replica connection not temporary denied until found one. searching in temporary denied host if not succeed, until reaching `retriesAllDown` attempts.

Parameters:
  `readOnly` - must connect a replica / primary
  `failFast` - must try only not denyed server
Returns:
  a valid connection client
Throws:
  `SQLException` - if not succeed to create a connection.

#### reConnect

    protected void reConnect()
                      throws SQLException

Throws:
  `SQLException`

#### executeTransactionReplay

    protected void executeTransactionReplay​(org.mariadb.jdbc.client.Client oldCli)
                                     throws SQLException

Throws:
  `SQLException`

#### syncNewState

    public void syncNewState​(org.mariadb.jdbc.client.Client oldCli)
                      throws SQLException

Throws:
  `SQLException`

#### execute

    public List<org.mariadb.jdbc.client.Completion> execute​(org.mariadb.jdbc.message.ClientMessage message)
                                                     throws SQLException

Specified by:
  `execute` in interface `org.mariadb.jdbc.client.Client`
Throws:
  `SQLException`

#### execute

    public List<org.mariadb.jdbc.client.Completion> execute​(org.mariadb.jdbc.message.ClientMessage message,
                                                            Statement stmt)
                                                     throws SQLException

Specified by:
  `execute` in interface `org.mariadb.jdbc.client.Client`
Throws:
  `SQLException`

#### execute

    public List<org.mariadb.jdbc.client.Completion> execute​(org.mariadb.jdbc.message.ClientMessage message,
                                                            Statement stmt,
                                                            int fetchSize,
                                                            long maxRows,
                                                            int resultSetConcurrency,
                                                            int resultSetType,
                                                            boolean closeOnCompletion)
                                                     throws SQLException

Specified by:
  `execute` in interface `org.mariadb.jdbc.client.Client`
Throws:
  `SQLException`

#### executePipeline

    public List<org.mariadb.jdbc.client.Completion> executePipeline​(org.mariadb.jdbc.message.ClientMessage[] messages,
                                                                    Statement stmt,
                                                                    int fetchSize,
                                                                    long maxRows,
                                                                    int resultSetConcurrency,
                                                                    int resultSetType,
                                                                    boolean closeOnCompletion)
                                                             throws SQLException

Specified by:
  `executePipeline` in interface `org.mariadb.jdbc.client.Client`
Throws:
  `SQLException`

#### readStreamingResults

    public void readStreamingResults​(List<org.mariadb.jdbc.client.Completion> completions,
                                     int fetchSize,
                                     long maxRows,
                                     int resultSetConcurrency,
                                     int resultSetType,
                                     boolean closeOnCompletion)
                              throws SQLException

Specified by:
  `readStreamingResults` in interface `org.mariadb.jdbc.client.Client`
Throws:
  `SQLException`

#### closePrepare

    public void closePrepare​(Prepare prepare)
                      throws SQLException

Specified by:
  `closePrepare` in interface `org.mariadb.jdbc.client.Client`
Throws:
  `SQLException`

#### abort

    public void abort​(Executor executor)
               throws SQLException

Specified by:
  `abort` in interface `org.mariadb.jdbc.client.Client`
Throws:
  `SQLException`

#### close

    public void close()
               throws SQLException

Specified by:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `org.mariadb.jdbc.client.Client`
Throws:
  `SQLException`

#### setReadOnly

    public void setReadOnly​(boolean readOnly)
                     throws SQLException

Specified by:
  `setReadOnly` in interface `org.mariadb.jdbc.client.Client`
Throws:
  `SQLException`

#### getSocketTimeout

    public int getSocketTimeout()

Specified by:
  `getSocketTimeout` in interface `org.mariadb.jdbc.client.Client`

#### setSocketTimeout

    public void setSocketTimeout​(int milliseconds)
                          throws SQLException

Specified by:
  `setSocketTimeout` in interface `org.mariadb.jdbc.client.Client`
Throws:
  `SQLException`

#### getWaitTimeout

    public int getWaitTimeout()

Specified by:
  `getWaitTimeout` in interface `org.mariadb.jdbc.client.Client`

#### isClosed

    public boolean isClosed()

Specified by:
  `isClosed` in interface `org.mariadb.jdbc.client.Client`

#### getContext

    public org.mariadb.jdbc.client.Context getContext()

Specified by:
  `getContext` in interface `org.mariadb.jdbc.client.Client`

#### getExceptionFactory

    public ExceptionFactory getExceptionFactory()

Specified by:
  `getExceptionFactory` in interface `org.mariadb.jdbc.client.Client`

#### getHostAddress

    public HostAddress getHostAddress()

Specified by:
  `getHostAddress` in interface `org.mariadb.jdbc.client.Client`

#### isPrimary

    public boolean isPrimary()

Specified by:
  `isPrimary` in interface `org.mariadb.jdbc.client.Client`

#### reset

    public void reset()

Specified by:
  `reset` in interface `org.mariadb.jdbc.client.Client`