soarez commented on code in PR #14881:
URL: https://github.com/apache/kafka/pull/14881#discussion_r1416235526


##########
core/src/main/scala/kafka/cluster/Partition.scala:
##########
@@ -867,6 +869,26 @@ class Partition(val topicPartition: TopicPartition,
     }
   }
 
+  private def createLogInAssignedDirectoryId(partitionState: 
LeaderAndIsrPartitionState, highWatermarkCheckpoints: OffsetCheckpoints, 
topicId: Option[Uuid], targetLogDirectoryId: Option[Uuid]): Unit = {
+    targetLogDirectoryId match {
+      case Some(directoryId) =>
+        if (logManager.onlineLogDirId(directoryId)) {
+          if (logManager.getLog(topicPartition).isEmpty) {
+            createLogIfNotExists(partitionState.isNew, isFutureReplica = 
false, highWatermarkCheckpoints, topicId, targetLogDirectoryId)
+          } else {
+            logger.info(s"Topic partition 
${topicPartition.topic()}-${topicPartition.partition()} already exists.")
+          }
+        } else if ((!logManager.onlineLogDirId(directoryId) && 
!logManager.hasOfflineLogDirs()) || directoryId == DirectoryId.UNASSIGNED) {
+          // create on next selected directory if the directory Id is LOST or 
unknown and no offline directories or unassigned
+          createLogIfNotExists(partitionState.isNew, isFutureReplica = false, 
highWatermarkCheckpoints, topicId, None)

Review Comment:
   I think if we have a directory ID defined, we can safely set `isNew` to 
`directoryId == DirectoryId.UNASSIGNED`. And then I think we don't need the 
check above for offline directories.



-- 
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