public interface PluginService extends ExceptionHandler, java.sql.Wrapper, StateSnapshotProvider
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) |
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 verifyTopology,
long timeoutMs)
Initiates a topology update.
|
java.util.List<HostSpec> |
getAllHosts()
Get host information for all hosts in the cluster.
|
PluginCallContext |
getCallContext()
Returns the per-call context that flows through the plugin pipeline for the current JDBC call.
|
java.sql.Connection |
getCurrentConnection() |
HostSpec |
getCurrentHostSpec() |
ConnectionProvider |
getDefaultConnectionProvider() |
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(@Nullable 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,
@Nullable 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() |
@Nullable HostSpec |
getRoutedHostSpec() |
@NonNull SessionStateService |
getSessionStateService() |
TargetDriverDialect |
getTargetDriverDialect() |
java.lang.String |
getTargetName() |
TelemetryFactory |
getTelemetryFactory() |
TrackedConnectionList.Node |
getTrackedConnectionNode()
Returns the tracked connection list node associated with the current connection.
|
@Nullable HostSpec |
identifyConnection(java.sql.Connection connection) |
@Nullable HostSpec |
identifyConnection(java.sql.Connection connection,
@NonNull HostSpec connectionHostSpec) |
boolean |
isDialectConfirmed() |
boolean |
isInTransaction() |
boolean |
isPluginInUse(java.lang.Class<? extends ConnectionPlugin> pluginClazz) |
@Nullable java.lang.Boolean |
isPooledConnection()
Retrieves details about the most recent
connect(software.amazon.jdbc.HostSpec, java.util.Properties, software.amazon.jdbc.ConnectionPlugin) or
forceConnect(software.amazon.jdbc.HostSpec, java.util.Properties) calls. |
boolean |
isPooledConnectionProvider(HostSpec host,
java.util.Properties props)
Deprecated.
|
void |
refreshHostList() |
void |
setAvailability(@NonNull HostSpec hostSpec,
@NonNull 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.
|
void |
setRoutedHostSpec(@Nullable HostSpec routedHostSpec) |
void |
setTrackedConnectionNode(TrackedConnectionList.Node node)
Sets the tracked connection list node for the current connection.
|
void |
updateDialect(@NonNull java.sql.Connection connection) |
isLoginException, isLoginException, isNetworkException, isNetworkException, isReadOnlyConnectionException, isReadOnlyConnectionExceptiongetSnapshotStatejava.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.@Nullable HostSpec getRoutedHostSpec()
void setRoutedHostSpec(@Nullable HostSpec routedHostSpec)
java.util.List<HostSpec> getAllHosts()
java.util.List<HostSpec> getHosts()
HostSpec getInitialConnectionHostSpec()
java.lang.String getOriginalUrl()
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(@Nullable 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, @Nullable 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(@NonNull HostSpec hostSpec, @NonNull HostAvailability availability)
boolean isInTransaction()
boolean isDialectConfirmed()
HostListProvider getHostListProvider()
void refreshHostList()
throws java.sql.SQLException
java.sql.SQLExceptionvoid forceRefreshHostList()
throws java.sql.SQLException
java.sql.SQLExceptionboolean forceRefreshHostList(boolean verifyTopology,
long timeoutMs)
throws java.sql.SQLException
verifyTopology - defines whether extra measures should be taken to verify the topology. If false, the
method will return as soon as topology is successfully retrieved from any instance. If
true, extra steps are taken to verify the topology is accurate.timeoutMs - timeout in msec to wait until the topology gets refreshed (if verifyWriter has a value of
false) or verified (if verifyTopology 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.SQLException@Nullable HostSpec identifyConnection(java.sql.Connection connection, @NonNull HostSpec connectionHostSpec) throws java.sql.SQLException
java.sql.SQLExceptionHostSpecBuilder getHostSpecBuilder()
ConnectionProvider getDefaultConnectionProvider()
@Deprecated 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()
PluginCallContext getCallContext()
PluginCallContext.<T> T getPlugin(java.lang.Class<T> pluginClazz)
boolean isPluginInUse(java.lang.Class<? extends ConnectionPlugin> pluginClazz)
TrackedConnectionList.Node getTrackedConnectionNode()
void setTrackedConnectionNode(TrackedConnectionList.Node node)
node - the node returned by
OpenedConnectionTracker.populateOpenedConnectionQueue(software.amazon.jdbc.HostSpec, java.sql.Connection)@Nullable java.lang.Boolean isPooledConnection()
connect(software.amazon.jdbc.HostSpec, java.util.Properties, software.amazon.jdbc.ConnectionPlugin) or
forceConnect(software.amazon.jdbc.HostSpec, java.util.Properties) calls. Specifically indicates whether the
returned connection was obtained from a connection pool or newly created.
Note: The ConnectionPlugin must process or store this information during
the current JDBC call, as these details will be reset before the next JDBC call
is processed, or another connect(software.amazon.jdbc.HostSpec, java.util.Properties, software.amazon.jdbc.ConnectionPlugin) or forceConnect(software.amazon.jdbc.HostSpec, java.util.Properties)
is made.