CalvinConfluent commented on code in PR #14465:
URL: https://github.com/apache/kafka/pull/14465#discussion_r1362968197


##########
core/src/main/scala/kafka/log/LogManager.scala:
##########
@@ -1409,6 +1410,32 @@ class LogManager(logDirs: Seq[File],
       None
     }
   }
+
+  def readBrokerEpochFromCleanShutdownFiles(): Long = {
+    // Verify whether all the log dirs have the same broker epoch in their 
clean shutdown files. If there are dir is not
+    // live, fail the broker epoch check.
+    if (liveLogDirs.size < logDirs.size) {
+      return -1L
+    }
+    var brokerEpoch = -1L
+    for (dir <- liveLogDirs) {
+        val cleanShutdownFileHandler = new 
CleanShutdownFileHandler(dir.getPath)
+        var textBrokerEpoch = -1L
+        try {
+          textBrokerEpoch = cleanShutdownFileHandler.read
+        } catch {
+          case e: Throwable =>
+            info(s"loading broker epoch from ${dir.toPath} with exception 
${e.toString}")
+            return -1L
+        }
+        if (brokerEpoch != -1 && textBrokerEpoch != brokerEpoch) {
+          info(s"Found different broker epochs a=$brokerEpoch vs 
b=$textBrokerEpoch")

Review Comment:
   We don't track the dir names already iterated, so only log the current dir 
name here.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to