public class FailoverClient extends Object implements com.singlestore.jdbc.client.Client
remark: would have been better using proxy, but for AOT compilation, avoiding to using not supported proxy class.
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
closed
is connections explicitly closed
|
protected Configuration |
conf
configuration
|
protected com.singlestore.jdbc.client.Client |
currentClient
current client
|
protected long |
deniedListTimeout
denied timeout
|
protected static ConcurrentMap<HostAddress,Long> |
denyList
temporary blacklisted hosts
|
protected ClosableLock |
lock
thread locker
|
| Constructor and Description |
|---|
FailoverClient(Configuration conf,
ClosableLock lock)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
abort(Executor executor)
Abort current connection
|
void |
close()
Close client
|
void |
closePrepare(Prepare prepare)
Close prepare command
|
protected com.singlestore.jdbc.client.Client |
connectHost()
Trying connecting server.
|
List<com.singlestore.jdbc.client.Completion> |
execute(com.singlestore.jdbc.message.ClientMessage message,
boolean canRedo)
Send client message and read result
|
List<com.singlestore.jdbc.client.Completion> |
execute(com.singlestore.jdbc.message.ClientMessage message,
Statement stmt,
boolean canRedo)
Send client message and read result
|
List<com.singlestore.jdbc.client.Completion> |
execute(com.singlestore.jdbc.message.ClientMessage message,
Statement stmt,
int fetchSize,
long maxRows,
int resultSetConcurrency,
int resultSetType,
boolean closeOnCompletion,
boolean canRedo)
Send client message and read result
|
List<com.singlestore.jdbc.client.Completion> |
executePipeline(com.singlestore.jdbc.message.ClientMessage[] messages,
Statement stmt,
int fetchSize,
long maxRows,
int resultSetConcurrency,
int resultSetType,
boolean closeOnCompletion,
boolean canRedo)
Send client messages pipelining and read result
|
protected void |
executeTransactionReplay(com.singlestore.jdbc.client.Client oldCli)
Execute transaction replay
|
BigInteger |
getAggregatorId()
Get aggregator id
|
com.singlestore.jdbc.client.Context |
getContext()
Get connection context
|
ExceptionFactory |
getExceptionFactory()
Get connection exception factory
|
HostAddress |
getHostAddress()
Get connection host
|
BigInteger |
getInitialSqlSelectLimit()
Get the maximum number of rows returned by a SELECT query.
|
com.singlestore.jdbc.util.Version |
getSingleStoreVersion()
Get SingleStore version.
|
String |
getSocketIp()
Get current socket IP or null (for Pipe / unix socket)
|
int |
getSocketTimeout()
get socket timeout
|
boolean |
isClosed()
Is client closed
|
boolean |
isPrimary() |
void |
readStreamingResults(List<com.singlestore.jdbc.client.Completion> completions,
int fetchSize,
long maxRows,
int resultSetConcurrency,
int resultSetType,
boolean closeOnCompletion)
Read results
|
protected com.singlestore.jdbc.client.Client |
reConnect()
Connection loop
|
protected void |
replayIfPossible(com.singlestore.jdbc.client.Client oldClient,
boolean canRedo,
SQLException cause)
Execute transaction replay if in transaction and configured for it, throw an exception if not
|
void |
reset()
Reset connection
|
void |
setReadOnly(boolean readOnly)
Switch to a writer/read-only connection, no effet on mono-connection
|
void |
setSocketTimeout(int milliseconds)
Set socket timeout
|
void |
syncNewState(com.singlestore.jdbc.client.Client oldCli)
Synchronized previous and new client states.
|
protected static final ConcurrentMap<HostAddress,Long> denyList
protected final long deniedListTimeout
protected final Configuration conf
protected boolean closed
protected final ClosableLock lock
protected com.singlestore.jdbc.client.Client currentClient
public FailoverClient(Configuration conf, ClosableLock lock) throws SQLException
conf - configurationlock - thread lockerSQLException - if fail to connectprotected com.singlestore.jdbc.client.Client connectHost()
throws SQLException
searching each connecting primary / replica connection not temporary denied until found one. searching in temporary denied host if not succeed, until reaching `retriesAllDown` attempts.
SQLException - if not succeed to create a connection.protected com.singlestore.jdbc.client.Client reConnect()
throws SQLException
SQLException - if fail to connectprotected void replayIfPossible(com.singlestore.jdbc.client.Client oldClient,
boolean canRedo,
SQLException cause)
throws SQLException
oldClient - previous clientcanRedo - if command can be redo even if not in transactionSQLException - if not able to replayprotected void executeTransactionReplay(com.singlestore.jdbc.client.Client oldCli)
throws SQLException
oldCli - previous clientSQLException - if not able to replaypublic void syncNewState(com.singlestore.jdbc.client.Client oldCli)
throws SQLException
oldCli - previous clientSQLException - if error occurspublic List<com.singlestore.jdbc.client.Completion> execute(com.singlestore.jdbc.message.ClientMessage message, boolean canRedo) throws SQLException
com.singlestore.jdbc.client.Clientexecute in interface com.singlestore.jdbc.client.Clientmessage - client messagecanRedo - can client message be redone in case of failoverSQLException - if execution failspublic List<com.singlestore.jdbc.client.Completion> execute(com.singlestore.jdbc.message.ClientMessage message, Statement stmt, boolean canRedo) throws SQLException
com.singlestore.jdbc.client.Clientexecute in interface com.singlestore.jdbc.client.Clientmessage - client messagestmt - statementcanRedo - can client message be redone in case of failoverSQLException - if execution failspublic List<com.singlestore.jdbc.client.Completion> execute(com.singlestore.jdbc.message.ClientMessage message, Statement stmt, int fetchSize, long maxRows, int resultSetConcurrency, int resultSetType, boolean closeOnCompletion, boolean canRedo) throws SQLException
com.singlestore.jdbc.client.Clientexecute in interface com.singlestore.jdbc.client.Clientmessage - client messagestmt - statementfetchSize - fetch sizemaxRows - maximum number of rows. 0 = allresultSetConcurrency - concurrencyresultSetType - result-set typecloseOnCompletion - close statement on completioncanRedo - can client message be redone in case of failoverSQLException - if any error occurspublic List<com.singlestore.jdbc.client.Completion> executePipeline(com.singlestore.jdbc.message.ClientMessage[] messages, Statement stmt, int fetchSize, long maxRows, int resultSetConcurrency, int resultSetType, boolean closeOnCompletion, boolean canRedo) throws SQLException
com.singlestore.jdbc.client.ClientexecutePipeline in interface com.singlestore.jdbc.client.Clientmessages - client messagestmt - statementfetchSize - fetch sizemaxRows - maximum number of rows. 0 = allresultSetConcurrency - concurrencyresultSetType - result-set typecloseOnCompletion - close statement on completioncanRedo - can client message be redone in case of failoverSQLException - if any error occurspublic void readStreamingResults(List<com.singlestore.jdbc.client.Completion> completions, int fetchSize, long maxRows, int resultSetConcurrency, int resultSetType, boolean closeOnCompletion) throws SQLException
com.singlestore.jdbc.client.ClientreadStreamingResults in interface com.singlestore.jdbc.client.Clientcompletions - List that will have the new resultsfetchSize - fetch sizemaxRows - maximum number of rows. 0 = allresultSetConcurrency - concurrencyresultSetType - result-set typecloseOnCompletion - close statement on completionSQLException - if any error occurspublic void closePrepare(Prepare prepare) throws SQLException
com.singlestore.jdbc.client.ClientclosePrepare in interface com.singlestore.jdbc.client.Clientprepare - prepare commandSQLException - if any error occurspublic void abort(Executor executor) throws SQLException
com.singlestore.jdbc.client.Clientabort in interface com.singlestore.jdbc.client.Clientexecutor - executorSQLException - if any error occurspublic void close()
throws SQLException
com.singlestore.jdbc.client.Clientclose in interface com.singlestore.jdbc.client.Clientclose in interface AutoCloseableSQLException - if any error occurspublic void setReadOnly(boolean readOnly)
throws SQLException
com.singlestore.jdbc.client.ClientsetReadOnly in interface com.singlestore.jdbc.client.ClientreadOnly - must use read-only connectionSQLException - if any error occurspublic int getSocketTimeout()
com.singlestore.jdbc.client.ClientgetSocketTimeout in interface com.singlestore.jdbc.client.Clientpublic void setSocketTimeout(int milliseconds)
throws SQLException
com.singlestore.jdbc.client.ClientsetSocketTimeout in interface com.singlestore.jdbc.client.Clientmilliseconds - timeoutSQLException - if any error occurspublic boolean isClosed()
com.singlestore.jdbc.client.ClientisClosed in interface com.singlestore.jdbc.client.Clientpublic com.singlestore.jdbc.client.Context getContext()
com.singlestore.jdbc.client.ClientgetContext in interface com.singlestore.jdbc.client.Clientpublic ExceptionFactory getExceptionFactory()
com.singlestore.jdbc.client.ClientgetExceptionFactory in interface com.singlestore.jdbc.client.Clientpublic HostAddress getHostAddress()
com.singlestore.jdbc.client.ClientgetHostAddress in interface com.singlestore.jdbc.client.Clientpublic String getSocketIp()
com.singlestore.jdbc.client.ClientgetSocketIp in interface com.singlestore.jdbc.client.Clientpublic BigInteger getAggregatorId()
com.singlestore.jdbc.client.ClientgetAggregatorId in interface com.singlestore.jdbc.client.Clientpublic BigInteger getInitialSqlSelectLimit()
com.singlestore.jdbc.client.ClientgetInitialSqlSelectLimit in interface com.singlestore.jdbc.client.Clientpublic com.singlestore.jdbc.util.Version getSingleStoreVersion()
com.singlestore.jdbc.client.ClientgetSingleStoreVersion in interface com.singlestore.jdbc.client.Clientpublic boolean isPrimary()
public void reset()
com.singlestore.jdbc.client.Clientreset in interface com.singlestore.jdbc.client.ClientCopyright © 2025 SingleStore. All rights reserved.