public class CustomEndpointPlugin extends AbstractConnectionPlugin
| Constructor and Description |
|---|
CustomEndpointPlugin(PluginService pluginService,
java.util.Properties props)
Constructs a new CustomEndpointPlugin instance.
|
CustomEndpointPlugin(PluginService pluginService,
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 |
|---|---|
static void |
closeMonitors()
Closes all active custom endpoint monitors.
|
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 long CACHE_CLEANUP_RATE_NANO
protected static final RegionUtils regionUtils
protected static final SlidingExpirationCacheWithCleanupThread<java.lang.String,CustomEndpointMonitor> monitors
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 PluginService pluginService
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 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(PluginService pluginService, java.util.Properties props)
pluginService - The plugin service that the custom endpoint plugin should use.props - The properties that the custom endpoint plugin should use.public CustomEndpointPlugin(PluginService pluginService, java.util.Properties props, java.util.function.BiFunction<HostSpec,software.amazon.awssdk.regions.Region,software.amazon.awssdk.services.rds.RdsClient> rdsClientFunc)
pluginService - The plugin service that the custom endpoint plugin should use.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
ConnectionProviderManager.setConnectionProvider(software.amazon.jdbc.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)
props - The connection properties.protected void waitForCustomEndpointInfo(CustomEndpointMonitor monitor) throws java.sql.SQLException
java.sql.SQLExceptionpublic <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.Exceptionpublic static void closeMonitors()