tombentley commented on code in PR #12347:
URL: https://github.com/apache/kafka/pull/12347#discussion_r925348863


##########
core/src/main/scala/kafka/log/LogLoader.scala:
##########
@@ -64,6 +65,7 @@ object LogLoader extends Logging {
  * @param recoveryPointCheckpoint The checkpoint of the offset at which to 
begin the recovery
  * @param leaderEpochCache An optional LeaderEpochFileCache instance to be 
updated during recovery
  * @param producerStateManager The ProducerStateManager instance to be updated 
during recovery
+ * @param numRemainingSegments The remaining segments to be recovered in this 
log

Review Comment:
   ```suggestion
    * @param numRemainingSegments The remaining segments to be recovered in 
this log keyed by recovery thread name
   ```



##########
core/src/main/scala/kafka/log/LogManager.scala:
##########
@@ -307,6 +309,27 @@ class LogManager(logDirs: Seq[File],
     log
   }
 
+  // factory class for naming the log recovery threads used in metrics
+  class LogRecoveryThreadFactory(val dirPath: String) extends ThreadFactory {
+    val threadNum = new AtomicInteger(0)
+
+    override def newThread(runnable: Runnable): Thread = {
+      KafkaThread.nonDaemon(logRecoveryThreadName(dirPath, 
threadNum.getAndIncrement()), runnable)
+    }
+  }
+
+  // create a unique log recovery thread name for each log dir as the format: 
prefix-dirPath-threadNum, ex: "log-recovery-/tmp/kafkaLogs-0"
+  private def logRecoveryThreadName(dirPath: String, threadNum: Int, prefix: 
String = "log-recovery"): String = s"$prefix-$dirPath-$threadNum"
+
+  /*
+   * decrement the number of remaining logs
+   * @return the number of remaining logs after decremented 1
+   */
+  private[log] def decNumRemainingLogs(numRemainingLogs: ConcurrentMap[String, 
AtomicInteger], path: String): Int = {
+    require(path != null, "path cannot be null to update remaining logs 
metric.")
+    numRemainingLogs.get(path).decrementAndGet()

Review Comment:
   Is it not possible to use `numRemainingLogs.compute()` and avoid the need 
for the `AtomicInteger`?



-- 
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-unsubscr...@kafka.apache.org

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

Reply via email to