Skip to content

Commit

Permalink
[server] SN read quota usage should return NaN for stores with no rep…
Browse files Browse the repository at this point in the history
…licas (#1157)

If a store's partition count is small it's normal and expectd to have some
hosts in the cluster to not have any replicas assigned to them. The hosts
should emit NaN for the SN read quota usage metric instead of -1. Emitting
-1 or 0 will mess up aggregation of metrics used for monitoring.
  • Loading branch information
xunyin8 authored Sep 5, 2024
1 parent 9b765b4 commit 38da506
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void setTokenBucket(TokenBucket tokenBucket) {
*/
private Double getReadQuotaUsageRatio() {
if (tokenBucket == null) {
return -1d;
return Double.NaN;
} else {
return tokenBucket.getStaleUsageRatio();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ public void testAggServerQuotaUsageStats() {
double expectedUsageRatio = 0.5;
doReturn(expectedUsageRatio).when(mockTokenBucket).getStaleUsageRatio();

Assert.assertEquals(metricsRepository.getMetric(readQuotaUsageRatioString).value(), -1d);
Assert.assertEquals(metricsRepository.getMetric(readQuotaUsageRatioString).value(), Double.NaN);
aggServerQuotaUsageStats.setStoreTokenBucket(storeName, mockTokenBucket);
Assert.assertEquals(metricsRepository.getMetric(readQuotaUsageRatioString).value(), expectedUsageRatio);
aggServerQuotaUsageStats.setStoreTokenBucket(storeName, null);
Assert.assertEquals(metricsRepository.getMetric(readQuotaUsageRatioString).value(), -1d);
Assert.assertEquals(metricsRepository.getMetric(readQuotaUsageRatioString).value(), Double.NaN);
}
}

0 comments on commit 38da506

Please sign in to comment.