Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Issue 11581][broker] feat:pass the executor to RateLimiter in ResourceGroupPublishLimiter #11582

Merged
merged 5 commits into from Aug 21, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -95,14 +95,14 @@ public void update(ResourceGroup resourceGroup) {
this.publishMaxMessageRate = Math.max(resourceGroup.getPublishRateInMsgs(), 0);
this.publishMaxByteRate = Math.max(resourceGroup.getPublishRateInBytes(), 0);
if (this.publishMaxMessageRate > 0) {
// TODO: pass the executor
publishRateLimiterOnMessage =
new RateLimiter(publishMaxMessageRate, 1, TimeUnit.SECONDS, this::apply);
new RateLimiter(scheduledExecutorService, publishMaxMessageRate, 1, TimeUnit.SECONDS,
this::apply);
}
if (this.publishMaxByteRate > 0) {
// TODO: pass the executor
publishRateLimiterOnByte =
new RateLimiter(publishMaxByteRate, 1, TimeUnit.SECONDS, this::apply);
new RateLimiter(scheduledExecutorService, publishMaxByteRate, 1, TimeUnit.SECONDS,
this::apply);
}
} else {
this.publishMaxMessageRate = 0;
Expand Down
Expand Up @@ -92,6 +92,11 @@ public RateLimiter(final ScheduledExecutorService service, final long permits, f
this(service, permits, rateTime, timeUnit, permitUpdater, false);
}

public RateLimiter(final ScheduledExecutorService service, final long permits, final long rateTime,
lhotari marked this conversation as resolved.
Show resolved Hide resolved
final TimeUnit timeUnit, RateLimitFunction autoReadResetFunction) {
this(service, permits, rateTime, timeUnit, null,false,autoReadResetFunction);
}

public RateLimiter(final ScheduledExecutorService service, final long permits, final long rateTime,
final TimeUnit timeUnit, Supplier<Long> permitUpdater, boolean isDispatchOrPrecisePublishRateLimiter) {
this(service, permits, rateTime, timeUnit, permitUpdater, isDispatchOrPrecisePublishRateLimiter,
Expand Down