dajac commented on code in PR #15152:
URL: https://github.com/apache/kafka/pull/15152#discussion_r1466007522
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/Group.java:
##########
@@ -40,6 +42,29 @@ enum GroupType {
public String toString() {
return name;
}
+
+ /**
+ * Parse a string into the corresponding {@code GroupType} enum value,
in a case-insensitive manner.
+ *
+ * @return The {{@link GroupType}} according to the string passed.
+ *
+ * @throws IllegalArgumentException If the input string does not match
any {@code GroupType}.
+ */
+ public static GroupType parse(String typeString) {
+ for (GroupType type : GroupType.values()) {
Review Comment:
Is there a reason why you did not build a Map to do the reverse lookup like
you did in https://github.com/apache/kafka/pull/15259. By the way, I was also
considering whether we should reuse the client GroupType on the server. What do
you think?
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -452,21 +453,38 @@ public Group group(String groupId, long committedOffset)
throws GroupIdNotFoundE
/**
* Get the Group List.
*
- * @param statesFilter The states of the groups we want to list.
- * If empty all groups are returned with their state.
- * @param committedOffset A specified committed offset corresponding to
this shard
+ * @param statesFilter The states of the groups we want to list.
+ * If empty, all groups are returned with their
state.
+ * @param typesFilter The types of the groups we want to list.
+ * If empty, all groups are returned with their
type.
+ * @param committedOffset A specified committed offset corresponding to
this shard.
*
* @return A list containing the ListGroupsResponseData.ListedGroup
*/
+ public List<ListGroupsResponseData.ListedGroup> listGroups(
+ Set<String> statesFilter,
+ Set<String> typesFilter,
+ long committedOffset
+ ) {
+ // Converts each string to a value in the GroupType enum while being
case-insensitive.
+ Set<Group.GroupType> enumTypesFilter = typesFilter.stream()
+ .map(Group.GroupType::parse)
+ .collect(Collectors.toSet());
Review Comment:
We need to discuss the handling of unknown types. I thought that we would
ignore the unknown types to basically follow what we did for the states. I
think that you're suggesting to throw an exception for them. I think that the
issue with throwing an exception is that the end user won't really know what is
going on because we don't have an error message in the response. He would get
an unknown server error. Therefore, I mean towards ignoring the unknown types.
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]