Skip to content

KAFKA-17897: Deprecate Admin.listConsumerGroups #19477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from

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.

@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

*
* @param options The options to use when listing the consumer groups.
* @return The ListConsumerGroupsResult.
*/
@Deprecated
Copy link
Member

Choose a reason for hiding this comment

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

@Deprecated(since = "4.1", forRemoval = true)

*
* @return The ListConsumerGroupsResult.
*/
@Deprecated
Copy link
Member

Choose a reason for hiding this comment

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

@Deprecated(since = "4.1", forRemoval = true)

/**
* 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?

@@ -45,6 +57,11 @@ public ListGroupsOptions inGroupStates(Set<GroupState> groupStates) {
return this;
}

public ListGroupsOptions withProtocolTypes(Set<String> protocolTypes) {
this.protocolTypes = (protocolTypes == null || protocolTypes.isEmpty()) ? Set.of() : Set.copyOf(protocolTypes);
Copy link
Member

Choose a reason for hiding this comment

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

Could you please change the Collections.emptySet() to Set.of for the line#56?

ListConsumerGroupsResult listConsumerGroups(ListConsumerGroupsOptions options);

/**
* List the consumer groups available in the cluster with the default options.
* <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.

* 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()

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.

2 participants