Package org.mariadb.jdbc.client
Class MultiPrimaryClient
- java.lang.Object
-
- org.mariadb.jdbc.client.MultiPrimaryClient
-
- All Implemented Interfaces:
java.lang.AutoCloseable
,Client
- Direct Known Subclasses:
MultiPrimaryReplicaClient
public class MultiPrimaryClient extends java.lang.Object implements 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 boolean
closed
protected Configuration
conf
protected Client
currentClient
protected long
deniedListTimeout
protected static java.util.concurrent.ConcurrentMap<HostAddress,java.lang.Long>
denyList
protected java.util.concurrent.locks.ReentrantLock
lock
private static Logger
logger
-
Constructor Summary
Constructors Constructor Description MultiPrimaryClient(Configuration conf, java.util.concurrent.locks.ReentrantLock lock)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
abort(java.util.concurrent.Executor executor)
void
close()
void
closePrepare(PrepareResultPacket prepare)
protected Client
connectHost(boolean readOnly, boolean failFast)
Trying connecting server.java.util.List<Completion>
execute(ClientMessage message)
java.util.List<Completion>
execute(ClientMessage message, Statement stmt)
java.util.List<Completion>
execute(ClientMessage message, Statement stmt, int fetchSize, long maxRows, int resultSetConcurrency, int resultSetType, boolean closeOnCompletion)
java.util.List<Completion>
executePipeline(ClientMessage[] messages, Statement stmt, int fetchSize, long maxRows, int resultSetConcurrency, int resultSetType, boolean closeOnCompletion)
protected void
executeTransactionReplay(Client oldCli)
Context
getContext()
ExceptionFactory
getExceptionFactory()
HostAddress
getHostAddress()
int
getSocketTimeout()
int
getWaitTimeout()
boolean
isClosed()
boolean
isPrimary()
void
readStreamingResults(java.util.List<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(Client oldCli)
-
-
-
Field Detail
-
logger
private static final Logger logger
-
denyList
protected static final java.util.concurrent.ConcurrentMap<HostAddress,java.lang.Long> denyList
-
deniedListTimeout
protected final long deniedListTimeout
-
conf
protected final Configuration conf
-
closed
protected boolean closed
-
lock
protected final java.util.concurrent.locks.ReentrantLock lock
-
currentClient
protected Client currentClient
-
-
Constructor Detail
-
MultiPrimaryClient
public MultiPrimaryClient(Configuration conf, java.util.concurrent.locks.ReentrantLock lock) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
-
Method Detail
-
connectHost
protected Client connectHost(boolean readOnly, boolean failFast) throws java.sql.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 / primaryfailFast
- must try only not denyed server- Returns:
- a valid connection client
- Throws:
java.sql.SQLException
- if not succeed to create a connection.
-
reConnect
protected void reConnect() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
executeTransactionReplay
protected void executeTransactionReplay(Client oldCli) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
syncNewState
public void syncNewState(Client oldCli) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
execute
public java.util.List<Completion> execute(ClientMessage message) throws java.sql.SQLException
-
execute
public java.util.List<Completion> execute(ClientMessage message, Statement stmt) throws java.sql.SQLException
-
execute
public java.util.List<Completion> execute(ClientMessage message, Statement stmt, int fetchSize, long maxRows, int resultSetConcurrency, int resultSetType, boolean closeOnCompletion) throws java.sql.SQLException
-
executePipeline
public java.util.List<Completion> executePipeline(ClientMessage[] messages, Statement stmt, int fetchSize, long maxRows, int resultSetConcurrency, int resultSetType, boolean closeOnCompletion) throws java.sql.SQLException
- Specified by:
executePipeline
in interfaceClient
- Throws:
java.sql.SQLException
-
readStreamingResults
public void readStreamingResults(java.util.List<Completion> completions, int fetchSize, long maxRows, int resultSetConcurrency, int resultSetType, boolean closeOnCompletion) throws java.sql.SQLException
- Specified by:
readStreamingResults
in interfaceClient
- Throws:
java.sql.SQLException
-
closePrepare
public void closePrepare(PrepareResultPacket prepare) throws java.sql.SQLException
- Specified by:
closePrepare
in interfaceClient
- Throws:
java.sql.SQLException
-
abort
public void abort(java.util.concurrent.Executor executor) throws java.sql.SQLException
-
close
public void close() throws java.sql.SQLException
-
setReadOnly
public void setReadOnly(boolean readOnly) throws java.sql.SQLException
- Specified by:
setReadOnly
in interfaceClient
- Throws:
java.sql.SQLException
-
getSocketTimeout
public int getSocketTimeout()
- Specified by:
getSocketTimeout
in interfaceClient
-
setSocketTimeout
public void setSocketTimeout(int milliseconds) throws java.sql.SQLException
- Specified by:
setSocketTimeout
in interfaceClient
- Throws:
java.sql.SQLException
-
getWaitTimeout
public int getWaitTimeout()
- Specified by:
getWaitTimeout
in interfaceClient
-
getContext
public Context getContext()
- Specified by:
getContext
in interfaceClient
-
getExceptionFactory
public ExceptionFactory getExceptionFactory()
- Specified by:
getExceptionFactory
in interfaceClient
-
getHostAddress
public HostAddress getHostAddress()
- Specified by:
getHostAddress
in interfaceClient
-
-