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 TopologyService
clusterId
- Topology cluster Idpublic void setClusterInstanceTemplate(HostInfo clusterInstanceTemplate)
Examples: "?.mydomain.com", "db-host.?.mydomain.com"
setClusterInstanceTemplate
in interface TopologyService
clusterInstanceTemplate
- Cluster host details including host dns pattern.public List<HostInfo> getTopology(Connection conn, boolean forceUpdate)
refreshRateInMilliseconds
).getTopology
in interface TopologyService
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.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 TopologyService
public @Nullable HostInfo getLastUsedReaderHost()
getLastUsedReaderHost
in interface TopologyService
public void setLastUsedReaderHost(@Nullable HostInfo reader)
setLastUsedReaderHost
in interface TopologyService
reader
- A reader host.public Set<String> getDownHosts()
getDownHosts
in interface TopologyService
public void addToDownHostList(@Nullable HostInfo downHost)
addToDownHostList
in interface TopologyService
downHost
- The HostInfo
object representing the host to mark as downpublic void removeFromDownHostList(@Nullable HostInfo host)
removeFromDownHostList
in interface TopologyService
host
- The HostInfo
object representing the host to remove from the list of down hostspublic void setRefreshRate(int refreshRate)
setRefreshRate
in interface TopologyService
refreshRate
- Topology refresh rate in millis.public void clearAll()
clearAll
in interface TopologyService
public void clear()
clear
in interface TopologyService
Copyright © 1997-2021 PostgreSQL Global Development Group. All Rights Reserved.