public class AuroraInitialConnectionStrategyPlugin extends AbstractConnectionPlugin
| Modifier and Type | Class and Description |
|---|---|
protected static class |
AuroraInitialConnectionStrategyPlugin.InstanceSubstitutionStrategy |
protected static class |
AuroraInitialConnectionStrategyPlugin.RoleVerificationSetting |
| Modifier and Type | Field and Description |
|---|---|
static AwsWrapperProperty |
ENDPOINT_SUBSTITUTION_ROLE |
static AwsWrapperProperty |
HOST_SELECTOR_STRATEGY |
static AwsWrapperProperty |
INACTIVE_CLUSTER_WRITER_SUBSTITUTION_ROLE |
static AwsWrapperProperty |
OPEN_CONNECTION_RETRY_INTERVAL_MS |
static AwsWrapperProperty |
OPEN_CONNECTION_RETRY_TIMEOUT_MS |
static AwsWrapperProperty |
READER_HOST_SELECTOR_STRATEGY |
static AwsWrapperProperty |
VERIFY_INACTIVE_CLUSTER_WRITER_CONNECTION_ROLE |
static AwsWrapperProperty |
VERIFY_OPENED_CONNECTION_ROLE |
static AwsWrapperProperty |
WAIT_FOR_INITIAL_TOPOLOGY_MS |
| Constructor and Description |
|---|
AuroraInitialConnectionStrategyPlugin(FullServicesContainer servicesContainer,
java.util.Properties properties) |
| Modifier and Type | Method and Description |
|---|---|
java.sql.Connection |
connect(java.lang.String driverProtocol,
HostSpec originalConnectHost,
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 HostSpec |
getCandidateHost(@NonNull HostSpec originalConnectHost,
@NonNull RdsUrlType urlType,
@NonNull AuroraInitialConnectionStrategyPlugin.InstanceSubstitutionStrategy substitutionStrategy) |
protected @NonNull AuroraInitialConnectionStrategyPlugin.InstanceSubstitutionStrategy |
getInstanceSubstitutionStrategy(java.util.Properties props,
RdsUrlType urlType,
boolean isInitialConnection,
@NonNull java.lang.String originalConnectHost) |
protected HostRole |
getRoleToVerify(RdsUrlType urlType,
boolean isInitialConnection,
java.util.Properties props,
@NonNull java.lang.String originalConnectHost) |
java.util.Set<java.lang.String> |
getSubscribedMethods() |
protected boolean |
hasReaders(@NonNull java.util.List<HostSpec> hosts) |
void |
initHostProvider(java.lang.String driverProtocol,
java.lang.String initialUrl,
java.util.Properties props,
HostListProviderService hostListProviderService,
JdbcCallable<java.lang.Void,java.sql.SQLException> initHostProviderFunc) |
protected HostSpec |
openCandidateConnection(@NonNull HostSpec originalConnectHost,
@NonNull RdsUrlType urlType,
@NonNull AuroraInitialConnectionStrategyPlugin.InstanceSubstitutionStrategy substitutionStrategy,
@NonNull java.util.Properties props,
@NonNull JdbcCallable<java.sql.Connection,java.sql.SQLException> connectFunc,
@NonNull AtomicConnection candidateConnHolder)
Opens a candidate connection and stores it in
candidateConnHolder, returning the HostSpec that
was connected to. |
protected void |
validateSubstitutionStrategy(@NonNull AuroraInitialConnectionStrategyPlugin.InstanceSubstitutionStrategy setting,
RdsUrlType urlType) |
protected void |
validateVerificationSetting(@NonNull AuroraInitialConnectionStrategyPlugin.RoleVerificationSetting setting,
@NonNull RdsUrlType urlType) |
protected HostSpec |
waitForTopologyAndConnectToInstance(@NonNull HostSpec originalConnectHost,
@NonNull RdsUrlType urlType,
@NonNull AuroraInitialConnectionStrategyPlugin.InstanceSubstitutionStrategy substitutionStrategy,
@NonNull java.util.Properties props,
@NonNull AtomicConnection candidateConnHolder)
Blocks until the topology for this cluster has been fetched, then re-attempts instance selection and connection.
|
acceptsStrategy, execute, forceConnect, getHostSpecByStrategy, getHostSpecByStrategy, getSnapshotState, notifyConnectionChanged, notifyNodeListChangedpublic static final AwsWrapperProperty READER_HOST_SELECTOR_STRATEGY
public static final AwsWrapperProperty HOST_SELECTOR_STRATEGY
public static final AwsWrapperProperty OPEN_CONNECTION_RETRY_TIMEOUT_MS
public static final AwsWrapperProperty OPEN_CONNECTION_RETRY_INTERVAL_MS
public static final AwsWrapperProperty WAIT_FOR_INITIAL_TOPOLOGY_MS
public static final AwsWrapperProperty ENDPOINT_SUBSTITUTION_ROLE
public static final AwsWrapperProperty INACTIVE_CLUSTER_WRITER_SUBSTITUTION_ROLE
public static final AwsWrapperProperty VERIFY_OPENED_CONNECTION_ROLE
public static final AwsWrapperProperty VERIFY_INACTIVE_CLUSTER_WRITER_CONNECTION_ROLE
public AuroraInitialConnectionStrategyPlugin(FullServicesContainer servicesContainer, java.util.Properties properties)
public java.util.Set<java.lang.String> getSubscribedMethods()
getSubscribedMethods in interface ConnectionPlugingetSubscribedMethods in class AbstractConnectionPluginpublic void initHostProvider(java.lang.String driverProtocol,
java.lang.String initialUrl,
java.util.Properties props,
HostListProviderService hostListProviderService,
JdbcCallable<java.lang.Void,java.sql.SQLException> initHostProviderFunc)
throws java.sql.SQLException
initHostProvider in interface ConnectionPlugininitHostProvider in class AbstractConnectionPluginjava.sql.SQLExceptionpublic java.sql.Connection connect(java.lang.String driverProtocol,
HostSpec originalConnectHost,
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 connectionoriginalConnectHost - 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 HostSpec openCandidateConnection(@NonNull HostSpec originalConnectHost, @NonNull RdsUrlType urlType, @NonNull AuroraInitialConnectionStrategyPlugin.InstanceSubstitutionStrategy substitutionStrategy, @NonNull java.util.Properties props, @NonNull JdbcCallable<java.sql.Connection,java.sql.SQLException> connectFunc, @NonNull AtomicConnection candidateConnHolder) throws java.sql.SQLException
candidateConnHolder, returning the HostSpec that
was connected to.
If no substitution is needed, the original endpoint is used. Otherwise, an instance host is selected from the
topology when available; if the topology isn't available yet, a connection is opened via the initial endpoint
(which also confirms the dialect and acts as a fallback) and, when waitForInitialTopologyMs > 0, the
topology fetch is awaited before re-attempting instance selection.
java.sql.SQLExceptionprotected HostSpec waitForTopologyAndConnectToInstance(@NonNull HostSpec originalConnectHost, @NonNull RdsUrlType urlType, @NonNull AuroraInitialConnectionStrategyPlugin.InstanceSubstitutionStrategy substitutionStrategy, @NonNull java.util.Properties props, @NonNull AtomicConnection candidateConnHolder) throws java.sql.SQLException
Returns the selected instance host if the topology was fetched and the instance connection succeeded; the
connection is then held in candidateConnHolder. Otherwise returns originalConnectHost and the
already-opened initial-endpoint connection (still held in candidateConnHolder) is kept as a fallback.
java.sql.SQLExceptionprotected @NonNull AuroraInitialConnectionStrategyPlugin.InstanceSubstitutionStrategy getInstanceSubstitutionStrategy(java.util.Properties props, RdsUrlType urlType, boolean isInitialConnection, @NonNull java.lang.String originalConnectHost) throws java.sql.SQLException
java.sql.SQLExceptionprotected void validateSubstitutionStrategy(@NonNull AuroraInitialConnectionStrategyPlugin.InstanceSubstitutionStrategy setting, RdsUrlType urlType) throws java.sql.SQLException
java.sql.SQLException@Nullable protected HostRole getRoleToVerify(RdsUrlType urlType, boolean isInitialConnection, java.util.Properties props, @NonNull java.lang.String originalConnectHost) throws java.sql.SQLException
java.sql.SQLExceptionprotected void validateVerificationSetting(@NonNull AuroraInitialConnectionStrategyPlugin.RoleVerificationSetting setting, @NonNull RdsUrlType urlType) throws java.sql.SQLException
java.sql.SQLException@Nullable protected HostSpec getCandidateHost(@NonNull HostSpec originalConnectHost, @NonNull RdsUrlType urlType, @NonNull AuroraInitialConnectionStrategyPlugin.InstanceSubstitutionStrategy substitutionStrategy) throws java.sql.SQLException
java.sql.SQLExceptionprotected boolean hasReaders(@NonNull java.util.List<HostSpec> hosts)