public class RdsHostListProvider extends java.lang.Object implements DynamicHostListProvider, CanReleaseResources
| Modifier and Type | Class and Description |
|---|---|
protected static class |
RdsHostListProvider.FetchTopologyResult |
| Constructor and Description |
|---|
RdsHostListProvider(TopologyUtils topologyUtils,
java.util.Properties properties,
java.lang.String originalUrl,
FullServicesContainer servicesContainer) |
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clear topology cache for the current cluster.
|
java.util.List<HostSpec> |
forceRefresh()
Force a host list provider to update its topology information.
|
java.util.List<HostSpec> |
forceRefresh(boolean shouldVerifyWriter,
long timeoutMs)
Force a host list provider to update its topology information.
|
protected java.util.List<HostSpec> |
forceRefreshMonitor(boolean shouldVerifyWriter,
long timeoutMs) |
java.lang.String |
getClusterId() |
java.util.List<HostSpec> |
getCurrentTopology(java.sql.Connection conn,
HostSpec initialHostSpec)
Get current topology information for the connected database.
|
HostRole |
getHostRole(java.sql.Connection conn)
Evaluates the host role of the given connection - either a writer or a reader.
|
protected ClusterTopologyMonitor |
getOrCreateMonitor() |
RdsUrlType |
getRdsUrlType() |
@Nullable java.util.List<HostSpec> |
getStoredTopology()
Get cached topology.
|
protected RdsHostListProvider.FetchTopologyResult |
getTopology()
Get cluster topology.
|
@Nullable HostSpec |
identifyConnection(java.sql.Connection connection) |
protected void |
init() |
protected void |
initSettings() |
java.util.List<HostSpec> |
refresh() |
void |
releaseResources()
An object that implements this interface should release all acquired resources assuming it may
be disposed at any time.
|
void |
stopMonitor() |
protected void |
validateHostPatternSetting(java.lang.String hostPattern) |
public static final AwsWrapperProperty CLUSTER_TOPOLOGY_REFRESH_RATE_MS
public static final AwsWrapperProperty CLUSTER_ID
public static final AwsWrapperProperty CLUSTER_INSTANCE_HOST_PATTERN
public static final AwsWrapperProperty CLUSTER_TOPOLOGY_HIGH_REFRESH_RATE_MS
protected static final RdsUtils rdsHelper
protected static final ConnectionUrlParser connectionUrlParser
protected static final int DEFAULT_TOPOLOGY_QUERY_TIMEOUT_MS
protected final java.util.concurrent.locks.ReentrantLock lock
protected final java.util.Properties properties
protected final java.lang.String originalUrl
protected final FullServicesContainer servicesContainer
protected final PluginService pluginService
protected final HostListProviderService hostListProviderService
protected final TopologyUtils topologyUtils
protected final long refreshRateNano
protected final long highRefreshRateNano
protected RdsUrlType rdsUrlType
protected java.util.List<HostSpec> initialHostList
protected HostSpec initialHostSpec
protected java.lang.String clusterId
protected HostSpec instanceTemplate
protected volatile boolean isInitialized
public RdsHostListProvider(TopologyUtils topologyUtils, java.util.Properties properties, java.lang.String originalUrl, FullServicesContainer servicesContainer)
protected void init()
throws java.sql.SQLException
java.sql.SQLExceptionprotected void initSettings()
throws java.sql.SQLException
java.sql.SQLExceptionprotected ClusterTopologyMonitor getOrCreateMonitor() throws java.sql.SQLException
java.sql.SQLExceptionpublic java.util.List<HostSpec> getCurrentTopology(java.sql.Connection conn, HostSpec initialHostSpec) throws java.sql.SQLException
HostListProviderStaticHostListProvider. The returned topology should be fresh info returned from a topology
query if `this` is a DynamicHostListProvider,getCurrentTopology in interface HostListProviderconn - the connection to use to query the database for topology information, if needed.initialHostSpec - the host details of the initial connection.java.sql.SQLException - if an error occurs while attempting to acquire the database topology information.protected java.util.List<HostSpec> forceRefreshMonitor(boolean shouldVerifyWriter, long timeoutMs) throws java.sql.SQLException
java.sql.SQLExceptionprotected RdsHostListProvider.FetchTopologyResult getTopology() throws java.sql.SQLException
refreshRateNano).java.sql.SQLException - if errors occurred while retrieving the topology.public @Nullable java.util.List<HostSpec> getStoredTopology() throws java.sql.SQLException
java.sql.SQLExceptionpublic void clear()
public java.util.List<HostSpec> refresh() throws java.sql.SQLException
refresh in interface HostListProviderjava.sql.SQLExceptionpublic RdsUrlType getRdsUrlType() throws java.sql.SQLException
java.sql.SQLExceptionprotected void validateHostPatternSetting(java.lang.String hostPattern)
public java.util.List<HostSpec> forceRefresh() throws java.sql.SQLException, java.util.concurrent.TimeoutException
HostListProviderHostListProvider.forceRefresh(boolean, long) instead.forceRefresh in interface HostListProviderjava.sql.SQLException - if there's errors updating topologyjava.util.concurrent.TimeoutException - if topology update takes longer time than expectedpublic java.util.List<HostSpec> forceRefresh(boolean shouldVerifyWriter, long timeoutMs) throws java.sql.SQLException, java.util.concurrent.TimeoutException
HostListProviderforceRefresh in interface HostListProvidershouldVerifyWriter - a flag indicating that the provider should verify the writer before
returning the updated topology.timeoutMs - timeout in msec to wait until topology is updated or the writer is verified.
If a timeout of 0 is provided, a topology update will be initiated but cached topology
will be returned. If a non-zero timeout is provided and the timeout is hit,
a TimeoutException will be thrown.java.sql.SQLException - if there's errors updating topologyjava.util.concurrent.TimeoutException - if topology update takes longer time than expectedpublic void releaseResources()
CanReleaseResourcesCalling this method does NOT mean that an object is disposing and there won't be any further calls. An object should keep its functional state after calling this method.
releaseResources in interface CanReleaseResourcespublic HostRole getHostRole(java.sql.Connection conn) throws java.sql.SQLException
HostListProvidergetHostRole in interface HostListProviderconn - a connection to the database instance whose role should be determinedjava.sql.SQLException - if there is a problem executing or processing the SQL query used to
determine the host rolepublic @Nullable HostSpec identifyConnection(java.sql.Connection connection) throws java.sql.SQLException
identifyConnection in interface HostListProviderjava.sql.SQLExceptionpublic java.lang.String getClusterId()
throws java.sql.SQLException
getClusterId in interface HostListProviderjava.sql.SQLExceptionpublic void stopMonitor()
stopMonitor in interface HostListProvider