Skip to content

Comments

KAFKA-10545: Create topic IDs in ZooKeeper and Controller#9473

Merged
rajinisivaram merged 10 commits intoapache:trunkfrom
jolshan:KIP516_Controller_and_ZK
Nov 18, 2020
Merged

KAFKA-10545: Create topic IDs in ZooKeeper and Controller#9473
rajinisivaram merged 10 commits intoapache:trunkfrom
jolshan:KIP516_Controller_and_ZK

Conversation

@jolshan
Copy link
Member

@jolshan jolshan commented Oct 21, 2020

Topic IDs must be created for all new topics and all existing topics that do not yet have a topic ID. In ZooKeeper, the ID is written to the TopicZNode, and in the controller, it is stored in a map.

This is a preliminary change before the second part of KAFKA-10545, which will propagate these IDs to brokers.

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

Copy link
Contributor

@rajinisivaram rajinisivaram left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jolshan Thanks for the PR, looks good overall. Left some minor comments.

if (topicIds.get(topic)!= None) {
topicNames.remove(topicIds.get(topic).get)
topicIds.remove(topic)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could do:

topicIds.remove(topic).foreach { topicId =>
  topicNames.remove(topicId)
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about this some more, and I don't think we will have a case where the topic ID is not in the map (the if conditional is not needed.) However, the suggestion you gave is still good because it prevents the extra lookup.

… getTopicIdsForTopics throws IllegalStateException

if one of the topics does not have a topic ID.
var epochZkVersion: Int = KafkaController.InitialControllerEpochZkVersion

val allTopics = mutable.Set.empty[String]
var topicIds = mutable.Map.empty[String, UUID]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these 2 names be more self-explanatory?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What part of the names is unclear? The name describes values of the map, so is it not clear what the keys should be?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, topicIds and topicNames may already enough self-explanatory.

Copy link
Contributor

@rajinisivaram rajinisivaram left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jolshan Thanks for the updates, LGTM

@rajinisivaram
Copy link
Contributor

@jolshan Thanks for the updates, merging to trunk.

@rajinisivaram rajinisivaram merged commit 77a46b1 into apache:trunk Nov 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants