public class FailoverConnectionPlugin extends AbstractConnectionPlugin
| Constructor and Description |
|---|
FailoverConnectionPlugin(PluginService pluginService,
java.util.Properties properties) |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
allowedOnClosedConnection(java.lang.String methodName)
Checks if the given method is allowed on closed connections.
|
protected boolean |
canDirectExecute(java.lang.String methodName)
Check whether the method provided can be executed directly without the failover functionality.
|
java.sql.Connection |
connect(java.lang.String driverProtocol,
HostSpec hostSpec,
java.util.Properties props,
boolean isInitialConnection,
JdbcCallable<java.sql.Connection,java.sql.SQLException> connectFunc)
Establishes a connection to the given host using the given driver protocol and properties.
|
protected <E extends java.lang.Exception> |
dealWithIllegalStateException(java.lang.IllegalStateException e,
java.lang.Class<E> exceptionClass) |
protected <E extends java.lang.Exception> |
dealWithOriginalException(java.lang.Throwable originalException,
java.lang.Throwable wrapperException,
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()
Initiates the failover procedure.
|
protected void |
failoverReader() |
protected void |
failoverWriter() |
protected ReaderFailoverResult |
getReaderFailoverConnection(long failoverEndTimeNano) |
java.util.Set<java.lang.String> |
getSubscribedMethods() |
protected void |
initFailoverMode() |
void |
initHostProvider(java.lang.String driverProtocol,
java.lang.String initialUrl,
java.util.Properties properties,
HostListProviderService hostListProviderService,
JdbcCallable<java.lang.Void,java.sql.SQLException> initHostProviderFunc) |
protected void |
invalidateCurrentConnection() |
protected void |
invalidInvocationOnClosedConnection() |
protected boolean |
isFailoverEnabled() |
protected void |
pickNewConnection() |
protected boolean |
shouldExceptionTriggerConnectionSwitch(java.lang.Throwable t) |
protected void |
throwFailoverSuccessException() |
acceptsStrategy, forceConnect, getHostSpecByStrategy, getHostSpecByStrategy, notifyConnectionChanged, notifyNodeListChangedpublic static final AwsWrapperProperty FAILOVER_TIMEOUT_MS
public static final AwsWrapperProperty FAILOVER_MODE
public static final AwsWrapperProperty TELEMETRY_FAILOVER_ADDITIONAL_TOP_TRACE
public static final AwsWrapperProperty FAILOVER_READER_HOST_SELECTOR_STRATEGY
public static final AwsWrapperProperty ENABLE_CONNECT_FAILOVER
public static final AwsWrapperProperty SKIP_FAILOVER_ON_INTERRUPTED_THREAD
protected final PluginService pluginService
protected final java.util.Properties properties
protected int failoverTimeoutMsSetting
protected FailoverMode failoverMode
protected boolean telemetryFailoverAdditionalTopTraceSetting
protected java.lang.String failoverReaderHostSelectorStrategySetting
protected boolean closedExplicitly
protected boolean isClosed
protected final RdsUtils rdsHelper
protected java.lang.Throwable lastExceptionDealtWith
protected PluginManagerService pluginManagerService
protected boolean isInTransaction
protected RdsUrlType rdsUrlType
protected HostListProviderService hostListProviderService
protected final AuroraStaleDnsHelper staleDnsHelper
protected final TelemetryCounter failoverWriterTriggeredCounter
protected final TelemetryCounter failoverWriterSuccessCounter
protected final TelemetryCounter failoverWriterFailedCounter
protected final TelemetryCounter failoverReaderTriggeredCounter
protected final TelemetryCounter failoverReaderSuccessCounter
protected final TelemetryCounter failoverReaderFailedCounter
protected final boolean skipFailoverOnInterruptedThread
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 properties,
HostListProviderService hostListProviderService,
JdbcCallable<java.lang.Void,java.sql.SQLException> initHostProviderFunc)
throws java.sql.SQLException
initHostProvider in interface ConnectionPlugininitHostProvider in class AbstractConnectionPluginjava.sql.SQLExceptionprotected boolean isFailoverEnabled()
protected void invalidInvocationOnClosedConnection()
throws java.sql.SQLException
java.sql.SQLExceptionprotected boolean allowedOnClosedConnection(java.lang.String methodName)
methodName - A method name to check.protected <E extends java.lang.Exception> void dealWithOriginalException(java.lang.Throwable originalException,
java.lang.Throwable wrapperException,
java.lang.Class<E> exceptionClass)
throws E extends java.lang.Exception
E extends java.lang.Exceptionprotected <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()
throws java.sql.SQLException
java.sql.SQLException - if an error occursprotected void failoverReader()
throws java.sql.SQLException
java.sql.SQLExceptionprotected ReaderFailoverResult getReaderFailoverConnection(long failoverEndTimeNano) throws java.util.concurrent.TimeoutException
java.util.concurrent.TimeoutExceptionprotected void throwFailoverSuccessException()
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)
protected boolean canDirectExecute(java.lang.String methodName)
methodName - The name of the method that is being calledprotected void initFailoverMode()
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
ConnectionPluginConnectionProvider has been set with
Driver.setCustomConnectionProvider(ConnectionProvider) and
ConnectionProvider.acceptsUrl(String, HostSpec, Properties) returns true for the given
protocol, host, and properties, the connection will be created by the non-default
ConnectionProvider. Otherwise, the connection will be created by the default
ConnectionProvider. The default ConnectionProvider will be DriverConnectionProvider for
connections requested via the DriverManager and
DataSourceConnectionProvider for connections requested via an
AwsWrapperDataSource.connect in interface ConnectionPluginconnect in class AbstractConnectionPlugindriverProtocol - the driver protocol that should be used to establish the connectionhostSpec - the host details for the desired connectionprops - the connection propertiesisInitialConnection - a boolean indicating whether the current Connection is
establishing an initial physical connection to the database or has
already established a physical connection in the pastconnectFunc - the function to call to continue the connect request down the
connect pipelineConnection to the requested hostjava.sql.SQLException - if there was an error establishing a Connection to the requested
host