Class 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 Detail

      • deniedListTimeout

        protected final long deniedListTimeout
      • closed

        protected boolean closed
      • currentClient

        protected org.mariadb.jdbc.client.Client currentClient
    • 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.
      • 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
      • 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