You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/07/09 12:33:56 UTC

[GitHub] [kafka] showuon commented on a change in pull request #11006: KAFKA-13049: Name the threads used for log recovery

showuon commented on a change in pull request #11006:
URL: https://github.com/apache/kafka/pull/11006#discussion_r666913262



##########
File path: core/src/main/scala/kafka/log/LogManager.scala
##########
@@ -312,7 +312,15 @@ class LogManager(logDirs: Seq[File],
       val logDirAbsolutePath = dir.getAbsolutePath
       var hadCleanShutdown: Boolean = false
       try {
-        val pool = Executors.newFixedThreadPool(numRecoveryThreadsPerDataDir)
+        val pool = Executors.newFixedThreadPool(numRecoveryThreadsPerDataDir, new ThreadFactory {
+          private val factory = Executors.defaultThreadFactory()
+          private val threadNumber = new AtomicInteger(1)
+          override def newThread(r: Runnable): Thread = {
+            val thread = factory.newThread(r)
+            thread.setName(s"log-recovery(${dir.getAbsolutePath}, ${threadNumber.getAndIncrement()})")

Review comment:
       we can replace `dir.getAbsolutePath` with local variable `logDirAbsolutePath`

##########
File path: core/src/main/scala/kafka/log/LogManager.scala
##########
@@ -312,7 +312,15 @@ class LogManager(logDirs: Seq[File],
       val logDirAbsolutePath = dir.getAbsolutePath
       var hadCleanShutdown: Boolean = false
       try {
-        val pool = Executors.newFixedThreadPool(numRecoveryThreadsPerDataDir)
+        val pool = Executors.newFixedThreadPool(numRecoveryThreadsPerDataDir, new ThreadFactory {
+          private val factory = Executors.defaultThreadFactory()
+          private val threadNumber = new AtomicInteger(1)
+          override def newThread(r: Runnable): Thread = {
+            val thread = factory.newThread(r)
+            thread.setName(s"log-recovery(${dir.getAbsolutePath}, ${threadNumber.getAndIncrement()})")

Review comment:
       nit: Do you think it is better to use dash (-) to concat path and threadNumber?
   s"log-recovery(${dir.getAbsolutePath}**-**${threadNumber.getAndIncrement()})"




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org