You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "DL1231 (via GitHub)" <gi...@apache.org> on 2024/01/17 10:56:47 UTC
[PR] KAFKA-16095: Update list group state type filter to include the states for the new consumer group type [kafka]
DL1231 opened a new pull request, #15211:
URL: https://github.com/apache/kafka/pull/15211
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)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-16095: Update list group state type filter to include the states for the new consumer group type [kafka]
Posted by "dajac (via GitHub)" <gi...@apache.org>.
dajac commented on code in PR #15211:
URL: https://github.com/apache/kafka/pull/15211#discussion_r1467316594
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/Group.java:
##########
@@ -57,10 +57,15 @@ public String toString() {
*/
String stateAsString(long committedOffset);
+ /**
+ * @return The {{@link GroupType}}'s LowerCase String representation based on the committed offset.
+ */
+ String stateAsLowerCaseString(long committedOffset);
Review Comment:
It seems that we only access it from within the class so we could remove it from the interface.
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/classic/ClassicGroupState.java:
##########
@@ -114,15 +115,20 @@ public enum ClassicGroupState {
DEAD.addValidPreviousStates(STABLE, PREPARING_REBALANCE, COMPLETING_REBALANCE, EMPTY, DEAD);
}
- ClassicGroupState(String name) {
+ ClassicGroupState(String name, String lowerCaseName) {
Review Comment:
nit: I wonder if we could remove the `lowerCaseName` parameter and lower case the name in the constructor. Would it work?
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/classic/ClassicGroupState.java:
##########
@@ -114,15 +115,20 @@ public enum ClassicGroupState {
DEAD.addValidPreviousStates(STABLE, PREPARING_REBALANCE, COMPLETING_REBALANCE, EMPTY, DEAD);
}
- ClassicGroupState(String name) {
+ ClassicGroupState(String name, String lowerCaseName) {
this.name = name;
+ this.lowerCaseName = lowerCaseName;
}
@Override
public String toString() {
return name;
}
+ public String toLowerCaseString() {
Review Comment:
Actually, it would be great to do the same there. We could also capitatlize the states to be consistent too.
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/classic/ClassicGroupState.java:
##########
@@ -114,15 +115,20 @@ public enum ClassicGroupState {
DEAD.addValidPreviousStates(STABLE, PREPARING_REBALANCE, COMPLETING_REBALANCE, EMPTY, DEAD);
}
- ClassicGroupState(String name) {
+ ClassicGroupState(String name, String lowerCaseName) {
this.name = name;
+ this.lowerCaseName = lowerCaseName;
}
@Override
public String toString() {
return name;
}
+ public String toLowerCaseString() {
Review Comment:
nit: I wonder if we should also add `toLowerCaseString` to `ConsumerGroup.ConsumerGroupState` in order to be consistent.
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/consumer/ConsumerGroup.java:
##########
@@ -739,6 +747,12 @@ public Optional<OffsetExpirationCondition> offsetExpirationCondition() {
return Optional.of(new OffsetExpirationConditionImpl(offsetAndMetadata -> offsetAndMetadata.commitTimestampMs));
}
+ @Override
+ public boolean isInStatesCaseInsensitive(List<String> statesFilter, long committedOffset) {
+ Set<String> caseInsensitiveFilterSet = statesFilter.stream().map(String::toLowerCase).map(String::trim).collect(Collectors.toSet());
Review Comment:
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?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-16095: Update list group state type filter to include the states for the new consumer group type [kafka]
Posted by "DL1231 (via GitHub)" <gi...@apache.org>.
DL1231 commented on code in PR #15211:
URL: https://github.com/apache/kafka/pull/15211#discussion_r1469457414
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/consumer/ConsumerGroup.java:
##########
@@ -67,14 +68,22 @@ public enum ConsumerGroupState {
private final String name;
+ private final String capitalizedName;
Review Comment:
Done.
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/classic/ClassicGroup.java:
##########
@@ -956,6 +956,20 @@ public Optional<OffsetExpirationCondition> offsetExpirationCondition() {
return Optional.empty();
}
+ /**
+ * The state of this group.
+ *
+ * @return The current state as a lowercase String.
+ */
+ public String stateAsLowerCaseString() {
+ return this.state.toLowerCaseString();
+ }
+
+ @Override
+ public boolean isInStates(Set<String> statesFilter, long committedOffset) {
+ return statesFilter.contains(this.stateAsLowerCaseString()) || statesFilter.contains(this.stateAsString());
Review Comment:
Done.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-16095: Update list group state type filter to include the states for the new consumer group type [kafka]
Posted by "rreddy-22 (via GitHub)" <gi...@apache.org>.
rreddy-22 commented on code in PR #15211:
URL: https://github.com/apache/kafka/pull/15211#discussion_r1459513439
##########
clients/src/main/java/org/apache/kafka/common/ConsumerGroupState.java:
##########
@@ -31,7 +31,15 @@ public enum ConsumerGroupState {
COMPLETING_REBALANCE("CompletingRebalance"),
STABLE("Stable"),
DEAD("Dead"),
- EMPTY("Empty");
+ EMPTY("Empty"),
+
+ // New consumer group states are temporary here. It will be removed when
+ // the KIP-848 is completed.
+ NEW_CONSUMER_GROUP_EMPTY("empty"),
Review Comment:
We would also have to add support to make the filter case insensitive both in the command line code and in both the group coordinators list groups methods
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-16095: Update list group state type filter to include the states for the new consumer group type [kafka]
Posted by "DL1231 (via GitHub)" <gi...@apache.org>.
DL1231 commented on code in PR #15211:
URL: https://github.com/apache/kafka/pull/15211#discussion_r1468309807
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/consumer/ConsumerGroup.java:
##########
@@ -739,6 +747,12 @@ public Optional<OffsetExpirationCondition> offsetExpirationCondition() {
return Optional.of(new OffsetExpirationConditionImpl(offsetAndMetadata -> offsetAndMetadata.commitTimestampMs));
}
+ @Override
+ public boolean isInStatesCaseInsensitive(List<String> statesFilter, long committedOffset) {
+ Set<String> caseInsensitiveFilterSet = statesFilter.stream().map(String::toLowerCase).map(String::trim).collect(Collectors.toSet());
Review Comment:
Done.
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/Group.java:
##########
@@ -57,10 +57,15 @@ public String toString() {
*/
String stateAsString(long committedOffset);
+ /**
+ * @return The {{@link GroupType}}'s LowerCase String representation based on the committed offset.
+ */
+ String stateAsLowerCaseString(long committedOffset);
Review Comment:
Done.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-16095: Update list group state type filter to include the states for the new consumer group type [kafka]
Posted by "rreddy-22 (via GitHub)" <gi...@apache.org>.
rreddy-22 commented on code in PR #15211:
URL: https://github.com/apache/kafka/pull/15211#discussion_r1459497325
##########
clients/src/main/java/org/apache/kafka/common/ConsumerGroupState.java:
##########
@@ -31,7 +31,15 @@ public enum ConsumerGroupState {
COMPLETING_REBALANCE("CompletingRebalance"),
STABLE("Stable"),
DEAD("Dead"),
- EMPTY("Empty");
+ EMPTY("Empty"),
+
+ // New consumer group states are temporary here. It will be removed when
+ // the KIP-848 is completed.
+ NEW_CONSUMER_GROUP_EMPTY("empty"),
Review Comment:
Hey, so it was decided that we would make the state filters case insensitive, which means that for states that are common in both the old protocol and the new protocol, we return all groups in that state. Ex: "Stable" returns are groups that are stable. The enum will therefore contain:
public enum ConsumerGroupState {
UNKNOWN("Unknown"),
PREPARING_REBALANCE("PreparingRebalance"),
COMPLETING_REBALANCE("CompletingRebalance"),
STABLE("Stable"),
DEAD("Dead"),
EMPTY("Empty"),
ASSIGNING("Assigning"),
RECONCILING("Reconciling");
}
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-16095: Update list group state type filter to include the states for the new consumer group type [kafka]
Posted by "DL1231 (via GitHub)" <gi...@apache.org>.
DL1231 commented on PR #15211:
URL: https://github.com/apache/kafka/pull/15211#issuecomment-1910449935
Thanks for the suggestion @dajac . I have addressed the comments.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-16095: Update list group state type filter to include the states for the new consumer group type [kafka]
Posted by "DL1231 (via GitHub)" <gi...@apache.org>.
DL1231 commented on code in PR #15211:
URL: https://github.com/apache/kafka/pull/15211#discussion_r1461468087
##########
clients/src/main/java/org/apache/kafka/common/ConsumerGroupState.java:
##########
@@ -31,7 +31,15 @@ public enum ConsumerGroupState {
COMPLETING_REBALANCE("CompletingRebalance"),
STABLE("Stable"),
DEAD("Dead"),
- EMPTY("Empty");
+ EMPTY("Empty"),
+
+ // New consumer group states are temporary here. It will be removed when
+ // the KIP-848 is completed.
+ NEW_CONSUMER_GROUP_EMPTY("empty"),
Review Comment:
done
##########
core/src/test/scala/unit/kafka/admin/ListConsumerGroupTest.scala:
##########
@@ -95,9 +95,18 @@ class ListConsumerGroupTest extends ConsumerGroupCommandTest {
result = ConsumerGroupCommand.consumerGroupStatesFromString("Dead,CompletingRebalance,")
assertEquals(Set(ConsumerGroupState.DEAD, ConsumerGroupState.COMPLETING_REBALANCE), result)
Review Comment:
done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-16095: Update list group state type filter to include the states for the new consumer group type [kafka]
Posted by "DL1231 (via GitHub)" <gi...@apache.org>.
DL1231 commented on code in PR #15211:
URL: https://github.com/apache/kafka/pull/15211#discussion_r1468309502
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/classic/ClassicGroupState.java:
##########
@@ -114,15 +115,20 @@ public enum ClassicGroupState {
DEAD.addValidPreviousStates(STABLE, PREPARING_REBALANCE, COMPLETING_REBALANCE, EMPTY, DEAD);
}
- ClassicGroupState(String name) {
+ ClassicGroupState(String name, String lowerCaseName) {
this.name = name;
+ this.lowerCaseName = lowerCaseName;
}
@Override
public String toString() {
return name;
}
+ public String toLowerCaseString() {
Review Comment:
Thanks for the suggestion, I added the `toCapitalizedString` to `ConsumerGroup.ConsumerGroupState`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-16095: Update list group state type filter to include the states for the new consumer group type [kafka]
Posted by "dajac (via GitHub)" <gi...@apache.org>.
dajac commented on PR #15211:
URL: https://github.com/apache/kafka/pull/15211#issuecomment-1913484512
@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?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-16095: Update list group state type filter to include the states for the new consumer group type [kafka]
Posted by "rreddy-22 (via GitHub)" <gi...@apache.org>.
rreddy-22 commented on code in PR #15211:
URL: https://github.com/apache/kafka/pull/15211#discussion_r1459581595
##########
core/src/test/scala/unit/kafka/admin/ListConsumerGroupTest.scala:
##########
@@ -95,9 +95,18 @@ class ListConsumerGroupTest extends ConsumerGroupCommandTest {
result = ConsumerGroupCommand.consumerGroupStatesFromString("Dead,CompletingRebalance,")
assertEquals(Set(ConsumerGroupState.DEAD, ConsumerGroupState.COMPLETING_REBALANCE), result)
Review Comment:
Once the group type PR's are merged, the test params for new and old GC will be present so we can verify if everything is working as expected!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-16095: Update list group state type filter to include the states for the new consumer group type [kafka]
Posted by "DL1231 (via GitHub)" <gi...@apache.org>.
DL1231 commented on PR #15211:
URL: https://github.com/apache/kafka/pull/15211#issuecomment-1903443692
@rreddy-22 Thanks for your comments. I addressed them.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-16095: Update list group state type filter to include the states for the new consumer group type [kafka]
Posted by "DL1231 (via GitHub)" <gi...@apache.org>.
DL1231 commented on PR #15211:
URL: https://github.com/apache/kafka/pull/15211#issuecomment-1912974892
@dajac
Addressed your review comments. PTAL when you get chance!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-16095: Update list group state type filter to include the states for the new consumer group type [kafka]
Posted by "rreddy-22 (via GitHub)" <gi...@apache.org>.
rreddy-22 commented on code in PR #15211:
URL: https://github.com/apache/kafka/pull/15211#discussion_r1459509714
##########
core/src/test/scala/unit/kafka/admin/ListConsumerGroupTest.scala:
##########
@@ -95,9 +95,18 @@ class ListConsumerGroupTest extends ConsumerGroupCommandTest {
result = ConsumerGroupCommand.consumerGroupStatesFromString("Dead,CompletingRebalance,")
assertEquals(Set(ConsumerGroupState.DEAD, ConsumerGroupState.COMPLETING_REBALANCE), result)
Review Comment:
Could we also add tests related to the new states in the other tests?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-16095: Update list group state type filter to include the states for the new consumer group type [kafka]
Posted by "rreddy-22 (via GitHub)" <gi...@apache.org>.
rreddy-22 commented on code in PR #15211:
URL: https://github.com/apache/kafka/pull/15211#discussion_r1459497325
##########
clients/src/main/java/org/apache/kafka/common/ConsumerGroupState.java:
##########
@@ -31,7 +31,15 @@ public enum ConsumerGroupState {
COMPLETING_REBALANCE("CompletingRebalance"),
STABLE("Stable"),
DEAD("Dead"),
- EMPTY("Empty");
+ EMPTY("Empty"),
+
+ // New consumer group states are temporary here. It will be removed when
+ // the KIP-848 is completed.
+ NEW_CONSUMER_GROUP_EMPTY("empty"),
Review Comment:
So it was decided that we would make the state filters case insensitive, which means that for states that are common in both the old protocol and the new protocol, we return all groups in that state. Ex: "Stable" returns are groups that are stable. The enum will therefore contain:
public enum ConsumerGroupState {
UNKNOWN("Unknown"),
PREPARING_REBALANCE("PreparingRebalance"),
COMPLETING_REBALANCE("CompletingRebalance"),
STABLE("Stable"),
DEAD("Dead"),
EMPTY("Empty"),
ASSIGNING("Assigning"),
RECONCILING("Reconciling");
}
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-16095: Update list group state type filter to include the states for the new consumer group type [kafka]
Posted by "DL1231 (via GitHub)" <gi...@apache.org>.
DL1231 commented on code in PR #15211:
URL: https://github.com/apache/kafka/pull/15211#discussion_r1469662425
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/consumer/ConsumerGroup.java:
##########
@@ -739,6 +748,19 @@ public Optional<OffsetExpirationCondition> offsetExpirationCondition() {
return Optional.of(new OffsetExpirationConditionImpl(offsetAndMetadata -> offsetAndMetadata.commitTimestampMs));
}
+ /**
+ * @return The current state as a capitalized String with given committedOffset.
+ */
+ public String stateAsCapitalizedString(long committedOffset) {
+ return state.get(committedOffset).toCapitalizedString();
+ }
Review Comment:
Done.
##########
core/src/main/scala/kafka/coordinator/group/GroupMetadata.scala:
##########
@@ -841,6 +842,10 @@ private[group] class GroupMetadata(val groupId: String, initialState: GroupState
.format(groupId, targetState.validPreviousStates.mkString(","), targetState, state))
}
+ def isInStates(states: collection.Set[String]): Boolean = {
+ states.contains(state.toString) || states.contains(state.toLowerCaseString)
Review Comment:
Done.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-16095: Update list group state type filter to include the states for the new consumer group type [kafka]
Posted by "dajac (via GitHub)" <gi...@apache.org>.
dajac commented on code in PR #15211:
URL: https://github.com/apache/kafka/pull/15211#discussion_r1469341470
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/classic/ClassicGroup.java:
##########
@@ -956,6 +956,20 @@ public Optional<OffsetExpirationCondition> offsetExpirationCondition() {
return Optional.empty();
}
+ /**
+ * The state of this group.
+ *
+ * @return The current state as a lowercase String.
+ */
+ public String stateAsLowerCaseString() {
+ return this.state.toLowerCaseString();
+ }
+
+ @Override
+ public boolean isInStates(Set<String> statesFilter, long committedOffset) {
+ return statesFilter.contains(this.stateAsLowerCaseString()) || statesFilter.contains(this.stateAsString());
Review Comment:
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`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-16095: Update list group state type filter to include the states for the new consumer group type [kafka]
Posted by "rreddy-22 (via GitHub)" <gi...@apache.org>.
rreddy-22 commented on code in PR #15211:
URL: https://github.com/apache/kafka/pull/15211#discussion_r1459497325
##########
clients/src/main/java/org/apache/kafka/common/ConsumerGroupState.java:
##########
@@ -31,7 +31,15 @@ public enum ConsumerGroupState {
COMPLETING_REBALANCE("CompletingRebalance"),
STABLE("Stable"),
DEAD("Dead"),
- EMPTY("Empty");
+ EMPTY("Empty"),
+
+ // New consumer group states are temporary here. It will be removed when
+ // the KIP-848 is completed.
+ NEW_CONSUMER_GROUP_EMPTY("empty"),
Review Comment:
So it was decided that we would make the state filters case insensitive, which means that for states that are common in both the old protocol and the new protocol, we return all groups in that state. Ex: "Stable" returns are groups that are stable. The enum will therefore contain:
`public enum ConsumerGroupState {
UNKNOWN("Unknown"),
PREPARING_REBALANCE("PreparingRebalance"),
COMPLETING_REBALANCE("CompletingRebalance"),
STABLE("Stable"),
DEAD("Dead"),
EMPTY("Empty"),
ASSIGNING("Assigning"),
RECONCILING("Reconciling");
}`
##########
clients/src/main/java/org/apache/kafka/common/ConsumerGroupState.java:
##########
@@ -31,7 +31,15 @@ public enum ConsumerGroupState {
COMPLETING_REBALANCE("CompletingRebalance"),
STABLE("Stable"),
DEAD("Dead"),
- EMPTY("Empty");
+ EMPTY("Empty"),
+
+ // New consumer group states are temporary here. It will be removed when
+ // the KIP-848 is completed.
+ NEW_CONSUMER_GROUP_EMPTY("empty"),
Review Comment:
So it was decided that we would make the state filters case insensitive, which means that for states that are common in both the old protocol and the new protocol, we return all groups in that state. Ex: "Stable" returns are groups that are stable. The enum will therefore contain:
public enum ConsumerGroupState {
UNKNOWN("Unknown"),
PREPARING_REBALANCE("PreparingRebalance"),
COMPLETING_REBALANCE("CompletingRebalance"),
STABLE("Stable"),
DEAD("Dead"),
EMPTY("Empty"),
ASSIGNING("Assigning"),
RECONCILING("Reconciling");
}
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-16095: Update list group state type filter to include the states for the new consumer group type [kafka]
Posted by "dajac (via GitHub)" <gi...@apache.org>.
dajac commented on code in PR #15211:
URL: https://github.com/apache/kafka/pull/15211#discussion_r1464905968
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -462,7 +463,9 @@ public Group group(String groupId, long committedOffset) throws GroupIdNotFoundE
public List<ListGroupsResponseData.ListedGroup> listGroups(List<String> statesFilter, long committedOffset) {
Stream<Group> groupStream = groups.values(committedOffset).stream();
if (!statesFilter.isEmpty()) {
- groupStream = groupStream.filter(group -> statesFilter.contains(group.stateAsString(committedOffset)));
+ List<String> caseInsensitiveFilterList = statesFilter.stream().map(String::toLowerCase).collect(Collectors.toList());
Review Comment:
It would be better to use a Set here.
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -462,7 +463,9 @@ public Group group(String groupId, long committedOffset) throws GroupIdNotFoundE
public List<ListGroupsResponseData.ListedGroup> listGroups(List<String> statesFilter, long committedOffset) {
Stream<Group> groupStream = groups.values(committedOffset).stream();
if (!statesFilter.isEmpty()) {
- groupStream = groupStream.filter(group -> statesFilter.contains(group.stateAsString(committedOffset)));
+ List<String> caseInsensitiveFilterList = statesFilter.stream().map(String::toLowerCase).collect(Collectors.toList());
+ groupStream = groupStream.filter(group -> caseInsensitiveFilterList.contains(group.stateAsString(committedOffset).toLowerCase(
Review Comment:
It is a tad annoying that we have to lower case the state for every group, every time this method is called. Here I wonder if we could store the lower cased version of the state in the enum in order to avoid it.
The second think that I wanted to point out is that it may be worth adding a method like `inState(Set<String> states, long committedOffset)` to the `Group` interface in order to delegate the implementation of the filter to the group itself. I think that something like this would be required to implement my initial suggestion.
What do you think?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-16095: Update list group state type filter to include the states for the new consumer group type [kafka]
Posted by "DL1231 (via GitHub)" <gi...@apache.org>.
DL1231 commented on code in PR #15211:
URL: https://github.com/apache/kafka/pull/15211#discussion_r1469259935
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/classic/ClassicGroup.java:
##########
@@ -956,6 +956,20 @@ public Optional<OffsetExpirationCondition> offsetExpirationCondition() {
return Optional.empty();
}
+ /**
+ * The state of this group.
+ *
+ * @return The current state as a lowercase String.
+ */
+ public String stateAsLowerCaseString() {
+ return this.state.toLowerCaseString();
+ }
+
+ @Override
+ public boolean isInStates(Set<String> statesFilter, long committedOffset) {
+ return statesFilter.contains(this.stateAsLowerCaseString()) || statesFilter.contains(this.stateAsString());
Review Comment:
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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-16095: Update list group state type filter to include the states for the new consumer group type [kafka]
Posted by "DL1231 (via GitHub)" <gi...@apache.org>.
DL1231 commented on code in PR #15211:
URL: https://github.com/apache/kafka/pull/15211#discussion_r1468299153
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/classic/ClassicGroupState.java:
##########
@@ -114,15 +115,20 @@ public enum ClassicGroupState {
DEAD.addValidPreviousStates(STABLE, PREPARING_REBALANCE, COMPLETING_REBALANCE, EMPTY, DEAD);
}
- ClassicGroupState(String name) {
+ ClassicGroupState(String name, String lowerCaseName) {
Review Comment:
Done.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-16095: Update list group state type filter to include the states for the new consumer group type [kafka]
Posted by "DL1231 (via GitHub)" <gi...@apache.org>.
DL1231 commented on PR #15211:
URL: https://github.com/apache/kafka/pull/15211#issuecomment-1895572781
@rreddy-22 PTAL.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-16095: Update list group state type filter to include the states for the new consumer group type [kafka]
Posted by "dajac (via GitHub)" <gi...@apache.org>.
dajac merged PR #15211:
URL: https://github.com/apache/kafka/pull/15211
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-16095: Update list group state type filter to include the states for the new consumer group type [kafka]
Posted by "dajac (via GitHub)" <gi...@apache.org>.
dajac commented on code in PR #15211:
URL: https://github.com/apache/kafka/pull/15211#discussion_r1469217586
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/classic/ClassicGroup.java:
##########
@@ -956,6 +956,20 @@ public Optional<OffsetExpirationCondition> offsetExpirationCondition() {
return Optional.empty();
}
+ /**
+ * The state of this group.
+ *
+ * @return The current state as a lowercase String.
+ */
+ public String stateAsLowerCaseString() {
+ return this.state.toLowerCaseString();
+ }
+
+ @Override
+ public boolean isInStates(Set<String> statesFilter, long committedOffset) {
+ return statesFilter.contains(this.stateAsLowerCaseString()) || statesFilter.contains(this.stateAsString());
Review Comment:
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?
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/consumer/ConsumerGroup.java:
##########
@@ -67,14 +68,22 @@ public enum ConsumerGroupState {
private final String name;
+ private final String capitalizedName;
Review Comment:
I would rather do it the other way around in order to be consistent with the classic group states. Could we capitalize the states in L63-67 and lower case them here?
##########
core/src/main/scala/kafka/coordinator/group/GroupMetadata.scala:
##########
@@ -841,6 +842,10 @@ private[group] class GroupMetadata(val groupId: String, initialState: GroupState
.format(groupId, targetState.validPreviousStates.mkString(","), targetState, state))
}
+ def isInStates(states: collection.Set[String]): Boolean = {
+ states.contains(state.toString) || states.contains(state.toLowerCaseString)
Review Comment:
Same question.
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/consumer/ConsumerGroup.java:
##########
@@ -739,6 +748,19 @@ public Optional<OffsetExpirationCondition> offsetExpirationCondition() {
return Optional.of(new OffsetExpirationConditionImpl(offsetAndMetadata -> offsetAndMetadata.commitTimestampMs));
}
+ /**
+ * @return The current state as a capitalized String with given committedOffset.
+ */
+ public String stateAsCapitalizedString(long committedOffset) {
+ return state.get(committedOffset).toCapitalizedString();
+ }
Review Comment:
Same suggestion about inlining it.
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/classic/ClassicGroup.java:
##########
@@ -956,6 +956,20 @@ public Optional<OffsetExpirationCondition> offsetExpirationCondition() {
return Optional.empty();
}
+ /**
+ * The state of this group.
+ *
+ * @return The current state as a lowercase String.
+ */
+ public String stateAsLowerCaseString() {
+ return this.state.toLowerCaseString();
+ }
Review Comment:
We could probably remove this one and inline it.
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/consumer/ConsumerGroup.java:
##########
@@ -739,6 +748,19 @@ public Optional<OffsetExpirationCondition> offsetExpirationCondition() {
return Optional.of(new OffsetExpirationConditionImpl(offsetAndMetadata -> offsetAndMetadata.commitTimestampMs));
}
+ /**
+ * @return The current state as a capitalized String with given committedOffset.
+ */
+ public String stateAsCapitalizedString(long committedOffset) {
+ return state.get(committedOffset).toCapitalizedString();
+ }
+
+ @Override
+ public boolean isInStates(Set<String> statesFilter, long committedOffset) {
+ return statesFilter.contains(this.stateAsCapitalizedString(committedOffset)) || statesFilter.contains(
+ this.stateAsString(committedOffset));
Review Comment:
Same question about checking the two versions here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-16095: Update list group state type filter to include the states for the new consumer group type [kafka]
Posted by "DL1231 (via GitHub)" <gi...@apache.org>.
DL1231 commented on code in PR #15211:
URL: https://github.com/apache/kafka/pull/15211#discussion_r1469662118
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/classic/ClassicGroup.java:
##########
@@ -956,6 +956,20 @@ public Optional<OffsetExpirationCondition> offsetExpirationCondition() {
return Optional.empty();
}
+ /**
+ * The state of this group.
+ *
+ * @return The current state as a lowercase String.
+ */
+ public String stateAsLowerCaseString() {
+ return this.state.toLowerCaseString();
+ }
Review Comment:
Done.
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/consumer/ConsumerGroup.java:
##########
@@ -739,6 +748,19 @@ public Optional<OffsetExpirationCondition> offsetExpirationCondition() {
return Optional.of(new OffsetExpirationConditionImpl(offsetAndMetadata -> offsetAndMetadata.commitTimestampMs));
}
+ /**
+ * @return The current state as a capitalized String with given committedOffset.
+ */
+ public String stateAsCapitalizedString(long committedOffset) {
+ return state.get(committedOffset).toCapitalizedString();
+ }
+
+ @Override
+ public boolean isInStates(Set<String> statesFilter, long committedOffset) {
+ return statesFilter.contains(this.stateAsCapitalizedString(committedOffset)) || statesFilter.contains(
+ this.stateAsString(committedOffset));
Review Comment:
Done.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org