kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rha...@apache.org
Subject [kafka] branch trunk updated: KAFKA-7880:Naming worker thread by task id (#6275)
Date Tue, 05 Mar 2019 00:04:43 GMT
This is an automated email from the ASF dual-hosted git repository.

rhauch pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 20f701c  KAFKA-7880:Naming worker thread by task id (#6275)
20f701c is described below

commit 20f701cc505f6bca01c41f85cb38bbb32554fbfb
Author: Lysss <lyssl0205@gmail.com>
AuthorDate: Tue Mar 5 08:04:34 2019 +0800

    KAFKA-7880:Naming worker thread by task id (#6275)
    
    KAFKA-7880: Name worker thread to include task id
    
    Change Connect's `WorkerTask` to name the thread using the `task-thread-<connectorTaskId>`
pattern.
    
    Reviewers: Randall Hauch <rhauch@gmail.com>
---
 .../src/main/java/org/apache/kafka/connect/runtime/WorkerTask.java    | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/WorkerTask.java
b/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/WorkerTask.java
index 6ea1ddd..9cecb3d 100644
--- a/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/WorkerTask.java
+++ b/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/WorkerTask.java
@@ -51,6 +51,7 @@ import java.util.concurrent.TimeUnit;
  */
 abstract class WorkerTask implements Runnable {
     private static final Logger log = LoggerFactory.getLogger(WorkerTask.class);
+    private static final String THREAD_NAME_PREFIX = "task-thread-";
 
     protected final ConnectorTaskId id;
     private final TaskStatus.Listener statusListener;
@@ -215,7 +216,9 @@ abstract class WorkerTask implements Runnable {
     @Override
     public void run() {
         ClassLoader savedLoader = Plugins.compareAndSwapLoaders(loader);
+        String savedName = Thread.currentThread().getName();
         try {
+            Thread.currentThread().setName(THREAD_NAME_PREFIX + id);
             doRun();
             onShutdown();
         } catch (Throwable t) {
@@ -225,6 +228,7 @@ abstract class WorkerTask implements Runnable {
                 throw (Error) t;
         } finally {
             try {
+                Thread.currentThread().setName(savedName);
                 Plugins.compareAndSwapLoaders(savedLoader);
                 shutdownLatch.countDown();
             } finally {


Mime
View raw message