Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
{
  "apiKey": 16,
  "type": "request",
  "name": "ListGroupsRequest",
  // Version 1 and 2 are the same as version 0.
  //
  // Version 3 is the first flexible version.
  // KIP-518 adds the States flexible field
  "validVersions": "0-3",
  "flexibleVersions": "3+",
  

  ]
}

Update ListGroupsResponse to include a new field "group_state".

Code Block
{
  "apiKey": 16,
  "type": "response",
  "name": "ListGroupsResponse",
  // Version 1 adds the throttle time.
  //
  // Starting in version 2, on quota violation, brokers send out responses before throttling.
  //
  // Version 3 is the first flexible version.
  "validVersions": "0-3",
  "flexibleVersions": "3+",
  "fields": [
    { "name": "StatesThrottleTimeMs", "type": "[]stringint32", "versions": "3+", "tag": 0, "taggedVersions": "31+", "ignorable": true,
      "about": "The duration in milliseconds for which the request was throttled due to a quota violation, or zero if the request did not violate any quota." },
    { "name": "ErrorCode", "type": "int16", "versions": "0+",
      "about": "The states of the groups we want to listerror code, or 0 if there was no error." },
    { "name": "Groups", "type": "[]ListedGroup", "versions": "0+",
      "about": "Each group in the response.", "fields": [
      { "name": "Name "GroupId", "type": "string", "versions": "0+", "entityType": "groupId",
        "about": "The group ID." },
      { "name": "ProtocolType", "type": "string", "versions": "30+",
        "about": "The group stateprotocol type." },
      

    ]}
  ]
}


If State is not specified or if it's empty in the request, from version 3, all groups will be returned with their states. At the moment, consumer group state is already serialized as a STRING in DescribeGroupsResponse, so serializing it the same way here. ListGroupsResponse is left untouched. If State is not specified or if it's empty, all groups will be returned 

With this KIP, having Describe authorization on the Cluster resource allows to retrieve the state of all groups. Previously this required having Describe authorization on each Group.

AdminClient API

To expose this feature in the AdminClient API, ListConsumerGroupsOptions will be updated.

Code Block
languagejava
titleListConsumerGroupsOptions
public class ListConsumerGroupsOptions extends AbstractOptions<ListConsumerGroupsOptions> {

    /**
     * Only groups in these states will be returned by listConsumerGroups()
     * By default, all groups are returned
     */
    public void inStates(List<ConsumerGroupState> states) {}

    public List<ConsumerGroupState> states() {}
}

Similarly, the state field will be exposed in ConsumerGroupListing:

Code Block
public class ConsumerGroupListing {
    ...
    private final ConsumerGroupState groupState;

    /**
     * Consumer Group State
     */
    public ConsumerGroupState groupState() {
        return groupState;
    }
}

The state will be UNKNOWN when ListGroupRequest < 3 is used, for example when connecting to an older broker.

Command line tools

To expose this feature in the command line tools, ConsumerGroupCommand tool will be updated to support filtering by group states. A new argument "--states" will allow to specify a list of group states. This new option will only be valid when used with "–list". When specified, the state of each group will be printed next to the group id.

For example:

No Format
./kafka-consumer-

...

groups.sh --bootstrap-server localhost:9092 --list
group1
group2

./kafka-consumer-groups.sh --bootstrap-server localhost:9092 --list --states
group1 stable
group2 empty

./kafka-consumer-groups.sh --bootstrap-server localhost:9092 --list --states stable
group1 stable


Compatibility, Deprecation, and Migration Plan

...