public class PgTargetDriverDialect extends GenericTargetDriverDialect
ALLOWED_ON_CLOSED_METHODS, NETWORK_BOUND_METHODS_FOR_ENTIRE_RESULTSET| Constructor and Description |
|---|
PgTargetDriverDialect() |
| Modifier and Type | Method and Description |
|---|---|
void |
abortConnection(@NonNull java.sql.Connection connectionToAbort,
@NonNull java.util.concurrent.Executor abortExecutor) |
java.util.Set<java.lang.String> |
getAllowedOnConnectionMethodNames() |
byte[] |
getEncryptedBytes(@NonNull java.sql.ResultSet rs,
java.lang.Object columnRef) |
@Nullable java.lang.String |
getSQLQueryString(java.sql.PreparedStatement ps) |
boolean |
isDialect(java.sql.Driver driver) |
boolean |
isDialect(java.lang.String dataSourceClass) |
boolean |
isDriverRegistered() |
ConnectInfo |
prepareConnectInfo(@NonNull java.lang.String protocol,
@NonNull HostSpec hostSpec,
@NonNull java.util.Properties props) |
void |
prepareDataSource(@NonNull javax.sql.DataSource dataSource,
@NonNull java.lang.String protocol,
@NonNull HostSpec hostSpec,
@NonNull java.util.Properties props) |
java.lang.String |
prepareTargetDataSource(@NonNull javax.sql.CommonDataSource dataSource,
@NonNull java.lang.String url,
@NonNull java.util.Properties props)
Applies AWS Wrapper connection settings that a target data source can only receive through
driver-specific bean setters (for example connect/socket timeouts, whose unit differs per
driver), and returns the connection URL to apply to that data source.
|
void |
registerDataType(@NonNull java.sql.Connection connection,
@NonNull java.lang.String typeName,
@NonNull java.lang.String className) |
void |
registerDriver() |
java.util.Set<java.lang.String> |
removeHostSelectionProperties(@NonNull java.util.Properties props)
Removes properties that restrict which database node the target driver is willing to accept a
connection to, and returns the names of the properties that were removed.
|
void |
setEncryptedParameter(@NonNull java.sql.PreparedStatement ps,
int paramIndex,
byte[] encrypted) |
void |
updateInternalState(@NonNull PluginService pluginService,
@NonNull java.util.Properties props)
Allows each target driver dialect to perform last-minute adjustments to the wrapper's
internal state after the initial connection is established.
|
findSQLQueryString, getNetworkBoundMethodNames, getSQLState, pingpublic boolean isDialect(java.sql.Driver driver)
isDialect in interface TargetDriverDialectisDialect in class GenericTargetDriverDialectpublic boolean isDialect(java.lang.String dataSourceClass)
isDialect in interface TargetDriverDialectisDialect in class GenericTargetDriverDialectpublic ConnectInfo prepareConnectInfo(@NonNull java.lang.String protocol, @NonNull HostSpec hostSpec, @NonNull java.util.Properties props)
prepareConnectInfo in interface TargetDriverDialectprepareConnectInfo in class GenericTargetDriverDialectpublic void prepareDataSource(@NonNull javax.sql.DataSource dataSource,
@NonNull java.lang.String protocol,
@NonNull HostSpec hostSpec,
@NonNull java.util.Properties props)
throws java.sql.SQLException
prepareDataSource in interface TargetDriverDialectprepareDataSource in class GenericTargetDriverDialectjava.sql.SQLExceptionpublic java.lang.String prepareTargetDataSource(@NonNull javax.sql.CommonDataSource dataSource,
@NonNull java.lang.String url,
@NonNull java.util.Properties props)
TargetDriverDialectThis is used by the XA datasource path, which configures a target driver
XADataSource directly instead of going through
TargetDriverDialect.prepareConnectInfo(String, HostSpec, Properties). Because that path hands the target
only its own (non-wrapper) properties, wrapper properties such as socketTimeout would
otherwise be dropped. Dialects whose target data source cannot express a setting as a bean
property may instead add it to the returned URL.
The default implementation applies nothing and returns url unchanged.
dataSource - the target driver data source being configured.url - the target driver URL, with AWS Wrapper parameters already removed.props - the effective connection properties, including AWS Wrapper properties.public boolean isDriverRegistered()
throws java.sql.SQLException
isDriverRegistered in interface TargetDriverDialectisDriverRegistered in class GenericTargetDriverDialectjava.sql.SQLExceptionpublic void registerDriver()
throws java.sql.SQLException
registerDriver in interface TargetDriverDialectregisterDriver in class GenericTargetDriverDialectjava.sql.SQLExceptionpublic java.util.Set<java.lang.String> getAllowedOnConnectionMethodNames()
getAllowedOnConnectionMethodNames in interface TargetDriverDialectgetAllowedOnConnectionMethodNames in class GenericTargetDriverDialectpublic void abortConnection(@NonNull java.sql.Connection connectionToAbort,
@NonNull java.util.concurrent.Executor abortExecutor)
throws java.sql.SQLException
abortConnection in interface TargetDriverDialectabortConnection in class GenericTargetDriverDialectjava.sql.SQLExceptionpublic @Nullable java.lang.String getSQLQueryString(java.sql.PreparedStatement ps)
getSQLQueryString in interface TargetDriverDialectgetSQLQueryString in class GenericTargetDriverDialectpublic void registerDataType(@NonNull java.sql.Connection connection,
@NonNull java.lang.String typeName,
@NonNull java.lang.String className)
throws java.sql.SQLException
registerDataType in interface TargetDriverDialectregisterDataType in class GenericTargetDriverDialectjava.sql.SQLExceptionpublic void setEncryptedParameter(@NonNull java.sql.PreparedStatement ps,
int paramIndex,
byte[] encrypted)
throws java.sql.SQLException
setEncryptedParameter in interface TargetDriverDialectsetEncryptedParameter in class GenericTargetDriverDialectjava.sql.SQLExceptionpublic byte[] getEncryptedBytes(@NonNull java.sql.ResultSet rs,
java.lang.Object columnRef)
throws java.sql.SQLException
getEncryptedBytes in interface TargetDriverDialectgetEncryptedBytes in class GenericTargetDriverDialectjava.sql.SQLExceptionpublic void updateInternalState(@NonNull PluginService pluginService, @NonNull java.util.Properties props) throws java.sql.SQLException
TargetDriverDialectcurrentSchema) into
the wrapper's session state so they are preserved across connection switches
(failover, read-write splitting, initial connection strategy, etc.).
Each dialect implementation should inspect the provided properties for driver-specific
settings that affect session state and register them with the appropriate services
(e.g. SessionStateService).
This method is called once after the initial connection is established in
ConnectionWrapper.init().
updateInternalState in interface TargetDriverDialectupdateInternalState in class GenericTargetDriverDialectpluginService - the plugin service providing access to session state and other servicesprops - the connection properties that may contain driver-specific settingsjava.sql.SQLException - if an error occurs while updating internal statepublic java.util.Set<java.lang.String> removeHostSelectionProperties(@NonNull java.util.Properties props)
TargetDriverDialectSome target drivers can be told to reject a node that does not match a role, for example
PostgreSQL's targetServerType, which makes the driver verify the server is writable and
fail the connection otherwise. Such a setting is meaningful for an application connection, where
the driver performs its own host selection, but not for the wrapper's internal monitoring
connections: those are opened against one specific node that the wrapper has already chosen, and
frequently against a reader or a replica on purpose. Inheriting the restriction there makes those
connections fail, silently disabling the monitor that depends on them.
Implementations must only remove properties that constrain node selection. Properties affecting authentication, encryption, timeouts, or session state must be left untouched so a monitoring connection keeps behaving like an application connection in every other respect.
The default implementation removes nothing and returns an empty set, so a target driver with no such property, and any implementation outside this library, needs no change.
props - the properties to adjust in place; typically a copy made for a monitoring connection.