Skip to content

KAFKA-16095: Update list group state type filter to include the states for the new consumer group type#15211

Merged
dajac merged 7 commits into
apache:trunkfrom
DL1231:KAFKA-16095
Jan 29, 2024
Merged

KAFKA-16095: Update list group state type filter to include the states for the new consumer group type#15211
dajac merged 7 commits into
apache:trunkfrom
DL1231:KAFKA-16095

Conversation

@DL1231

@DL1231 DL1231 commented Jan 17, 2024

Copy link
Copy Markdown
Collaborator

While using —list —state the current accepted values correspond to the classic group type states.
This PR include support for the new group type states.

Committer Checklist (excluded from commit message)

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

@DL1231

DL1231 commented Jan 17, 2024

Copy link
Copy Markdown
Collaborator Author

@rreddy-22 PTAL.

@rreddy-22 rreddy-22 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the PR! Left a few comments

Comment thread clients/src/main/java/org/apache/kafka/common/ConsumerGroupState.java Outdated
Comment thread core/src/test/scala/unit/kafka/admin/ListConsumerGroupTest.scala
@jolshan jolshan added the KIP-848 The Next Generation of the Consumer Rebalance Protocol label Jan 19, 2024
@DL1231

DL1231 commented Jan 22, 2024

Copy link
Copy Markdown
Collaborator Author

@rreddy-22 Thanks for your comments. I addressed them.

@rreddy-22 rreddy-22 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the update! We're currently still straightening out the details on how to implement the case insensitivity for the group type filter. I'll get back to you asap once we figure that out!

@dajac dajac left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@DL1231 Thanks for the PR. I left a few comments/suggestions.

@DL1231

DL1231 commented Jan 25, 2024

Copy link
Copy Markdown
Collaborator Author

Thanks for the suggestion @dajac . I have addressed the comments.

@dajac dajac left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@DL1231 Thanks for the update! I left a few nits and some suggestions for considerations.

}

ClassicGroupState(String name) {
ClassicGroupState(String name, String lowerCaseName) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: I wonder if we could remove the lowerCaseName parameter and lower case the name in the constructor. Would it work?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done.

return name;
}

public String toLowerCaseString() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: I wonder if we should also add toLowerCaseString to ConsumerGroup.ConsumerGroupState in order to be consistent.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Actually, it would be great to do the same there. We could also capitatlize the states to be consistent too.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for the suggestion, I added the toCapitalizedString to ConsumerGroup.ConsumerGroupState.


@Override
public boolean isInStatesCaseInsensitive(List<String> statesFilter, long committedOffset) {
Set<String> caseInsensitiveFilterSet = statesFilter.stream().map(String::toLowerCase).map(String::trim).collect(Collectors.toSet());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It is a tad annoying to call toLowerCase here because we have to do it for every group. Would it be better to keep this part on the calling side?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done.

/**
* @return The {{@link GroupType}}'s LowerCase String representation based on the committed offset.
*/
String stateAsLowerCaseString(long committedOffset);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It seems that we only access it from within the class so we could remove it from the interface.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@DL1231

DL1231 commented Jan 27, 2024

Copy link
Copy Markdown
Collaborator Author

@dajac

Addressed your review comments. PTAL when you get chance!

@dajac

dajac commented Jan 28, 2024

Copy link
Copy Markdown
Member

@DL1231 Thanks. I’ll review it on Monday. I had a quick
look at the tests and there are related failures. Could you please check them?

@dajac dajac left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@DL1231 Thanks for the update. I left a few minor comments. Please let me know what you think.


@Override
public boolean isInStates(Set<String> statesFilter, long committedOffset) {
return statesFilter.contains(this.stateAsLowerCaseString()) || statesFilter.contains(this.stateAsString());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am not sure to understand why do we need to check both versions here? If the statesFilter are lowercased, the first one should be enough, no?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

In my opinion, the statefilter cannot be guaranteed to be in lowercase, there might be that the method isinstates is called without doing the lowercase conversion, so needs to check for both versions here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah, it is not but in this context we know that it is. Could we address this by clarifying the requirement in the javadoc? My point is that if statesFilter is not lowercased, it won't work anyway because you could also received something like sTable.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Comment on lines +964 to +966
public String stateAsLowerCaseString() {
return this.state.toLowerCaseString();
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We could probably remove this one and inline it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Comment on lines +760 to +761
return statesFilter.contains(this.stateAsCapitalizedString(committedOffset)) || statesFilter.contains(
this.stateAsString(committedOffset));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same question about checking the two versions here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Comment on lines +754 to +756
public String stateAsCapitalizedString(long committedOffset) {
return state.get(committedOffset).toCapitalizedString();
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same suggestion about inlining it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done.

}

def isInStates(states: collection.Set[String]): Boolean = {
states.contains(state.toString) || states.contains(state.toLowerCaseString)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same question.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@dajac dajac left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks @DL1231!

@dajac dajac merged commit 82920ff into apache:trunk Jan 29, 2024
nizhikov pushed a commit to nizhikov/kafka that referenced this pull request Jan 29, 2024
nizhikov pushed a commit to nizhikov/kafka that referenced this pull request Jan 29, 2024
yyu1993 pushed a commit to yyu1993/kafka that referenced this pull request Feb 15, 2024
…s for the new consumer group type (apache#15211)

While using —list —state the current accepted values correspond to the classic group type states. This patch adds the new states introduced by KIP-848. It also make the matching on the server case insensitive.

Co-authored-by: d00791190 <dinglan6@huawei.com>

Reviewers: Ritika Reddy <rreddy@confluent.io>, David Jacot <djacot@confluent.io>
clolov pushed a commit to clolov/kafka that referenced this pull request Apr 5, 2024
…s for the new consumer group type (apache#15211)

While using —list —state the current accepted values correspond to the classic group type states. This patch adds the new states introduced by KIP-848. It also make the matching on the server case insensitive.

Co-authored-by: d00791190 <dinglan6@huawei.com>

Reviewers: Ritika Reddy <rreddy@confluent.io>, David Jacot <djacot@confluent.io>
Phuc-Hong-Tran pushed a commit to Phuc-Hong-Tran/kafka that referenced this pull request Jun 6, 2024
…s for the new consumer group type (apache#15211)

While using —list —state the current accepted values correspond to the classic group type states. This patch adds the new states introduced by KIP-848. It also make the matching on the server case insensitive.

Co-authored-by: d00791190 <dinglan6@huawei.com>

Reviewers: Ritika Reddy <rreddy@confluent.io>, David Jacot <djacot@confluent.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

KIP-848 The Next Generation of the Consumer Rebalance Protocol

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants