public class ReadWriteSplittingPlugin extends AbstractConnectionPlugin implements CanReleaseResources
| Modifier and Type | Field and Description |
|---|---|
static AwsWrapperProperty |
READER_HOST_SELECTOR_STRATEGY |
| Modifier and Type | Method and Description |
|---|---|
java.sql.Connection |
connect(java.lang.String driverProtocol,
HostSpec hostSpec,
java.util.Properties props,
boolean isInitialConnection,
@NonNull JdbcCallable<java.sql.Connection,java.sql.SQLException> connectFunc)
Establishes a connection to the given host using the given driver protocol and properties.
|
<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[] args) |
java.sql.Connection |
forceConnect(java.lang.String driverProtocol,
HostSpec hostSpec,
java.util.Properties props,
boolean isInitialConnection,
@NonNull JdbcCallable<java.sql.Connection,java.sql.SQLException> forceConnectFunc)
Establishes a connection to the given host using the given driver protocol and properties.
|
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) |
OldConnectionSuggestedAction |
notifyConnectionChanged(java.util.EnumSet<NodeChangeOptions> changes) |
void |
releaseResources()
An object that implements this interface should release all acquired resources assuming it may
be disposed at any time.
|
protected void |
transferSessionStateOnReadWriteSplit(java.sql.Connection to)
Transfers basic session state from one connection to another, except for the read-only
status.
|
acceptsStrategy, getHostSpecByStrategy, notifyNodeListChangedpublic static final AwsWrapperProperty READER_HOST_SELECTOR_STRATEGY
public java.util.Set<java.lang.String> getSubscribedMethods()
getSubscribedMethods in interface ConnectionPlugingetSubscribedMethods in class AbstractConnectionPluginpublic 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 java.sql.Connection connect(java.lang.String driverProtocol,
HostSpec hostSpec,
java.util.Properties props,
boolean isInitialConnection,
@NonNull JdbcCallable<java.sql.Connection,java.sql.SQLException> connectFunc)
throws java.sql.SQLException
ConnectionPluginConnectionProvider has been set with
ConnectionProviderManager.setConnectionProvider(software.amazon.jdbc.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
hostpublic java.sql.Connection forceConnect(java.lang.String driverProtocol,
HostSpec hostSpec,
java.util.Properties props,
boolean isInitialConnection,
@NonNull JdbcCallable<java.sql.Connection,java.sql.SQLException> forceConnectFunc)
throws java.sql.SQLException
ConnectionPluginConnectionPlugin.connect(java.lang.String, software.amazon.jdbc.HostSpec, java.util.Properties, boolean, software.amazon.jdbc.JdbcCallable<java.sql.Connection, java.sql.SQLException>) in that the default
ConnectionProvider will be used to establish the connection even if a non-default
ConnectionProvider has been set via ConnectionProviderManager.setConnectionProvider(software.amazon.jdbc.ConnectionProvider).
The default ConnectionProvider will be DriverConnectionProvider for connections
requested via the DriverManager and DataSourceConnectionProvider for
connections requested via an AwsWrapperDataSource.forceConnect in interface ConnectionPluginforceConnect 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 pastforceConnectFunc - the function to call to continue the forceConnect request down the
forceConnect pipelineConnection to the requested hostjava.sql.SQLException - if there was an error establishing a Connection to the requested
hostpublic OldConnectionSuggestedAction notifyConnectionChanged(java.util.EnumSet<NodeChangeOptions> changes)
notifyConnectionChanged in interface ConnectionPluginnotifyConnectionChanged 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[] args)
throws E extends java.lang.Exception
execute in interface ConnectionPluginexecute in class AbstractConnectionPluginE extends java.lang.Exceptionprotected void transferSessionStateOnReadWriteSplit(java.sql.Connection to)
throws java.sql.SQLException
to - The connection to transfer state tojava.sql.SQLException - if a database access error occurs, this method is called on a closed
connection, or this method is called during a distributed transactionpublic void releaseResources()
CanReleaseResourcesCalling this method does NOT mean that an object is disposing and there won't be any further calls. An object should keep its functional state after calling this method.
releaseResources in interface CanReleaseResources