pprovenzano commented on code in PR #14578:
URL: https://github.com/apache/kafka/pull/14578#discussion_r1371668063
##########
core/src/main/scala/kafka/log/LogManager.scala:
##########
@@ -270,26 +270,38 @@ class LogManager(logDirs: Seq[File],
def directoryId(dir: String): Option[Uuid] = dirIds.get(dir)
/**
- * Determine directory ID for each directory with a meta.properties.
+ * Determine directory ID for each directory.
* If meta.properties does not include a directory ID, one is generated and
persisted back to meta.properties.
- * Directories without a meta.properties don't get a directory ID assigned.
+ * Directories without a meta.properties file, which can only occur in Zk
mode, will file have a directory ID assigned.
+ * The ID will be written when the new meta.properties file is first written.
*/
private def directoryIds(dirs: Seq[File]): Map[String, Uuid] = {
+ val s = scala.collection.mutable.Set[Uuid]()
dirs.flatMap { dir =>
try {
val metadataCheckpoint = new BrokerMetadataCheckpoint(new File(dir,
KafkaServer.brokerMetaPropsFile))
- metadataCheckpoint.read().map { props =>
- val rawMetaProperties = new RawMetaProperties(props)
- val uuid = rawMetaProperties.directoryId match {
- case Some(uuidStr) => Uuid.fromString(uuidStr)
- case None =>
- val uuid = Uuid.randomUuid()
- rawMetaProperties.directoryId = uuid.toString
- metadataCheckpoint.write(rawMetaProperties.props)
- uuid
+ val uuid = metadataCheckpoint.read() match {
+ case Some(props) => {
+ val rawMetaProperties = new RawMetaProperties(props)
+ val uuid_from_properties = rawMetaProperties.directoryId match {
+ case Some(uuidStr) => Uuid.fromString(uuidStr)
+ case None =>
+ val uuid_new = Uuid.randomUuid()
+ rawMetaProperties.directoryId = uuid_new.toString
+ metadataCheckpoint.write(rawMetaProperties.props)
+ uuid_new
+ }
+ uuid_from_properties
+ }
+ case None => {
+ Uuid.randomUuid()
Review Comment:
It will get persisted. The only case where we allow a directory to not have
a meta.properties file is in Zk mode. In Zk mode on startup, all directories
without a meta.properties file have one created immediately after the broker is
registered with ZooKeeper.
--
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]