Package org.mariadb.jdbc.client
Class MultiPrimaryClient
java.lang.Object
org.mariadb.jdbc.client.MultiPrimaryClient
- All Implemented Interfaces:
AutoCloseable
,Client
- Direct Known Subclasses:
MultiPrimaryReplicaClient
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
FieldsModifier and TypeFieldDescriptionprotected boolean
protected final Configuration
protected Client
protected final long
protected static final ConcurrentMap<HostAddress,
Long> protected final ReentrantLock
private static final Logger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
close()
void
closePrepare
(PrepareResultPacket prepare) protected Client
connectHost
(boolean readOnly, boolean failFast) Trying connecting server.execute
(ClientMessage message) execute
(ClientMessage message, Statement stmt) execute
(ClientMessage message, Statement stmt, int fetchSize, long maxRows, int resultSetConcurrency, int resultSetType, boolean closeOnCompletion) executePipeline
(ClientMessage[] messages, Statement stmt, int fetchSize, long maxRows, int resultSetConcurrency, int resultSetType, boolean closeOnCompletion) protected void
executeTransactionReplay
(Client oldCli) int
int
boolean
isClosed()
boolean
void
readStreamingResults
(List<Completion> completions, int fetchSize, long maxRows, int resultSetConcurrency, int resultSetType, boolean closeOnCompletion) protected void
void
reset()
void
setReadOnly
(boolean readOnly) void
setSocketTimeout
(int milliseconds) void
syncNewState
(Client oldCli)
-
Field Details
-
logger
-
denyList
-
deniedListTimeout
protected final long deniedListTimeout -
conf
-
closed
protected boolean closed -
lock
-
currentClient
-
-
Constructor Details
-
MultiPrimaryClient
- Throws:
SQLException
-
-
Method Details
-
connectHost
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:
SQLException
- if not succeed to create a connection.
-
reConnect
- Throws:
SQLException
-
executeTransactionReplay
- Throws:
SQLException
-
syncNewState
- Throws:
SQLException
-
execute
- Specified by:
execute
in interfaceClient
- Throws:
SQLException
-
execute
- Specified by:
execute
in interfaceClient
- Throws:
SQLException
-
execute
public List<Completion> execute(ClientMessage message, Statement stmt, int fetchSize, long maxRows, int resultSetConcurrency, int resultSetType, boolean closeOnCompletion) throws SQLException - Specified by:
execute
in interfaceClient
- Throws:
SQLException
-
executePipeline
public List<Completion> executePipeline(ClientMessage[] messages, Statement stmt, int fetchSize, long maxRows, int resultSetConcurrency, int resultSetType, boolean closeOnCompletion) throws SQLException - Specified by:
executePipeline
in interfaceClient
- Throws:
SQLException
-
readStreamingResults
public void readStreamingResults(List<Completion> completions, int fetchSize, long maxRows, int resultSetConcurrency, int resultSetType, boolean closeOnCompletion) throws SQLException - Specified by:
readStreamingResults
in interfaceClient
- Throws:
SQLException
-
closePrepare
- Specified by:
closePrepare
in interfaceClient
- Throws:
SQLException
-
abort
- Specified by:
abort
in interfaceClient
- Throws:
SQLException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceClient
- Throws:
SQLException
-
setReadOnly
- Specified by:
setReadOnly
in interfaceClient
- Throws:
SQLException
-
getSocketTimeout
public int getSocketTimeout()- Specified by:
getSocketTimeout
in interfaceClient
-
setSocketTimeout
- Specified by:
setSocketTimeout
in interfaceClient
- Throws:
SQLException
-
getWaitTimeout
public int getWaitTimeout()- Specified by:
getWaitTimeout
in interfaceClient
-
isClosed
public boolean isClosed() -
getContext
- Specified by:
getContext
in interfaceClient
-
getExceptionFactory
- Specified by:
getExceptionFactory
in interfaceClient
-
getHostAddress
- Specified by:
getHostAddress
in interfaceClient
-
isPrimary
public boolean isPrimary() -
reset
public void reset()
-