Skip to content

Commit

Permalink
fix(quota): limit the max throttle time (#2180)
Browse files Browse the repository at this point in the history
Signed-off-by: Ning Yu <[email protected]>
  • Loading branch information
Chillax-0v0 authored Nov 26, 2024
1 parent 018833e commit bfc0e61
Showing 1 changed file with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,8 @@ class BrokerQuotaManager(private val config: BrokerQuotaManagerConfig,
maybeRecordAndGetThrottleTimeMs(quotaType, value, timeMs)
}

protected def throttleTime(quotaType: QuotaType, e: QuotaViolationException, timeMs: Long): Long = {
quotaType match {
case QuotaType.SlowFetch | QuotaType.RequestRate =>
QuotaUtils.boundedThrottleTime(e, maxThrottleTimeMs, timeMs)
case _ =>
QuotaUtils.throttleTime(e, timeMs)
}

override protected def throttleTime(e: QuotaViolationException, timeMs: Long): Long = {
QuotaUtils.boundedThrottleTime(e, maxThrottleTimeMs, timeMs)
}

private def isInternalClient(clientId: String): Boolean = {
Expand All @@ -119,7 +113,7 @@ class BrokerQuotaManager(private val config: BrokerQuotaManagerConfig,
0
} catch {
case e: QuotaViolationException =>
val throttleTimeMs = throttleTime(quotaType, e, timeMs).toInt
val throttleTimeMs = throttleTime(e, timeMs).toInt
debug(s"Quota violated for sensor (${clientSensors.quotaSensor.name}). Delay time: ($throttleTimeMs)")
throttleTimeMs
}
Expand Down

0 comments on commit bfc0e61

Please sign in to comment.