public class FailoverConnectionPlugin extends AbstractConnectionPlugin
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String |
closedReason |
static AwsWrapperProperty |
ENABLE_CLUSTER_AWARE_FAILOVER |
protected boolean |
enableFailoverSetting |
protected boolean |
explicitlyAutoCommit |
static AwsWrapperProperty |
FAILOVER_CLUSTER_TOPOLOGY_REFRESH_RATE_MS |
static AwsWrapperProperty |
FAILOVER_READER_CONNECT_TIMEOUT_MS |
static AwsWrapperProperty |
FAILOVER_TIMEOUT_MS |
static AwsWrapperProperty |
FAILOVER_WRITER_RECONNECT_INTERVAL_MS |
protected int |
failoverClusterTopologyRefreshRateMsSetting |
protected int |
failoverReaderConnectTimeoutMsSetting |
protected int |
failoverTimeoutMsSetting |
protected int |
failoverWriterReconnectIntervalMsSetting |
protected boolean |
isClosed |
protected java.util.Properties |
properties |
protected ReaderFailoverHandler |
readerFailoverHandler |
protected WriterFailoverHandler |
writerFailoverHandler |
| Constructor and Description |
|---|
FailoverConnectionPlugin(PluginService pluginService,
java.util.Properties properties) |
| Modifier and Type | Method and Description |
|---|---|
java.sql.Connection |
connect(java.lang.String driverProtocol,
HostSpec hostSpec,
java.util.Properties props,
boolean isInitialConnection,
JdbcCallable<java.sql.Connection,java.sql.SQLException> connectFunc) |
protected java.sql.Connection |
createConnectionForHost(HostSpec baseHostSpec)
Creates a new physical connection for the given
HostSpec. |
protected <E extends java.lang.Exception> |
dealWithIllegalStateException(java.lang.IllegalStateException e,
java.lang.Class<E> exceptionClass) |
<T,E extends java.lang.Exception> |
execute(java.lang.Class<T> resultClass,
java.lang.Class<E> exceptionClass,
java.lang.Object methodInvokeOn,
java.lang.String methodName,
JdbcCallable<T,E> jdbcMethodFunc,
java.lang.Object[] jdbcMethodArgs) |
protected void |
failover(HostSpec failedHost)
Initiates the failover procedure.
|
protected void |
failoverReader(HostSpec failedHostSpec) |
protected void |
failoverWriter() |
java.util.Set<java.lang.String> |
getSubscribedMethods() |
void |
initHostProvider(java.lang.String driverProtocol,
java.lang.String initialUrl,
java.util.Properties props,
HostListProviderService hostListProviderService,
JdbcCallable<java.lang.Void,java.sql.SQLException> initHostProviderFunc) |
protected void |
invalidateCurrentConnection() |
boolean |
isFailoverEnabled() |
OldConnectionSuggestedAction |
notifyConnectionChanged(java.util.EnumSet<NodeChangeOptions> changes) |
void |
notifyNodeListChanged(java.util.Map<java.lang.String,java.util.EnumSet<NodeChangeOptions>> changes) |
protected void |
pickNewConnection() |
protected boolean |
shouldExceptionTriggerConnectionSwitch(java.lang.Throwable t) |
protected void |
transferSessionState(java.sql.Connection from,
java.sql.Connection to,
boolean readOnly)
Transfers basic session state from one connection to another.
|
protected void |
updateTopology(boolean forceUpdate) |
protected final java.util.Properties properties
protected boolean enableFailoverSetting
protected int failoverTimeoutMsSetting
protected int failoverClusterTopologyRefreshRateMsSetting
protected int failoverWriterReconnectIntervalMsSetting
protected int failoverReaderConnectTimeoutMsSetting
protected boolean explicitlyAutoCommit
protected boolean isClosed
protected java.lang.String closedReason
protected WriterFailoverHandler writerFailoverHandler
protected ReaderFailoverHandler readerFailoverHandler
public static final AwsWrapperProperty FAILOVER_CLUSTER_TOPOLOGY_REFRESH_RATE_MS
public static final AwsWrapperProperty FAILOVER_TIMEOUT_MS
public static final AwsWrapperProperty FAILOVER_WRITER_RECONNECT_INTERVAL_MS
public static final AwsWrapperProperty FAILOVER_READER_CONNECT_TIMEOUT_MS
public static final AwsWrapperProperty ENABLE_CLUSTER_AWARE_FAILOVER
public FailoverConnectionPlugin(PluginService pluginService, java.util.Properties properties)
public java.util.Set<java.lang.String> getSubscribedMethods()
getSubscribedMethods in interface ConnectionPlugingetSubscribedMethods in class AbstractConnectionPluginpublic <T,E extends java.lang.Exception> T execute(java.lang.Class<T> resultClass,
java.lang.Class<E> exceptionClass,
java.lang.Object methodInvokeOn,
java.lang.String methodName,
JdbcCallable<T,E> jdbcMethodFunc,
java.lang.Object[] jdbcMethodArgs)
throws E extends java.lang.Exception
execute in interface ConnectionPluginexecute in class AbstractConnectionPluginE extends java.lang.Exceptionpublic void initHostProvider(java.lang.String driverProtocol,
java.lang.String initialUrl,
java.util.Properties props,
HostListProviderService hostListProviderService,
JdbcCallable<java.lang.Void,java.sql.SQLException> initHostProviderFunc)
throws java.sql.SQLException
initHostProvider in interface ConnectionPlugininitHostProvider in class AbstractConnectionPluginjava.sql.SQLExceptionpublic OldConnectionSuggestedAction notifyConnectionChanged(java.util.EnumSet<NodeChangeOptions> changes)
notifyConnectionChanged in interface ConnectionPluginnotifyConnectionChanged in class AbstractConnectionPluginpublic void notifyNodeListChanged(java.util.Map<java.lang.String,java.util.EnumSet<NodeChangeOptions>> changes)
notifyNodeListChanged in interface ConnectionPluginnotifyNodeListChanged in class AbstractConnectionPluginpublic boolean isFailoverEnabled()
protected void updateTopology(boolean forceUpdate)
throws java.sql.SQLException
java.sql.SQLExceptionprotected void transferSessionState(java.sql.Connection from,
java.sql.Connection to,
boolean readOnly)
throws java.sql.SQLException
from - The connection to transfer state fromto - The connection to transfer state toreadOnly - The desired read-only statejava.sql.SQLException - if a database access error occurs, this method is called on a closed connection or this method
is called during a transactionprotected java.sql.Connection createConnectionForHost(HostSpec baseHostSpec) throws java.sql.SQLException
HostSpec.baseHostSpec - The host info instance to base the connection off of.java.sql.SQLException - if an error occursprotected <E extends java.lang.Exception> void dealWithIllegalStateException(java.lang.IllegalStateException e,
java.lang.Class<E> exceptionClass)
throws E extends java.lang.Exception
E extends java.lang.Exceptionprotected void failover(HostSpec failedHost) throws java.sql.SQLException
failedHost - The host with network errors.java.sql.SQLException - if an error occursprotected void failoverReader(HostSpec failedHostSpec) throws java.sql.SQLException
java.sql.SQLExceptionprotected void failoverWriter()
throws java.sql.SQLException
java.sql.SQLExceptionprotected void invalidateCurrentConnection()
protected void pickNewConnection()
throws java.sql.SQLException
java.sql.SQLExceptionprotected boolean shouldExceptionTriggerConnectionSwitch(java.lang.Throwable t)
public java.sql.Connection connect(java.lang.String driverProtocol,
HostSpec hostSpec,
java.util.Properties props,
boolean isInitialConnection,
JdbcCallable<java.sql.Connection,java.sql.SQLException> connectFunc)
throws java.sql.SQLException
connect in interface ConnectionPluginconnect in class AbstractConnectionPluginjava.sql.SQLException