Skip to content

KAFKA-10774; Support Describe topic using topic IDs#9769

Merged
rajinisivaram merged 10 commits intoapache:trunkfrom
dengziming:KAFKA-10774
Aug 28, 2021
Merged

KAFKA-10774; Support Describe topic using topic IDs#9769
rajinisivaram merged 10 commits intoapache:trunkfrom
dengziming:KAFKA-10774

Conversation

@dengziming
Copy link
Member

@dengziming dengziming commented Dec 19, 2020

More detailed description of your change

  1. Add topicNames in MetadataCache and alter KafkaApis.handleTopicMetadataRequest according to the KIP
  2. Add method describeTopics(TopicCollection) in KafkaAdminClient, similar to describeTopics
  3. Change DescribeTopicsResult to support TopicId

Summary of testing strategy (including rationale)
Test locally, here is some result:
New server + new Client

kafka-topics.sh --describe --zookeeper localhost:2181 --topic-id a-Paxi-LSka9sIVy9UFp_Q
Exception in thread "main" java.lang.IllegalArgumentException: --topic-id can used only with --bootstrap-server

kafka-topics.sh --describe --bootstrap-server localhost:9092 --topic-id a-Paxi-LSka9sIVy9UFp_Q
Topic: old-version-topic	TopicId: a-Paxi-LSka9sIVy9UFp_Q	PartitionCount: 2	ReplicationFactor: 1	Configs: segment.bytes=1073741824
	Topic: old-version-topic	Partition: 0	Leader: 0	Replicas: 0	Isr: 0
	Topic: old-version-topic	Partition: 1	Leader: 0	Replicas: 0	Isr: 0

Old Server + new Client

kafka-topics.sh --describe --bootstrap-server localhost:9092 --topic-id a-Paxi-LSka9sIVy9UFp_Q
Error while executing topic command : TopicId a-Paxi-LSka9sIVy9UFp_Q not found.

New server + old client

kafka-topics.sh --describe --bootstrap-server localhost:9092 --topic-id a-Paxi-LSka9sIVy9UFp_Q
Exception in thread "main" joptsimple.UnrecognizedOptionException: topic-id is not a recognized option

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.

@dengziming Thanks for the PR, left some comments. The main thing to watch out for is compatibility of the public API.

@dengziming dengziming force-pushed the KAFKA-10774 branch 2 times, most recently from 0e25260 to 5df1f32 Compare January 13, 2021 14:42
@rajinisivaram
Copy link
Contributor

@dengziming #9814 has been merged, so this needs rebasing and the check for IBP. Thanks.

@jolshan
Copy link
Member

jolshan commented Jan 20, 2021

@dengziming I realized that for this, it really depends on the IBP of the controller. (That is, we need UpdateMetadata to send topic IDs to all the brokers). So maybe instead of checking IBP it would make sense to check if the MetadataCache does not have any topic IDs. What do you think?

@dengziming
Copy link
Member Author

#9769 (comment)

@rajinisivaram @jolshan I also realized this, we add topicId in MetadataCache from IBP=2.8.1, so instead of using config.usesTopicId it would make sense to check config.interBrokerProtocolVersion >= KAFKA_2_8_IV1

@dengziming
Copy link
Member Author

@rajinisivaram I rebased the code and added a test in PlaintextAdminIntegrationTest, PTAL.

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.

@dengziming Thanks for the updates. Left some comments/questions. I ran one of the tests and there were NullPointerExceptions, so those needs fixing as well.

@dengziming
Copy link
Member Author

Hello, @rajinisivaram , I resolved the comments/questions and fixed the NullPointerExceptions, call for a third review.

  1. Add topicId toTopicListing and add TopicCommand.getTopicIds
  2. move the code shared between describeTopics and describeTopicsWithIds to a common private method getTopicDescriptionFromCluster.

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.

@dengziming Thanks for the updates and tests, looks good. Left just a couple of minor comments. @jolshan Can you also review to make sure I haven't missed anything? Thanks.

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.

@dengziming Thanks for the updates, LGTM. Will merge after @jolshan has a chance to review.

@jolshan
Copy link
Member

jolshan commented Jan 25, 2021

