public interface PluginService extends ExceptionHandler
Connection and its HostSpec.| Modifier and Type | Method and Description |
|---|---|
boolean |
acceptsStrategy(HostRole role,
java.lang.String strategy)
Returns a boolean indicating if the available
ConnectionProvider or
ConnectionPlugin instances support the selection of a host with the requested role and
strategy via getHostSpecByStrategy(software.amazon.jdbc.HostRole, java.lang.String). |
java.sql.Connection |
connect(HostSpec hostSpec,
java.util.Properties props)
Establishes a connection to the given host using the given properties.
|
java.sql.Connection |
connect(HostSpec hostSpec,
java.util.Properties props,
@Nullable ConnectionPlugin pluginToSkip) |
void |
fillAliases(java.sql.Connection connection,
HostSpec hostSpec) |
java.sql.Connection |
forceConnect(HostSpec hostSpec,
java.util.Properties props)
Establishes a connection to the given host using the given properties.
|
java.sql.Connection |
forceConnect(HostSpec hostSpec,
java.util.Properties props,
@Nullable ConnectionPlugin pluginToSkip) |
void |
forceRefreshHostList() |
boolean |
forceRefreshHostList(boolean shouldVerifyWriter,
long timeoutMs)
Initiates a topology update.
|
void |
forceRefreshHostList(java.sql.Connection connection) |
java.util.List<HostSpec> |
getAllHosts()
Get host information for all hosts in the cluster.
|
ConnectionProvider |
getConnectionProvider()
Deprecated.
|
java.sql.Connection |
getCurrentConnection() |
HostSpec |
getCurrentHostSpec() |
Dialect |
getDialect() |
java.lang.String |
getDriverProtocol() |
HostListProvider |
getHostListProvider() |
HostRole |
getHostRole(java.sql.Connection conn)
Evaluates the host role of the given connection - either a writer or a reader.
|
java.util.List<HostSpec> |
getHosts()
Get host information for allowed hosts in the cluster.
|
HostSpecBuilder |
getHostSpecBuilder() |
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)
Selects a
HostSpec with the requested role from available hosts using the requested
strategy. |
HostSpec |
getInitialConnectionHostSpec() |
java.lang.String |
getOriginalUrl() |
<T> T |
getPlugin(java.lang.Class<T> pluginClazz) |
java.util.Properties |
getProperties() |
@NonNull SessionStateService |
getSessionStateService() |
<T> T |
getStatus(@NonNull java.lang.Class<T> clazz,
boolean clusterBound) |
<T> T |
getStatus(@NonNull java.lang.Class<T> clazz,
java.lang.String key) |
TargetDriverDialect |
getTargetDriverDialect() |
java.lang.String |
getTargetName() |
TelemetryFactory |
getTelemetryFactory() |
@Nullable HostSpec |
identifyConnection(java.sql.Connection connection) |
boolean |
isInTransaction() |
boolean |
isPluginInUse(java.lang.Class<? extends ConnectionPlugin> pluginClazz) |
boolean |
isPooledConnectionProvider(HostSpec host,
java.util.Properties props) |
void |
refreshHostList() |
void |
refreshHostList(java.sql.Connection connection) |
void |
setAllowedAndBlockedHosts(AllowedAndBlockedHosts allowedAndBlockedHosts)
Deprecated.
use StorageService#set(key, allowedAndBlockedHosts) instead.
|
void |
setAvailability(java.util.Set<java.lang.String> hostAliases,
HostAvailability availability) |
void |
setCurrentConnection(@NonNull java.sql.Connection connection,
@NonNull HostSpec hostSpec) |
java.util.EnumSet<NodeChangeOptions> |
setCurrentConnection(@NonNull java.sql.Connection connection,
@NonNull HostSpec hostSpec,
@Nullable ConnectionPlugin skipNotificationForThisPlugin)
Set a new internal connection.
|
<T> void |
setStatus(java.lang.Class<T> clazz,
T status,
boolean clusterBound) |
<T> void |
setStatus(java.lang.Class<T> clazz,
T status,
java.lang.String key) |
void |
updateDialect(@NonNull java.sql.Connection connection) |
isLoginException, isLoginException, isLoginException, isNetworkException, isNetworkException, isNetworkExceptionjava.sql.Connection getCurrentConnection()
HostSpec getCurrentHostSpec()
void setCurrentConnection(@NonNull java.sql.Connection connection,
@NonNull HostSpec hostSpec)
throws java.sql.SQLException
java.sql.SQLExceptionjava.util.EnumSet<NodeChangeOptions> setCurrentConnection(@NonNull java.sql.Connection connection, @NonNull HostSpec hostSpec, @Nullable ConnectionPlugin skipNotificationForThisPlugin) throws java.sql.SQLException
ConnectionPlugin.notifyConnectionChanged(EnumSet) for more details. A plugin mentioned
in parameter skipNotificationForThisPlugin won't be receiving such notification.connection - the new internal connection.hostSpec - the host details for a new internal connection.skipNotificationForThisPlugin - A reference to a plugin that doesn't need to receive notification
about connection change. Usually, a plugin that initiates connection change
doesn't need to receive such notification and uses a pointer to
itself as a call parameter.java.sql.SQLException - if there's an error setting a current connection.java.util.List<HostSpec> getAllHosts()
java.util.List<HostSpec> getHosts()
HostSpec getInitialConnectionHostSpec()
java.lang.String getOriginalUrl()
@Deprecated void setAllowedAndBlockedHosts(AllowedAndBlockedHosts allowedAndBlockedHosts)
allowedAndBlockedHosts - An object defining the allowed and blocked sets of hosts.boolean acceptsStrategy(HostRole role, java.lang.String strategy) throws java.sql.SQLException
ConnectionProvider or
ConnectionPlugin instances support the selection of a host with the requested role and
strategy via getHostSpecByStrategy(software.amazon.jdbc.HostRole, java.lang.String).role - the desired host rolestrategy - the strategy that should be used to pick a host (eg "random")ConnectionProvider or ConnectionPlugin instances
support the selection of a host with the requested role and strategy via
getHostSpecByStrategy(software.amazon.jdbc.HostRole, java.lang.String). Otherwise, return false.java.sql.SQLException - if there's an error processing this method.HostSpec getHostSpecByStrategy(HostRole role, java.lang.String strategy) throws java.sql.SQLException, java.lang.UnsupportedOperationException
HostSpec with the requested role from available hosts using the requested
strategy. acceptsStrategy(software.amazon.jdbc.HostRole, java.lang.String) should be called first to evaluate if the available
ConnectionProvider or ConnectionPlugin instances support the selection of a
host with the requested role and strategy.role - 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 ConnectionProvider or
ConnectionPlugin instances do not cannot find a
host matching the requested role or an error occurs while
selecting a hostjava.lang.UnsupportedOperationException - if the available ConnectionProvider or
ConnectionPlugin instances do not support the
requested strategyHostSpec getHostSpecByStrategy(java.util.List<HostSpec> hosts, HostRole role, java.lang.String strategy) throws java.sql.SQLException, java.lang.UnsupportedOperationException
HostSpec with the requested role from available hosts using the requested
strategy. acceptsStrategy(software.amazon.jdbc.HostRole, java.lang.String) should be called first to evaluate if the available
ConnectionProvider or ConnectionPlugin instances support the selection of a
host with the requested role and strategy.hosts - the list of HostSpec from which a HostSpec will be selected fromrole - 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 ConnectionProvider or
ConnectionPlugin instances do not cannot find a
host matching the requested role or an error occurs while
selecting a hostjava.lang.UnsupportedOperationException - if the available ConnectionProvider or
ConnectionPlugin instances do not support the
requested strategyHostRole getHostRole(java.sql.Connection conn) throws java.sql.SQLException
conn - a connection to the database instance whose role should be determinedjava.sql.SQLException - if there is a problem executing or processing the SQL query used to
determine the host rolevoid setAvailability(java.util.Set<java.lang.String> hostAliases,
HostAvailability availability)
boolean isInTransaction()
HostListProvider getHostListProvider()
void refreshHostList()
throws java.sql.SQLException
java.sql.SQLExceptionvoid refreshHostList(java.sql.Connection connection)
throws java.sql.SQLException
java.sql.SQLExceptionvoid forceRefreshHostList()
throws java.sql.SQLException
java.sql.SQLExceptionvoid forceRefreshHostList(java.sql.Connection connection)
throws java.sql.SQLException
java.sql.SQLExceptionboolean forceRefreshHostList(boolean shouldVerifyWriter,
long timeoutMs)
throws java.sql.SQLException
shouldVerifyWriter - true, if a caller expects to get topology with the latest confirmed writertimeoutMs - timeout in msec to wait until topology gets refreshed and a new (or existing) writer is
confirmed (if shouldVerifyWriter has a value of true).java.sql.SQLException - if there was an error establishing a connection or fetching a topologyjava.sql.Connection connect(HostSpec hostSpec, java.util.Properties props, @Nullable ConnectionPlugin pluginToSkip) throws java.sql.SQLException
java.sql.SQLExceptionjava.sql.Connection connect(HostSpec hostSpec, java.util.Properties props) throws java.sql.SQLException
ConnectionProvider has been set with
Driver.setCustomConnectionProvider(ConnectionProvider) and
ConnectionProvider.acceptsUrl(String, HostSpec, Properties) returns true for the
desired 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.hostSpec - the host details for the desired connectionprops - the connection propertiesConnection to the requested hostjava.sql.SQLException - if there was an error establishing a Connection to the requested
hostjava.sql.Connection forceConnect(HostSpec hostSpec, java.util.Properties props) throws java.sql.SQLException
ConnectionPlugin.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.hostSpec - the host details for the desired connectionprops - the connection propertiesConnection to the requested hostjava.sql.SQLException - if there was an error establishing a Connection to the requested
hostjava.sql.Connection forceConnect(HostSpec hostSpec, java.util.Properties props, @Nullable ConnectionPlugin pluginToSkip) throws java.sql.SQLException
java.sql.SQLExceptionDialect getDialect()
TargetDriverDialect getTargetDriverDialect()
void updateDialect(@NonNull java.sql.Connection connection)
throws java.sql.SQLException
java.sql.SQLException@Nullable HostSpec identifyConnection(java.sql.Connection connection) throws java.sql.SQLException
java.sql.SQLExceptionvoid fillAliases(java.sql.Connection connection,
HostSpec hostSpec)
throws java.sql.SQLException
java.sql.SQLExceptionHostSpecBuilder getHostSpecBuilder()
@Deprecated ConnectionProvider getConnectionProvider()
boolean isPooledConnectionProvider(HostSpec host, java.util.Properties props)
java.lang.String getDriverProtocol()
java.util.Properties getProperties()
TelemetryFactory getTelemetryFactory()
java.lang.String getTargetName()
@NonNull SessionStateService getSessionStateService()
<T> T getPlugin(java.lang.Class<T> pluginClazz)
<T> void setStatus(java.lang.Class<T> clazz,
T status,
boolean clusterBound)
<T> void setStatus(java.lang.Class<T> clazz,
T status,
java.lang.String key)
<T> T getStatus(@NonNull java.lang.Class<T> clazz,
boolean clusterBound)
<T> T getStatus(@NonNull java.lang.Class<T> clazz,
java.lang.String key)
boolean isPluginInUse(java.lang.Class<? extends ConnectionPlugin> pluginClazz)