public class SimpleReadWriteSplittingPlugin extends AbstractReadWriteSplittingPlugin implements CanReleaseResources, StateSnapshotProvider
| Modifier and Type | Field and Description |
|---|---|
static AwsWrapperProperty |
SRW_CONNECT_RETRY_INTERVAL_MS |
static AwsWrapperProperty |
SRW_CONNECT_RETRY_TIMEOUT_MS |
static AwsWrapperProperty |
SRW_READ_ENDPOINT |
static AwsWrapperProperty |
SRW_WRITE_ENDPOINT |
static AwsWrapperProperty |
VERIFY_INITIAL_CONNECTION_TYPE |
static AwsWrapperProperty |
VERIFY_NEW_SRW_CONNECTIONS |
CACHED_READER_KEEP_ALIVE_TIMEOUT, hostListProviderService, inReadWriteSplit, isReaderConnFromInternalPool, isWriterConnFromInternalPool, pluginService, properties, readerCacheItem, readerHostSpec, writerConnection, writerHostSpec| Constructor and Description |
|---|
SimpleReadWriteSplittingPlugin(PluginService pluginService,
java.util.Properties properties) |
SimpleReadWriteSplittingPlugin(PluginService pluginService,
java.util.Properties properties,
HostListProviderService hostListProviderService,
java.sql.Connection writerConnection,
java.sql.Connection readerConnection,
HostSpec writeEndpointHostSpec,
HostSpec readEndpointHostSpec)
For testing purposes only.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
closeReaderIfNecessary() |
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.
|
java.util.List<Pair<java.lang.String,java.lang.Object>> |
getSnapshotState() |
protected void |
initializeReaderConnection() |
protected void |
initializeWriterConnection() |
protected boolean |
isReader(@NonNull HostSpec hostSpec) |
protected boolean |
isWriter(@NonNull HostSpec hostSpec) |
protected void |
refreshAndStoreTopology(java.sql.Connection currentConnection) |
protected boolean |
shouldUpdateReaderConnection(java.sql.Connection currentConnection,
HostSpec currentHost) |
protected boolean |
shouldUpdateWriterConnection(java.sql.Connection currentConnection,
HostSpec currentHost) |
closeReaderConnectionIfIdle, closeWriterConnectionIfIdle, execute, getKeepAliveTimeout, getReaderConnection, getReaderHostSpec, getSubscribedMethods, getWriterConnection, getWriterHostSpec, initHostProvider, isConnectionUsable, logAndThrowException, logAndThrowException, notifyConnectionChanged, releaseResources, setReaderConnection, setWriterConnection, switchConnectionIfRequired, switchCurrentConnectionToacceptsStrategy, forceConnect, getHostSpecByStrategy, getHostSpecByStrategy, notifyNodeListChangedclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitreleaseResourcespublic static final AwsWrapperProperty SRW_READ_ENDPOINT
public static final AwsWrapperProperty SRW_WRITE_ENDPOINT
public static final AwsWrapperProperty VERIFY_NEW_SRW_CONNECTIONS
public static final AwsWrapperProperty SRW_CONNECT_RETRY_TIMEOUT_MS
public static final AwsWrapperProperty SRW_CONNECT_RETRY_INTERVAL_MS
public static final AwsWrapperProperty VERIFY_INITIAL_CONNECTION_TYPE
public SimpleReadWriteSplittingPlugin(PluginService pluginService, java.util.Properties properties)
public SimpleReadWriteSplittingPlugin(PluginService pluginService, java.util.Properties properties, HostListProviderService hostListProviderService, java.sql.Connection writerConnection, java.sql.Connection readerConnection, HostSpec writeEndpointHostSpec, HostSpec readEndpointHostSpec)
pluginService - The PluginService implementation.properties - The properties to be used for this plugin.hostListProviderService - The HostListProviderService implementation.writerConnection - The writer connection.readerConnection - The reader connection.writeEndpointHostSpec - The writer HostSpec.readEndpointHostSpec - The reader HostSpec.public 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
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
hostprotected boolean isWriter(@NonNull HostSpec hostSpec)
isWriter in class AbstractReadWriteSplittingPluginprotected boolean isReader(@NonNull HostSpec hostSpec)
isReader in class AbstractReadWriteSplittingPluginprotected void refreshAndStoreTopology(java.sql.Connection currentConnection)
refreshAndStoreTopology in class AbstractReadWriteSplittingPluginprotected void initializeWriterConnection()
throws java.sql.SQLException
initializeWriterConnection in class AbstractReadWriteSplittingPluginjava.sql.SQLExceptionprotected void initializeReaderConnection()
throws java.sql.SQLException
initializeReaderConnection in class AbstractReadWriteSplittingPluginjava.sql.SQLExceptionprotected void closeReaderIfNecessary()
closeReaderIfNecessary in class AbstractReadWriteSplittingPluginprotected boolean shouldUpdateReaderConnection(java.sql.Connection currentConnection,
HostSpec currentHost)
throws java.sql.SQLException
shouldUpdateReaderConnection in class AbstractReadWriteSplittingPluginjava.sql.SQLExceptionprotected boolean shouldUpdateWriterConnection(java.sql.Connection currentConnection,
HostSpec currentHost)
throws java.sql.SQLException
shouldUpdateWriterConnection in class AbstractReadWriteSplittingPluginjava.sql.SQLExceptionpublic java.util.List<Pair<java.lang.String,java.lang.Object>> getSnapshotState()
getSnapshotState in interface StateSnapshotProvidergetSnapshotState in class AbstractConnectionPlugin