diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2021-01-13 13:08:12 +0100 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2021-01-13 13:08:12 +0100 |
commit | 4020320a5a99ea84c44d9439df8a5247bb53d877 (patch) | |
tree | c462191a56f2ccd152c4f63165bc3a86c47e3f77 /messagebus | |
parent | 7fe6943d6409a4d8838fb1c618e10b8dfae40382 (diff) |
Ensure minimum window size is never less than 1.0, as that stops the session silently
Diffstat (limited to 'messagebus')
-rw-r--r-- | messagebus/src/main/java/com/yahoo/messagebus/DynamicThrottlePolicy.java | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/messagebus/src/main/java/com/yahoo/messagebus/DynamicThrottlePolicy.java b/messagebus/src/main/java/com/yahoo/messagebus/DynamicThrottlePolicy.java index ab09c9f5720..9aa7529cd8b 100644 --- a/messagebus/src/main/java/com/yahoo/messagebus/DynamicThrottlePolicy.java +++ b/messagebus/src/main/java/com/yahoo/messagebus/DynamicThrottlePolicy.java @@ -105,11 +105,11 @@ public class DynamicThrottlePolicy extends StaticThrottlePolicy { long time = timer.milliTime(); double elapsed = (time - timeOfLastMessage); if (elapsed > IDLE_TIME_MILLIS) { - windowSize = Math.min(windowSize, pendingCount + windowSizeIncrement); + windowSize = Math.max(minWindowSize, Math.min(windowSize, pendingCount + windowSizeIncrement)); } timeOfLastMessage = time; int windowSizeFloored = (int) windowSize; - // Use floating point window sizes, so the algorithm sees the different in 1.1 and 1.9 window size. + // Use floating point window sizes, so the algorithm sees the difference between 1.1 and 1.9 window size. boolean carry = numSent < (windowSize * resizeRate) * (windowSize - windowSizeFloored); return pendingCount < windowSizeFloored + (carry ? 1 : 0); } @@ -257,6 +257,9 @@ public class DynamicThrottlePolicy extends StaticThrottlePolicy { * @return this, to allow chaining */ public DynamicThrottlePolicy setMaxWindowSize(double max) { + if (max < 1) + throw new IllegalArgumentException("Maximum window size cannot be less than one"); + this.maxWindowSize = max; return this; } @@ -279,6 +282,9 @@ public class DynamicThrottlePolicy extends StaticThrottlePolicy { * @return this, to allow chaining */ public DynamicThrottlePolicy setMinWindowSize(double min) { + if (min < 1) + throw new IllegalArgumentException("Minimum window size cannot be less than one"); + this.minWindowSize = min; this.windowSize = Math.max(this.minWindowSize, this.windowSizeIncrement); return this; |