From 240ca436d8aa57bdc61b6cefb5ca2d589887b64b Mon Sep 17 00:00:00 2001 From: Jiwei Guo Date: Thu, 13 Oct 2022 09:20:16 +0800 Subject: [PATCH] [improve][common] Add thread name for RateLimiter. (#18013) --- .../main/java/org/apache/pulsar/common/util/RateLimiter.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pulsar-common/src/main/java/org/apache/pulsar/common/util/RateLimiter.java b/pulsar-common/src/main/java/org/apache/pulsar/common/util/RateLimiter.java index 8f02bcc0e5cf3..33003af20a0de 100644 --- a/pulsar-common/src/main/java/org/apache/pulsar/common/util/RateLimiter.java +++ b/pulsar-common/src/main/java/org/apache/pulsar/common/util/RateLimiter.java @@ -21,6 +21,7 @@ import static com.google.common.base.Preconditions.checkArgument; import static org.apache.pulsar.common.util.Runnables.catchingAndLoggingThrowables; import com.google.common.base.MoreObjects; +import io.netty.util.concurrent.DefaultThreadFactory; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledThreadPoolExecutor; @@ -80,7 +81,8 @@ public class RateLimiter implements AutoCloseable{ this.executorService = scheduledExecutorService; this.externalExecutor = true; } else { - final ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1); + final ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1, + new DefaultThreadFactory("pulsar-rate-limiter")); executor.setContinueExistingPeriodicTasksAfterShutdownPolicy(false); executor.setExecuteExistingDelayedTasksAfterShutdownPolicy(false); this.executorService = executor;