Use long instead of int in DB statistics for Queries and Uptime. (#7125)

Co-authored-by: Wei Zhou <weizhou@apache.org>
This commit is contained in:
dahn 2023-01-26 00:53:36 -08:00 committed by GitHub
parent e8c1b5509e
commit f39b02aec7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 12 deletions

View File

@ -807,8 +807,8 @@ public class MetricsServiceImpl extends MutualExclusiveIdsManagerBase implements
private void getQueryHistory(DbMetricsResponse response) { private void getQueryHistory(DbMetricsResponse response) {
Map<String, Object> dbStats = ApiDBUtils.getDbStatistics(); Map<String, Object> dbStats = ApiDBUtils.getDbStatistics();
if (dbStats != null) { if (dbStats != null) {
response.setQueries((Integer)dbStats.get(DbStatsCollection.queries)); response.setQueries((Long)dbStats.get(DbStatsCollection.queries));
response.setUptime((Integer)dbStats.get(DbStatsCollection.uptime)); response.setUptime((Long)dbStats.get(DbStatsCollection.uptime));
} }
List<Double> loadHistory = (List<Double>) dbStats.get(DbStatsCollection.loadAvarages); List<Double> loadHistory = (List<Double>) dbStats.get(DbStatsCollection.loadAvarages);

View File

@ -43,7 +43,7 @@ public class DbMetricsResponse extends BaseResponse {
@SerializedName(MetricConstants.UPTIME) @SerializedName(MetricConstants.UPTIME)
@Param(description = "the uptime of the DB in seconds") @Param(description = "the uptime of the DB in seconds")
private int uptime; private long uptime;
@SerializedName(MetricConstants.TLS_VERSIONS) @SerializedName(MetricConstants.TLS_VERSIONS)
@Param(description = "the tls versions currently in use (accepted) by the DB") @Param(description = "the tls versions currently in use (accepted) by the DB")
@ -59,7 +59,7 @@ public class DbMetricsResponse extends BaseResponse {
@SerializedName(MetricConstants.QUERIES) @SerializedName(MetricConstants.QUERIES)
@Param(description = "the number of queries performed on the DB") @Param(description = "the number of queries performed on the DB")
private int queries; private long queries;
@SerializedName(MetricConstants.DATABASE_LOAD_AVERAGES) @SerializedName(MetricConstants.DATABASE_LOAD_AVERAGES)
@Param(description = "the last measured load averages on the DB") @Param(description = "the last measured load averages on the DB")
@ -77,7 +77,7 @@ public class DbMetricsResponse extends BaseResponse {
this.connections = connections; this.connections = connections;
} }
public void setUptime(int uptime) { public void setUptime(long uptime) {
this.uptime = uptime; this.uptime = uptime;
} }
@ -93,7 +93,7 @@ public class DbMetricsResponse extends BaseResponse {
this.versionComment = versionComment; this.versionComment = versionComment;
} }
public void setQueries(int queries) { public void setQueries(long queries) {
this.queries = queries; this.queries = queries;
} }

View File

@ -714,11 +714,11 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
LOGGER.debug(String.format("%s is running...", this.getClass().getSimpleName())); LOGGER.debug(String.format("%s is running...", this.getClass().getSimpleName()));
try { try {
int lastUptime = (dbStats.containsKey(uptime) ? (Integer) dbStats.get(uptime) : 0); long lastUptime = (dbStats.containsKey(uptime) ? (Long) dbStats.get(uptime) : 0);
int lastQueries = (dbStats.containsKey(queries) ? (Integer) dbStats.get(queries) : 0); long lastQueries = (dbStats.containsKey(queries) ? (Long) dbStats.get(queries) : 0);
getDynamicDataFromDB(); getDynamicDataFromDB();
int interval = (Integer) dbStats.get(uptime) - lastUptime; long interval = (Long) dbStats.get(uptime) - lastUptime;
int activity = (Integer) dbStats.get(queries) - lastQueries; long activity = (Long) dbStats.get(queries) - lastQueries;
loadHistory.add(0, Double.valueOf(activity / interval)); loadHistory.add(0, Double.valueOf(activity / interval));
int maxsize = DATABASE_SERVER_LOAD_HISTORY_RETENTION_NUMBER.value(); int maxsize = DATABASE_SERVER_LOAD_HISTORY_RETENTION_NUMBER.value();
while (loadHistory.size() > maxsize) { while (loadHistory.size() > maxsize) {
@ -736,8 +736,8 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
private void getDynamicDataFromDB() { private void getDynamicDataFromDB() {
Map<String, String> stats = DbUtil.getDbInfo("STATUS", queries, uptime); Map<String, String> stats = DbUtil.getDbInfo("STATUS", queries, uptime);
dbStats.put(collectionTime, new Date()); dbStats.put(collectionTime, new Date());
dbStats.put(queries, (Integer.valueOf(stats.get(queries)))); dbStats.put(queries, (Long.valueOf(stats.get(queries))));
dbStats.put(uptime, (Integer.valueOf(stats.get(uptime)))); dbStats.put(uptime, (Long.valueOf(stats.get(uptime))));
} }