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 Modifier and Type Field Description protected booleanclosedprotected Configurationconfprotected org.mariadb.jdbc.client.ClientcurrentClientprotected longdeniedListTimeoutprotected static ConcurrentMap<HostAddress,Long>denyListprotected ReentrantLocklock
-
Constructor Summary
Constructors Constructor Description MultiPrimaryClient(Configuration conf, ReentrantLock lock)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidabort(Executor executor)voidclose()voidclosePrepare(Prepare prepare)protected org.mariadb.jdbc.client.ClientconnectHost(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 voidexecuteTransactionReplay(org.mariadb.jdbc.client.Client oldCli)org.mariadb.jdbc.client.ContextgetContext()ExceptionFactorygetExceptionFactory()HostAddressgetHostAddress()intgetSocketTimeout()intgetWaitTimeout()booleanisClosed()booleanisPrimary()voidreadStreamingResults(List<org.mariadb.jdbc.client.Completion> completions, int fetchSize, long maxRows, int resultSetConcurrency, int resultSetType, boolean closeOnCompletion)protected voidreConnect()voidreset()voidsetReadOnly(boolean readOnly)voidsetSocketTimeout(int milliseconds)voidsyncNewState(org.mariadb.jdbc.client.Client oldCli)
-
-
-
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 SQLExceptionTrying 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 / primaryfailFast- 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:
executein interfaceorg.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:
executein interfaceorg.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:
executein interfaceorg.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:
executePipelinein interfaceorg.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:
readStreamingResultsin interfaceorg.mariadb.jdbc.client.Client- Throws:
SQLException
-
closePrepare
public void closePrepare(Prepare prepare) throws SQLException
- Specified by:
closePreparein interfaceorg.mariadb.jdbc.client.Client- Throws:
SQLException
-
abort
public void abort(Executor executor) throws SQLException
- Specified by:
abortin interfaceorg.mariadb.jdbc.client.Client- Throws:
SQLException
-
close
public void close() throws SQLException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceorg.mariadb.jdbc.client.Client- Throws:
SQLException
-
setReadOnly
public void setReadOnly(boolean readOnly) throws SQLException- Specified by:
setReadOnlyin interfaceorg.mariadb.jdbc.client.Client- Throws:
SQLException
-
getSocketTimeout
public int getSocketTimeout()
- Specified by:
getSocketTimeoutin interfaceorg.mariadb.jdbc.client.Client
-
setSocketTimeout
public void setSocketTimeout(int milliseconds) throws SQLException- Specified by:
setSocketTimeoutin interfaceorg.mariadb.jdbc.client.Client- Throws:
SQLException
-
getWaitTimeout
public int getWaitTimeout()
- Specified by:
getWaitTimeoutin interfaceorg.mariadb.jdbc.client.Client
-
isClosed
public boolean isClosed()
- Specified by:
isClosedin interfaceorg.mariadb.jdbc.client.Client
-
getContext
public org.mariadb.jdbc.client.Context getContext()
- Specified by:
getContextin interfaceorg.mariadb.jdbc.client.Client
-
getExceptionFactory
public ExceptionFactory getExceptionFactory()
- Specified by:
getExceptionFactoryin interfaceorg.mariadb.jdbc.client.Client
-
getHostAddress
public HostAddress getHostAddress()
- Specified by:
getHostAddressin interfaceorg.mariadb.jdbc.client.Client
-
isPrimary
public boolean isPrimary()
- Specified by:
isPrimaryin interfaceorg.mariadb.jdbc.client.Client
-
reset
public void reset()
- Specified by:
resetin interfaceorg.mariadb.jdbc.client.Client
-
-