public class ReadWriteSplittingPlugin extends AbstractReadWriteSplittingPlugin implements CanReleaseResources, StateSnapshotProvider
| Modifier and Type | Field and Description |
|---|---|
protected java.util.List<HostSpec> |
hosts |
static AwsWrapperProperty |
READER_HOST_SELECTOR_STRATEGY |
protected java.lang.String |
readerSelectorStrategy |
static AwsWrapperProperty |
VERIFY_INITIAL_CONNECTION_ROLE |
protected boolean |
verifyInitialConnectionRole |
CACHED_READER_KEEP_ALIVE_TIMEOUT, hostListProviderService, inReadWriteSplit, isReaderConnFromInternalPool, isWriterConnFromInternalPool, pluginService, properties, readerCacheItem, readerHostSpec, writerConnection, writerHostSpec| Constructor and Description |
|---|
ReadWriteSplittingPlugin(PluginService pluginService,
@NonNull java.util.Properties properties) |
| 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.
|
protected java.util.List<HostSpec> |
getReaderHostCandidates() |
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 |
openNewReaderConnection() |
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, waitreleaseResourcesprotected final java.lang.String readerSelectorStrategy
protected java.util.List<HostSpec> hosts
public static final AwsWrapperProperty READER_HOST_SELECTOR_STRATEGY
public static final AwsWrapperProperty VERIFY_INITIAL_CONNECTION_ROLE
protected final boolean verifyInitialConnectionRole
public ReadWriteSplittingPlugin(PluginService pluginService, @NonNull java.util.Properties properties)
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)
throws java.sql.SQLException
refreshAndStoreTopology in class AbstractReadWriteSplittingPluginjava.sql.SQLExceptionprotected 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 java.util.List<HostSpec> getReaderHostCandidates() throws java.sql.SQLException
java.sql.SQLExceptionprotected void openNewReaderConnection()
throws java.sql.SQLException
java.sql.SQLExceptionprotected boolean shouldUpdateReaderConnection(java.sql.Connection currentConnection,
HostSpec currentHost)
shouldUpdateReaderConnection in class AbstractReadWriteSplittingPluginprotected boolean shouldUpdateWriterConnection(java.sql.Connection currentConnection,
HostSpec currentHost)
shouldUpdateWriterConnection in class AbstractReadWriteSplittingPluginpublic java.util.List<Pair<java.lang.String,java.lang.Object>> getSnapshotState()
getSnapshotState in interface StateSnapshotProvidergetSnapshotState in class AbstractConnectionPlugin