This is an automated email from the ASF dual-hosted git repository.
jolshan pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push:
new 627aaef47e6 MINOR: Duplicate method; The QuotaUtils one is used.
(#15066)
627aaef47e6 is described below
commit 627aaef47e6b36b350b03016882940f8296520de
Author: Afshin Moazami <[email protected]>
AuthorDate: Thu Dec 28 19:01:30 2023 -0500
MINOR: Duplicate method; The QuotaUtils one is used. (#15066)
It seems like this PR (https://github.com/apache/kafka/pull/8768)
duplicated the implementation to QuotaUtils, but didn't remove this
implementation and private methods that is using
Reviewers: Justine Olshan <[email protected]>
---
.../scala/kafka/server/ClientQuotaManager.scala | 26 ----------------------
1 file changed, 26 deletions(-)
diff --git a/core/src/main/scala/kafka/server/ClientQuotaManager.scala
b/core/src/main/scala/kafka/server/ClientQuotaManager.scala
index 411bbc5edd7..73d080b68c0 100644
--- a/core/src/main/scala/kafka/server/ClientQuotaManager.scala
+++ b/core/src/main/scala/kafka/server/ClientQuotaManager.scala
@@ -125,32 +125,6 @@ object ClientQuotaManager {
val User = "user"
val ClientId = "client-id"
}
-
- /**
- * This calculates the amount of time needed to bring the metric within quota
- * assuming that no new metrics are recorded.
- *
- * Basically, if O is the observed rate and T is the target rate over a
window of W, to bring O down to T,
- * we need to add a delay of X to W such that O * W / (W + X) = T.
- * Solving for X, we get X = (O - T)/T * W.
- */
- def throttleTime(e: QuotaViolationException, timeMs: Long): Long = {
- val difference = e.value - e.bound
- // Use the precise window used by the rate calculation
- val throttleTimeMs = difference / e.bound * windowSize(e.metric, timeMs)
- Math.round(throttleTimeMs)
- }
-
- private def windowSize(metric: KafkaMetric, timeMs: Long): Long =
- measurableAsRate(metric.metricName,
metric.measurable).windowSize(metric.config, timeMs)
-
- // Casting to Rate because we only use Rate in Quota computation
- private def measurableAsRate(name: MetricName, measurable: Measurable): Rate
= {
- measurable match {
- case r: Rate => r
- case _ => throw new IllegalArgumentException(s"Metric $name is not a
Rate metric, value $measurable")
- }
- }
}
/**