Skip to content

Conversation

@AndrewJSchofield
Copy link
Member

@AndrewJSchofield AndrewJSchofield commented Apr 15, 2025

The final part of KIP-1043 is to deprecate Admin.listConsumerGroups() in
favour of Admin.listGroups() which works for all group types.

Reviewers: PoAn Yang [email protected], Chia-Ping Tsai
[email protected]

@AndrewJSchofield AndrewJSchofield marked this pull request as ready for review April 15, 2025 19:34
Copy link
Member

@chia7712 chia7712 left a comment

Choose a reason for hiding this comment

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

@AndrewJSchofield thanks for this patch. a couple of comments are left. PTAL

/**
* Returns the list of protocol types that are requested or empty if no protocol types have been specified.
*/
public Set<String> protocolTypes() {
Copy link
Member

Choose a reason for hiding this comment

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

I guess there will be a follow-up to use this field?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I'll add a few more tests. And update the KIP of course.

* <p>
* This is a convenience method for {@link #listConsumerGroups(ListConsumerGroupsOptions)} with default options.
* See the overload for more details.
* @deprecated Since 4.1. Use {@link Admin#listGroups(ListGroupsOptions)} instead.
Copy link
Member

Choose a reason for hiding this comment

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

Use {@link Admin#listGroups()} instead.

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 don't think so. If you want Admin.listGroups() to return just consumer groups, you need to apply a filter to group type and protocol type.

* Only consumer groups will be returned by listGroups().
* This operation sets filters on group type and protocol type which select consumer groups.
*/
public ListGroupsOptions forConsumerGroups() {
Copy link
Member

Choose a reason for hiding this comment

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

This new API is not in KIP-1043, therefore its code style is probably open for discussion 😃

Given that this API appears to be a helper function for creating a specific query, perhaps we could refactor it as a static method.

    public static ListGroupsOptions forConsumerGroups() {
        return new ListGroupsOptions()
                .withTypes(Set.of(GroupType.CLASSIC, GroupType.CONSUMER))
                .withProtocolTypes(Set.of("", ConsumerProtocol.PROTOCOL_TYPE));
    }

and then the code new ListGroupsOptions().forConsumerGroups() can be replaced by ListGroupsOptions.forConsumerGroups()

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I agree. I was trying to see what the best way to express this would be and I like the static method suggestion.

Copy link
Member

@FrankYang0529 FrankYang0529 left a comment

Choose a reason for hiding this comment

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

The ConfigCommand still uses listConsumerGroups. Do we want to update it to listGroups?

case GroupType =>
adminClient.listConsumerGroups().all.get.asScala.map(_.groupId).toSeq

@github-actions github-actions bot added streams core Kafka Broker labels Apr 17, 2025
@chia7712 chia7712 merged commit 8d66481 into apache:trunk Apr 17, 2025
22 of 23 checks passed
@AndrewJSchofield
Copy link
Member Author

@chia7712 I actually discovered a problem with the code running against older brokers. Admin.listGroups(ListGroupsOptions.forConsumerGroups()) actually implies a higher version of ListGroups RPC than Admin.listConsumerGroups(). Since we support back to AK 2.1, the code needs to use an early version of ListGroups. I'll put in another PR.

rreddy-22 pushed a commit to rreddy-22/kafka-rreddy that referenced this pull request Apr 21, 2025
The final part of KIP-1043 is to deprecate Admin.listConsumerGroups() in
favour of Admin.listGroups() which works for all group types.

Reviewers: PoAn Yang <[email protected]>, Chia-Ping Tsai
<[email protected]>
@AndrewJSchofield AndrewJSchofield deleted the KAFKA-17897 branch May 9, 2025 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants