public class RdsHostListProvider extends java.lang.Object implements DynamicHostListProvider, CanReleaseResources
| Modifier and Type | Class and Description |
|---|---|
protected static class |
RdsHostListProvider.FetchTopologyResult |
| Modifier and Type | Field and Description |
|---|---|
static AwsWrapperProperty |
CLUSTER_ID |
static AwsWrapperProperty |
CLUSTER_INSTANCE_HOST_PATTERN |
static AwsWrapperProperty |
CLUSTER_TOPOLOGY_HIGH_REFRESH_RATE_MS |
static AwsWrapperProperty |
CLUSTER_TOPOLOGY_REFRESH_RATE_MS |
protected java.lang.String |
clusterId |
protected static ConnectionUrlParser |
connectionUrlParser |
protected static int |
DEFAULT_TOPOLOGY_QUERY_TIMEOUT_MS |
protected long |
highRefreshRateNano |
protected HostListProviderService |
hostListProviderService |
protected java.util.List<HostSpec> |
initialHostList |
protected HostSpec |
initialHostSpec |
protected HostSpec |
instanceTemplate |
protected boolean |
isInitialized |
protected ResourceLock |
lock |
protected java.lang.String |
originalUrl |
protected PluginService |
pluginService |
protected java.util.Properties |
properties |
protected static RdsUtils |
rdsHelper |
protected RdsUrlType |
rdsUrlType |
protected long |
refreshRateNano |
protected FullServicesContainer |
servicesContainer |
protected TopologyUtils |
topologyUtils |
| 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.
|
@Nullable java.util.List<HostSpec> |
forceRefresh()
Force a host list provider to update its topology information.
|
@Nullable java.util.List<HostSpec> |
forceRefresh(boolean verifyTopology,
long timeoutMs)
Force a host list provider to update its topology information.
|
protected @Nullable java.util.List<HostSpec> |
forceRefreshMonitor(boolean verifyTopology,
long timeoutMs) |
java.lang.String |
getClusterId() |
@Nullable java.util.List<HostSpec> |
getCurrentTopology(java.sql.Connection conn,
HostSpec initialHostSpec)
Get current topology information for the connected database.
|
protected ClusterTopologyMonitor |
getOrCreateMonitor() |
RdsUrlType |
getRdsUrlType() |
@Nullable java.util.List<HostSpec> |
getStoredTopology()
Get cached topology.
|
protected RdsHostListProvider.FetchTopologyResult |
getTopology()
Get cluster topology.
|
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 ResourceLock 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 @Nullable 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 @Nullable java.util.List<HostSpec> forceRefreshMonitor(boolean verifyTopology, 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.SQLException - if errors occurred while retrieving the topology.public 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 @Nullable 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 @Nullable java.util.List<HostSpec> forceRefresh(boolean verifyTopology, long timeoutMs) throws java.sql.SQLException, java.util.concurrent.TimeoutException
HostListProviderforceRefresh in interface HostListProviderverifyTopology - defines whether extra measures should be taken to verify the topology. If false, the method
will return as soon as topology is successfully retrieved from any instance. If true, extra
steps are taken to verify the topology is accurate.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 the timeout is hitpublic 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 java.lang.String getClusterId()
throws java.sql.SQLException
getClusterId in interface HostListProviderjava.sql.SQLExceptionpublic void stopMonitor()
stopMonitor in interface HostListProvider