public class RdsHostListProvider extends java.lang.Object implements DynamicHostListProvider
| Modifier and Type | Field and Description |
|---|---|
static AwsWrapperProperty |
CLUSTER_ID |
static AwsWrapperProperty |
CLUSTER_INSTANCE_HOST_PATTERN |
static AwsWrapperProperty |
CLUSTER_TOPOLOGY_REFRESH_RATE_MS |
protected java.lang.String |
clusterId |
protected HostSpec |
clusterInstanceTemplate |
protected ConnectionUrlParser |
connectionUrlParser |
protected boolean |
isInitialized |
protected boolean |
isPrimaryClusterId |
static CacheMap<java.lang.String,java.lang.Boolean> |
primaryClusterIdCache |
static CacheMap<java.lang.String,java.lang.String> |
suggestedPrimaryClusterIdCache |
static CacheMap<java.lang.String,java.util.List<HostSpec>> |
topologyCache |
| Constructor and Description |
|---|
RdsHostListProvider(java.util.Properties properties,
java.lang.String originalUrl,
HostListProviderService hostListProviderService,
java.lang.String topologyQuery,
java.lang.String nodeIdQuery,
java.lang.String isReaderQuery) |
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clear topology cache for the current cluster.
|
static void |
clearAll()
Clear topology cache for all clusters.
|
java.util.List<HostSpec> |
forceRefresh() |
java.util.List<HostSpec> |
forceRefresh(java.sql.Connection connection) |
@Nullable java.util.List<HostSpec> |
getCachedTopology()
Get cached topology.
|
HostRole |
getHostRole(java.sql.Connection conn)
Evaluates the host role of the given connection - either a writer or a reader.
|
RdsUrlType |
getRdsUrlType() |
software.amazon.jdbc.hostlistprovider.RdsHostListProvider.FetchTopologyResult |
getTopology(java.sql.Connection conn,
boolean forceUpdate)
Get cluster topology.
|
HostSpec |
identifyConnection(java.sql.Connection connection) |
protected void |
init() |
static void |
logCache() |
protected java.util.List<HostSpec> |
queryForTopology(java.sql.Connection conn)
Obtain a cluster topology from database.
|
java.util.List<HostSpec> |
refresh() |
java.util.List<HostSpec> |
refresh(java.sql.Connection connection) |
protected void |
suggestPrimaryCluster(@NonNull java.util.List<HostSpec> primaryClusterHosts) |
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 CacheMap<java.lang.String,java.lang.String> suggestedPrimaryClusterIdCache
public static final CacheMap<java.lang.String,java.lang.Boolean> primaryClusterIdCache
protected java.lang.String clusterId
protected HostSpec clusterInstanceTemplate
protected ConnectionUrlParser connectionUrlParser
protected boolean isPrimaryClusterId
protected boolean isInitialized
public RdsHostListProvider(java.util.Properties properties,
java.lang.String originalUrl,
HostListProviderService hostListProviderService,
java.lang.String topologyQuery,
java.lang.String nodeIdQuery,
java.lang.String isReaderQuery)
protected void init()
throws java.sql.SQLException
java.sql.SQLExceptionpublic software.amazon.jdbc.hostlistprovider.RdsHostListProvider.FetchTopologyResult getTopology(java.sql.Connection conn,
boolean forceUpdate)
throws java.sql.SQLException
refreshRateNano).conn - A connection to database to fetch the latest topology, if needed.forceUpdate - If true, it forces a service to ignore cached copy of topology and to fetch
a fresh one.java.sql.SQLException - if errors occurred while retrieving the topology.protected void suggestPrimaryCluster(@NonNull java.util.List<HostSpec> primaryClusterHosts)
protected java.util.List<HostSpec> queryForTopology(java.sql.Connection conn) throws java.sql.SQLException
conn - A connection to database to fetch the latest topology.HostSpec objects representing the topologyjava.sql.SQLException - if errors occurred while retrieving the topology.public @Nullable java.util.List<HostSpec> getCachedTopology()
public static void clearAll()
public void clear()
public java.util.List<HostSpec> refresh() throws java.sql.SQLException
refresh in interface HostListProviderjava.sql.SQLExceptionpublic java.util.List<HostSpec> refresh(java.sql.Connection connection) throws java.sql.SQLException
refresh in interface HostListProviderjava.sql.SQLExceptionpublic java.util.List<HostSpec> forceRefresh() throws java.sql.SQLException
forceRefresh in interface HostListProviderjava.sql.SQLExceptionpublic java.util.List<HostSpec> forceRefresh(java.sql.Connection connection) throws java.sql.SQLException
forceRefresh in interface HostListProviderjava.sql.SQLExceptionpublic RdsUrlType getRdsUrlType() throws java.sql.SQLException
java.sql.SQLExceptionpublic static void logCache()
public 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 HostSpec identifyConnection(java.sql.Connection connection) throws java.sql.SQLException
identifyConnection in interface HostListProviderjava.sql.SQLException