Skip to content

Commit

Permalink
Checkstyle
Browse files Browse the repository at this point in the history
  • Loading branch information
lhotari committed Dec 2, 2023
1 parent e65412c commit e396cd4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
public class PublishRateLimiterImpl implements PublishRateLimiter {
private static final int BURST_FACTOR = 1;
private static final int DEFAULT_CONSISTENT_VIEW_INTERVAL = 10;
private static int CONSISTENT_VIEW_OF_TOKENS_INTERVAL_IN_UNTHROTTLE_LOOP = DEFAULT_CONSISTENT_VIEW_INTERVAL;
private static int consistentViewOfTokensIntervalInUnthrottleLoop = DEFAULT_CONSISTENT_VIEW_INTERVAL;
private volatile AsyncTokenBucket tokenBucketOnMessage;
private volatile AsyncTokenBucket tokenBucketOnByte;
private final LongSupplier clockSource;
Expand All @@ -43,11 +43,11 @@ public class PublishRateLimiterImpl implements PublishRateLimiter {
private final AtomicBoolean unthrottlingScheduled = new AtomicBoolean(false);

public static void switchToConsistentTokensView() {
CONSISTENT_VIEW_OF_TOKENS_INTERVAL_IN_UNTHROTTLE_LOOP = 1;
consistentViewOfTokensIntervalInUnthrottleLoop = 1;
}

public static void resetConsistentTokensViewToDefault() {
CONSISTENT_VIEW_OF_TOKENS_INTERVAL_IN_UNTHROTTLE_LOOP = DEFAULT_CONSISTENT_VIEW_INTERVAL;
consistentViewOfTokensIntervalInUnthrottleLoop = DEFAULT_CONSISTENT_VIEW_INTERVAL;
}

public PublishRateLimiterImpl(Policies policies, String clusterName) {
Expand Down Expand Up @@ -104,7 +104,7 @@ private void scheduleUnthrottling(ScheduledExecutorService executor) {
private void unthrottleQueuedProducers(ScheduledExecutorService executor) {
Producer producer;
int handledProducersCount = 0;
while (containsTokens(handledProducersCount++ % CONSISTENT_VIEW_OF_TOKENS_INTERVAL_IN_UNTHROTTLE_LOOP == 0)
while (containsTokens(handledProducersCount++ % consistentViewOfTokensIntervalInUnthrottleLoop == 0)
&& (producer = unthrottlingQueue.poll()) != null) {
producer.decrementThrottleCount();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ public AsyncTokenBucket(long capacity, long rate, LongSupplier clockSource, long
this.rate = rate;
this.ratePeriodNanos = ratePeriodNanos != -1 ? ratePeriodNanos : ONE_SECOND_NANOS;
this.clockSource = clockSource;
this.minIncrementNanos = minimumIncrementNanos != 0 ?
Math.max(ratePeriodNanos / rate + 1,
this.minIncrementNanos = minimumIncrementNanos != 0 ? Math.max(ratePeriodNanos / rate + 1,
minimumIncrementNanos != -1 ? minimumIncrementNanos : DEFAULT_MINIMUM_INCREMENT_NANOS) : 0;
// The default minimum tokens is the amount of tokens made available in the minimum increment duration
this.defaultMinTokensForPause = Math.max(this.minIncrementNanos * rate / ratePeriodNanos, minTokens);
Expand Down

0 comments on commit e396cd4

Please sign in to comment.