public class CustomEndpointPlugin extends AbstractConnectionPlugin
| Constructor and Description |
|---|
CustomEndpointPlugin(FullServicesContainer servicesContainer,
java.util.Properties props)
Constructs a new CustomEndpointPlugin instance.
|
CustomEndpointPlugin(FullServicesContainer servicesContainer,
java.util.Properties props,
java.util.function.BiFunction<HostSpec,software.amazon.awssdk.regions.Region,software.amazon.awssdk.services.rds.RdsClient> rdsClientFunc)
Constructs a new CustomEndpointPlugin instance.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
protected CustomEndpointMonitor |
createMonitorIfAbsent(java.util.Properties props)
Creates a monitor for the custom endpoint if it does not already exist.
|
<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)
Executes the given method via a pipeline of plugins.
|
java.util.Set<java.lang.String> |
getSubscribedMethods() |
protected void |
waitForCustomEndpointInfo(CustomEndpointMonitor monitor)
If custom endpoint info does not exist for the current custom endpoint, waits a short time for the info to be
made available by the custom endpoint monitor.
|
acceptsStrategy, forceConnect, getHostSpecByStrategy, getHostSpecByStrategy, initHostProvider, notifyConnectionChanged, notifyNodeListChangedprotected static final java.lang.String TELEMETRY_WAIT_FOR_INFO_COUNTER
protected static final RegionUtils regionUtils
protected static final java.util.Set<MonitorErrorResponse> monitorErrorResponses
public static final AwsWrapperProperty CUSTOM_ENDPOINT_INFO_REFRESH_RATE_MS
public static final AwsWrapperProperty WAIT_FOR_CUSTOM_ENDPOINT_INFO
public static final AwsWrapperProperty WAIT_FOR_CUSTOM_ENDPOINT_INFO_TIMEOUT_MS
public static final AwsWrapperProperty CUSTOM_ENDPOINT_MONITOR_IDLE_EXPIRATION_MS
public static final AwsWrapperProperty REGION_PROPERTY
protected final FullServicesContainer servicesContainer
protected final PluginService pluginService
protected final TelemetryFactory telemetryFactory
protected final java.util.Properties props
protected final RdsUtils rdsUtils
protected final java.util.function.BiFunction<HostSpec,software.amazon.awssdk.regions.Region,software.amazon.awssdk.services.rds.RdsClient> rdsClientFunc
protected final java.util.Set<java.lang.String> subscribedMethods
protected final TelemetryCounter waitForInfoCounter
protected final boolean shouldWaitForInfo
protected final int waitOnCachedInfoDurationMs
protected final int idleMonitorExpirationMs
protected HostSpec customEndpointHostSpec
protected java.lang.String customEndpointId
protected software.amazon.awssdk.regions.Region region
public CustomEndpointPlugin(FullServicesContainer servicesContainer, java.util.Properties props)
servicesContainer - The service container for the services required by this class.props - The properties that the custom endpoint plugin should use.public CustomEndpointPlugin(FullServicesContainer servicesContainer, java.util.Properties props, java.util.function.BiFunction<HostSpec,software.amazon.awssdk.regions.Region,software.amazon.awssdk.services.rds.RdsClient> rdsClientFunc)
servicesContainer - The service container for the services required by this class.props - The properties that the custom endpoint plugin should use.rdsClientFunc - The function to call to obtain an RdsClient instance.public java.util.Set<java.lang.String> getSubscribedMethods()
getSubscribedMethods in interface ConnectionPlugingetSubscribedMethods in class AbstractConnectionPluginpublic 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 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 CustomEndpointMonitor createMonitorIfAbsent(java.util.Properties props) throws java.sql.SQLException
props - The connection properties.CustomEndpointMonitorjava.sql.SQLException - if an error occurs while attempting to create the monitor.protected void waitForCustomEndpointInfo(CustomEndpointMonitor monitor) throws java.sql.SQLException
monitor - A CustomEndpointMonitor monitor.java.sql.SQLException - if there's an error getting custom endpoint, or if it takes longer time than anticipatedpublic <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 ConnectionPluginexecute in class AbstractConnectionPluginT - The type of the result returned by the method.E - The desired type for any exceptions that occur while executing the jdbcMethodFunc.resultClass - The class of the object returned by the jdbcMethodFunc.exceptionClass - The desired exception class for any exceptions that occur while executing the
jdbcMethodFunc.methodInvokeOn - The object that the jdbcMethodFunc is being invoked on.methodName - The name of the method being invoked.jdbcMethodFunc - The execute pipeline to call to invoke the method.jdbcMethodArgs - The arguments to the method being invoked.E - If an exception occurs, either directly in this method, or while executing the jdbcMethodFunc.E extends java.lang.Exception