public abstract class AbstractConnectionPlugin extends java.lang.Object implements ConnectionPlugin
| Constructor and Description |
|---|
AbstractConnectionPlugin() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
acceptsStrategy(HostRole role,
java.lang.String strategy)
Returns a boolean indicating if this
ConnectionPlugin implements the specified host
selection strategy for the given role in ConnectionPlugin.getHostSpecByStrategy(software.amazon.jdbc.HostRole, java.lang.String). |
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.
|
<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) |
java.sql.Connection |
forceConnect(java.lang.String driverProtocol,
HostSpec hostSpec,
java.util.Properties props,
boolean isInitialConnection,
JdbcCallable<java.sql.Connection,java.sql.SQLException> forceConnectFunc)
Establishes a connection to the given host using the given driver protocol and properties.
|
HostSpec |
getHostSpecByStrategy(HostRole role,
java.lang.String strategy)
Selects a
HostSpec with the requested role from available hosts using the requested
strategy. |
HostSpec |
getHostSpecByStrategy(java.util.List<HostSpec> hosts,
HostRole role,
java.lang.String strategy) |
abstract 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 |
notifyNodeListChanged(java.util.Map<java.lang.String,java.util.EnumSet<NodeChangeOptions>> changes) |
public abstract java.util.Set<java.lang.String> getSubscribedMethods()
getSubscribedMethods in interface ConnectionPluginpublic <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 ConnectionPluginE extends java.lang.Exceptionpublic 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 ConnectionPlugindriverProtocol - 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,
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 Driver.setCustomConnectionProvider(ConnectionProvider).
The default ConnectionProvider will be DriverConnectionProvider for connections
requested via the DriverManager and DataSourceConnectionProvider for
connections requested via an AwsWrapperDataSource.forceConnect in interface ConnectionPlugindriverProtocol - 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 boolean acceptsStrategy(HostRole role, java.lang.String strategy)
ConnectionPluginConnectionPlugin implements the specified host
selection strategy for the given role in ConnectionPlugin.getHostSpecByStrategy(software.amazon.jdbc.HostRole, java.lang.String).acceptsStrategy in interface ConnectionPluginrole - the desired host rolestrategy - the strategy that should be used to pick a host (eg "random")ConnectionPlugin supports the selection of a host with the requested role and strategy
via ConnectionPlugin.getHostSpecByStrategy(software.amazon.jdbc.HostRole, java.lang.String). Otherwise, return false.public HostSpec getHostSpecByStrategy(HostRole role, java.lang.String strategy) throws java.sql.SQLException, java.lang.UnsupportedOperationException
ConnectionPluginHostSpec with the requested role from available hosts using the requested
strategy. ConnectionPlugin.acceptsStrategy(software.amazon.jdbc.HostRole, java.lang.String) should be called first to evaluate if this
ConnectionPlugin supports the selection of a host with the requested role and
strategy.getHostSpecByStrategy in interface ConnectionPluginrole - the desired role of the host - either a writer or a readerstrategy - the strategy that should be used to select a HostSpec from the
available hosts (eg "random")HostSpec with the requested rolejava.sql.SQLException - if the available hosts do not contain any hosts matching
the requested role or an error occurs while selecting a
hostjava.lang.UnsupportedOperationException - if this ConnectionPlugin does not support the
requested strategypublic HostSpec getHostSpecByStrategy(java.util.List<HostSpec> hosts, HostRole role, java.lang.String strategy) throws java.sql.SQLException, java.lang.UnsupportedOperationException
getHostSpecByStrategy in interface ConnectionPluginjava.sql.SQLExceptionjava.lang.UnsupportedOperationExceptionpublic 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 ConnectionPluginjava.sql.SQLExceptionpublic OldConnectionSuggestedAction notifyConnectionChanged(java.util.EnumSet<NodeChangeOptions> changes)
notifyConnectionChanged in interface ConnectionPluginpublic void notifyNodeListChanged(java.util.Map<java.lang.String,java.util.EnumSet<NodeChangeOptions>> changes)
notifyNodeListChanged in interface ConnectionPlugin