public abstract class TopologyUtils
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected static int |
DEFAULT_QUERY_TIMEOUT_MS |
protected TopologyDialect |
dialect |
protected HostSpecBuilder |
hostSpecBuilder |
protected java.util.concurrent.Executor |
networkTimeoutExecutor |
| Constructor and Description |
|---|
TopologyUtils(TopologyDialect dialect,
HostSpecBuilder hostSpecBuilder) |
| Modifier and Type | Method and Description |
|---|---|
HostSpec |
createHost(@Nullable java.lang.String instanceId,
@Nullable java.lang.String instanceName,
boolean isWriter,
long weight,
@Nullable java.lang.Float cpuPercent,
@Nullable java.lang.Float lag,
@Nullable java.sql.Timestamp lastUpdateTime,
HostSpec initialHostSpec,
HostSpec instanceTemplate)
Creates a
HostSpec from the given topology information, including a load value. |
HostSpec |
createHost(@Nullable java.lang.String instanceId,
@Nullable java.lang.String instanceName,
boolean isWriter,
long weight,
@Nullable java.sql.Timestamp lastUpdateTime,
HostSpec initialHostSpec,
HostSpec instanceTemplate)
Creates a
HostSpec from the given topology information. |
protected abstract @Nullable java.util.List<HostSpec> |
getHosts(java.sql.Connection conn,
java.sql.ResultSet rs,
HostSpec initialHostSpec,
HostSpec instanceTemplate) |
abstract boolean |
isWriterInstance(java.sql.Connection connection)
Evaluate whether the given connection is to a writer instance.
|
@Nullable java.util.List<HostSpec> |
queryForTopology(java.sql.Connection conn,
HostSpec initialHostSpec,
HostSpec instanceTemplate)
Query the database for information for each instance in the database topology.
|
protected Pair<java.lang.Integer,java.lang.Boolean> |
setNetworkTimeout(java.sql.Connection conn) |
protected @Nullable java.util.List<HostSpec> |
verifyWriter(@Nullable java.util.List<HostSpec> allHosts) |
protected static final int DEFAULT_QUERY_TIMEOUT_MS
protected final java.util.concurrent.Executor networkTimeoutExecutor
protected final TopologyDialect dialect
protected final HostSpecBuilder hostSpecBuilder
public TopologyUtils(TopologyDialect dialect, HostSpecBuilder hostSpecBuilder)
public @Nullable java.util.List<HostSpec> queryForTopology(java.sql.Connection conn, HostSpec initialHostSpec, HostSpec instanceTemplate) throws java.sql.SQLException
conn - the connection to use to query the database.initialHostSpec - the HostSpec that was used to initially connect.instanceTemplate - the template HostSpec to use when constructing new HostSpec objects from
the data returned by the topology query.HostSpec objects representing the results of the topology query.java.sql.SQLException - if an error occurs when executing the topology or processing the results.protected Pair<java.lang.Integer,java.lang.Boolean> setNetworkTimeout(java.sql.Connection conn)
protected abstract @Nullable java.util.List<HostSpec> getHosts(java.sql.Connection conn, java.sql.ResultSet rs, HostSpec initialHostSpec, HostSpec instanceTemplate) throws java.sql.SQLException
java.sql.SQLExceptionprotected @Nullable java.util.List<HostSpec> verifyWriter(@Nullable java.util.List<HostSpec> allHosts)
public HostSpec createHost(@Nullable java.lang.String instanceId, @Nullable java.lang.String instanceName, boolean isWriter, long weight, @Nullable java.sql.Timestamp lastUpdateTime, HostSpec initialHostSpec, HostSpec instanceTemplate)
HostSpec from the given topology information.instanceId - the database instance identifier, e.g. "mydb-instance-1"
or "db-WQFQKBTL2LQUPIEFIFBGENS4ZQ".instanceName - the database instance name, e.g. "mydb-instance-1.cluster-xxxxx.region.rds.amazonaws.com".isWriter - true if this is a writer instance, false for reader.weight - the instance weight for load balancing.lastUpdateTime - the timestamp of the last update to this instance's information.initialHostSpec - the original host specification used for connecting.instanceTemplate - the template used to construct the new HostSpec.HostSpec representing the given information.public HostSpec createHost(@Nullable java.lang.String instanceId, @Nullable java.lang.String instanceName, boolean isWriter, long weight, @Nullable java.lang.Float cpuPercent, @Nullable java.lang.Float lag, @Nullable java.sql.Timestamp lastUpdateTime, HostSpec initialHostSpec, HostSpec instanceTemplate)
HostSpec from the given topology information, including a load value.instanceId - the database instance identifier.instanceName - the database instance name.isWriter - true if this is a writer instance, false for reader.weight - the instance weight for load balancing.lastUpdateTime - the timestamp of the last update to this instance's information.initialHostSpec - the original host specification used for connecting.instanceTemplate - the template used to construct the new HostSpec.HostSpec representing the given information.public abstract boolean isWriterInstance(java.sql.Connection connection)
throws java.sql.SQLException
connection - the connection to evaluate.java.sql.SQLException - if an exception occurs when querying the database or processing the database response.