public class AuroraTopologyService extends Object implements TopologyService
| Modifier and Type | Field and Description |
|---|---|
protected String |
clusterId |
protected HostInfo |
clusterInstanceTemplate |
protected boolean |
gatherPerfMetrics |
protected @MonotonicNonNull ClusterAwareMetrics |
metrics |
protected static ExpiringCache<String,software.aws.rds.jdbc.postgresql.ca.AuroraTopologyService.ClusterTopologyInfo> |
topologyCache |
| Constructor and Description |
|---|
AuroraTopologyService()
Initializes a service with topology default refresh rate.
|
AuroraTopologyService(int refreshRateInMilliseconds)
Initializes a service with provided topology refresh rate.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addToDownHostList(@Nullable HostInfo downHost)
Mark host as down.
|
void |
clear()
Clear topology cache for the current cluster.
|
void |
clearAll()
Clear topology cache for all clusters.
|
@Nullable List<HostInfo> |
getCachedTopology()
Get cached topology.
|
Set<String> |
getDownHosts()
Get a set of host names that were marked down.
|
@Nullable HostInfo |
getLastUsedReaderHost()
Get details about the most recent reader that the driver has successfully connected to.
|
List<HostInfo> |
getTopology(Connection conn,
boolean forceUpdate)
Get cluster topology.
|
protected software.aws.rds.jdbc.postgresql.ca.AuroraTopologyService.ClusterTopologyInfo |
queryForTopology(Connection conn)
Obtain a cluster topology from database.
|
void |
removeFromDownHostList(@Nullable HostInfo host)
Unmark host as down.
|
void |
setClusterId(String clusterId)
Sets cluster Id for a host Different service hosts with the same cluster Id
share topology cache.
|
void |
setClusterInstanceTemplate(HostInfo clusterInstanceTemplate)
Sets host details common to each host in the cluster, including the host dns pattern.
|
static void |
setExpireTime(int expireTimeMs)
Service hosts with the same cluster Id share cluster topology.
|
void |
setLastUsedReaderHost(@Nullable HostInfo reader)
Set details about the most recent reader that the driver has connected to.
|
void |
setPerformanceMetrics(ClusterAwareMetrics metrics,
boolean gatherMetrics)
Initializes the performance metrics
|
void |
setRefreshRate(int refreshRate)
Set new topology refresh rate.
|
protected static final ExpiringCache<String,software.aws.rds.jdbc.postgresql.ca.AuroraTopologyService.ClusterTopologyInfo> topologyCache
protected String clusterId
protected HostInfo clusterInstanceTemplate
protected @MonotonicNonNull ClusterAwareMetrics metrics
protected boolean gatherPerfMetrics
public AuroraTopologyService()
public AuroraTopologyService(int refreshRateInMilliseconds)
refreshRateInMilliseconds - Topology refresh rate in millispublic void setPerformanceMetrics(ClusterAwareMetrics metrics, boolean gatherMetrics)
metrics - The ClusterAwareMetrics instance that will be used to record metricsgatherMetrics - The metric settings that decides whether or not the class should gather metricspublic static void setExpireTime(int expireTimeMs)
expireTimeMs - Topology cache expiration time in millispublic void setClusterId(String clusterId)
setClusterId in interface TopologyServiceclusterId - Topology cluster Idpublic void setClusterInstanceTemplate(HostInfo clusterInstanceTemplate)
Examples: "?.mydomain.com", "db-host.?.mydomain.com"
setClusterInstanceTemplate in interface TopologyServiceclusterInstanceTemplate - Cluster host details including host dns pattern.public List<HostInfo> getTopology(Connection conn, boolean forceUpdate)
refreshRateInMilliseconds).getTopology in interface TopologyServiceconn - 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.protected software.aws.rds.jdbc.postgresql.ca.AuroraTopologyService.ClusterTopologyInfo queryForTopology(Connection conn)
conn - A connection to database to fetch the latest topology.ClusterTopologyInfo instance which contains details of the fetched topologypublic @Nullable List<HostInfo> getCachedTopology()
getCachedTopology in interface TopologyServicepublic @Nullable HostInfo getLastUsedReaderHost()
getLastUsedReaderHost in interface TopologyServicepublic void setLastUsedReaderHost(@Nullable HostInfo reader)
setLastUsedReaderHost in interface TopologyServicereader - A reader host.public Set<String> getDownHosts()
getDownHosts in interface TopologyServicepublic void addToDownHostList(@Nullable HostInfo downHost)
addToDownHostList in interface TopologyServicedownHost - The HostInfo object representing the host to mark as downpublic void removeFromDownHostList(@Nullable HostInfo host)
removeFromDownHostList in interface TopologyServicehost - The HostInfo object representing the host to remove from the list of down hostspublic void setRefreshRate(int refreshRate)
setRefreshRate in interface TopologyServicerefreshRate - Topology refresh rate in millis.public void clearAll()
clearAll in interface TopologyServicepublic void clear()
clear in interface TopologyServiceCopyright © 1997-2021 PostgreSQL Global Development Group. All Rights Reserved.