Thanks for the updates and all the hard work! I added a few comments. Mostly just questions for clarification.

Copy link
Member

@satishd satishd left a comment

Choose a reason for hiding this comment

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

thanks @dengziming for the PR. Oveall LGTM, left minor comments.

Copy link
Member

@satishd satishd left a comment

Choose a reason for hiding this comment

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

thanks @dengziming for addressing the review comments, LGTM.

@dengziming dengziming force-pushed the KAFKA-10774 branch 2 times, most recently from 8da4a39 to 83c3f0d Compare July 24, 2021 12:49
@dengziming
Copy link
Member Author

@rajinisivaram Are you interested in taking this across finish line? I think this has something that is very close to a first version, we can try to land that and then improvise since this has been worked for a long time, thank you!

@jolshan
Copy link
Member

jolshan commented Jul 28, 2021

@dengziming -- @rajinisivaram can help in about 2 weeks. I will try to help review so it will be ready when she gets to it.

@dengziming dengziming force-pushed the KAFKA-10774 branch 2 times, most recently from cedaec4 to 140ade8 Compare July 31, 2021 08:41
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.

@dengziming Thanks for the updates, looks good. Left some minor comments, I think it is ready to go after that.

dengziming added 9 commits August 27, 2021 22:17
KAFKA-10774; add topicId in TopicCommand
Gate  topic IDs behind IBP 2.8.1
add ITCase of metadata request edge case between different ipb
Add Unauthorized unit test
use matchSameElements replace EasyMock.eq since the order of the request is unknown
resolve conflicts

check KAFKA-12394

check KAFKA-12701
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.

@dengziming Thanks for the updates, LGTM. Sorry about the delay in getting this in and thanks for your patience! Merging to trunk.

@rajinisivaram rajinisivaram merged commit 1d22b0d into apache:trunk Aug 28, 2021
xdgrulez pushed a commit to xdgrulez/kafka that referenced this pull request Dec 22, 2021
Reviewers: Justine Olshan <jolshan@confluent.io>, Chia-Ping Tsai <chia7712@gmail.com>, Satish Duggana <satishd@apache.org>, Rajini Sivaram <rajinisivaram@googlemail.com>
@dengziming dengziming deleted the KAFKA-10774 branch October 8, 2022 11:52
dongjoon-hyun added a commit to apache/spark that referenced this pull request Oct 14, 2025
… the deprecated `all` API

### What changes were proposed in this pull request?

This PR aims to use `DescribeTopicsResult.allTopicNames` API instead of the deprecated `all` API.

### Why are the changes needed?

`all` API was deprecated at Apache Kafka 3.1.0 and removed at 4.0.0.
- apache/kafka#9769
- apache/kafka#18255

> The <code>all()</code> method was removed from the <code>org.apache.kafka.clients.admin.DescribeTopicsResult</code>. Please use <code>allTopicNames()</code> instead.

### Does this PR introduce _any_ user-facing change?

No behavior change.

### How was this patch tested?

Pass the CIs.

### Was this patch authored or co-authored using generative AI tooling?

No.

Closes #52597 from dongjoon-hyun/DescribeTopicsResult.

Authored-by: Dongjoon Hyun <dongjoon@apache.org>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
huangxiaopingRD pushed a commit to huangxiaopingRD/spark that referenced this pull request Nov 25, 2025
… the deprecated `all` API

### What changes were proposed in this pull request?

This PR aims to use `DescribeTopicsResult.allTopicNames` API instead of the deprecated `all` API.

### Why are the changes needed?

`all` API was deprecated at Apache Kafka 3.1.0 and removed at 4.0.0.
- apache/kafka#9769
- apache/kafka#18255

> The <code>all()</code> method was removed from the <code>org.apache.kafka.clients.admin.DescribeTopicsResult</code>. Please use <code>allTopicNames()</code> instead.

### Does this PR introduce _any_ user-facing change?

No behavior change.

### How was this patch tested?

Pass the CIs.

### Was this patch authored or co-authored using generative AI tooling?

No.

Closes apache#52597 from dongjoon-hyun/DescribeTopicsResult.

Authored-by: Dongjoon Hyun <dongjoon@apache.org>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
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.

5 participants

Comments