public class FastestResponseStrategyPlugin extends AbstractConnectionPlugin
| Modifier and Type | Field and Description |
|---|---|
protected static CacheMap<java.lang.String,HostSpec> |
cachedFastestResponseHostByRole |
protected long |
cacheExpirationNano |
static java.lang.String |
FASTEST_RESPONSE_STRATEGY_NAME |
protected @NonNull HostResponseTimeService |
hostResponseTimeService |
protected java.util.List<HostSpec> |
hosts |
protected @NonNull PluginService |
pluginService |
protected @NonNull java.util.Properties |
properties |
protected static RandomHostSelector |
randomHostSelector |
static AwsWrapperProperty |
RESPONSE_MEASUREMENT_INTERVAL_MILLIS |
| Constructor and Description |
|---|
FastestResponseStrategyPlugin(FullServicesContainer servicesContainer,
@NonNull java.util.Properties properties) |
FastestResponseStrategyPlugin(@NonNull PluginService pluginService,
@NonNull java.util.Properties properties,
@NonNull HostResponseTimeService hostResponseTimeService) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
acceptsStrategy(HostRole role,
java.lang.String strategy)
Returns a boolean indicating if this
ConnectionPlugin implements the specified host
selection strategy for the given role in ConnectionPlugin.getHostSpecByStrategy(software.amazon.jdbc.HostRole, java.lang.String). |
static void |
clearCache() |
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.
|
HostSpec |
getHostSpecByStrategy(HostRole role,
java.lang.String strategy)
Selects a
HostSpec with the requested role from available hosts using the requested
strategy. |
java.util.Set<java.lang.String> |
getSubscribedMethods() |
void |
notifyNodeListChanged(java.util.Map<java.lang.String,java.util.EnumSet<NodeChangeOptions>> changes) |
execute, forceConnect, getHostSpecByStrategy, initHostProvider, notifyConnectionChangedpublic static final java.lang.String FASTEST_RESPONSE_STRATEGY_NAME
public static final AwsWrapperProperty RESPONSE_MEASUREMENT_INTERVAL_MILLIS
protected static final CacheMap<java.lang.String,HostSpec> cachedFastestResponseHostByRole
protected static final RandomHostSelector randomHostSelector
protected final @NonNull PluginService pluginService
protected final @NonNull java.util.Properties properties
protected final @NonNull HostResponseTimeService hostResponseTimeService
protected long cacheExpirationNano
protected java.util.List<HostSpec> hosts
public FastestResponseStrategyPlugin(FullServicesContainer servicesContainer, @NonNull java.util.Properties properties)
public FastestResponseStrategyPlugin(@NonNull PluginService pluginService, @NonNull java.util.Properties properties, @NonNull HostResponseTimeService hostResponseTimeService)
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
hostpublic boolean acceptsStrategy(HostRole role, java.lang.String strategy)
ConnectionPluginConnectionPlugin implements the specified host
selection strategy for the given role in ConnectionPlugin.getHostSpecByStrategy(software.amazon.jdbc.HostRole, java.lang.String).acceptsStrategy in interface ConnectionPluginacceptsStrategy in class AbstractConnectionPluginrole - the desired host rolestrategy - the strategy that should be used to pick a host (eg "random")ConnectionPlugin supports the selection of a host with the requested role and strategy
via ConnectionPlugin.getHostSpecByStrategy(software.amazon.jdbc.HostRole, java.lang.String). Otherwise, return false.public HostSpec getHostSpecByStrategy(HostRole role, java.lang.String strategy) throws java.sql.SQLException, java.lang.UnsupportedOperationException
ConnectionPluginHostSpec with the requested role from available hosts using the requested
strategy. ConnectionPlugin.acceptsStrategy(software.amazon.jdbc.HostRole, java.lang.String) should be called first to evaluate if this
ConnectionPlugin supports the selection of a host with the requested role and
strategy.getHostSpecByStrategy in interface ConnectionPlugingetHostSpecByStrategy in class AbstractConnectionPluginrole - 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 hosts do not contain any hosts matching
the requested role or an error occurs while selecting a
hostjava.lang.UnsupportedOperationException - if this ConnectionPlugin does not support the
requested strategypublic void notifyNodeListChanged(java.util.Map<java.lang.String,java.util.EnumSet<NodeChangeOptions>> changes)
notifyNodeListChanged in interface ConnectionPluginnotifyNodeListChanged in class AbstractConnectionPluginpublic static void clearCache()