AndrewJSchofield commented on code in PR #17626: URL: https://github.com/apache/kafka/pull/17626#discussion_r1829080363
########## clients/src/main/java/org/apache/kafka/clients/admin/ListGroupsOptions.java: ########## @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.kafka.clients.admin; + +import org.apache.kafka.common.GroupType; +import org.apache.kafka.common.annotation.InterfaceStability; + +import java.util.Collections; +import java.util.Set; + +/** + * Options for {@link Admin#listGroups()}. + * <p> + * The API of this class is evolving, see {@link Admin} for details. + */ [email protected] +public class ListGroupsOptions extends AbstractOptions<ListGroupsOptions> { + + private Set<GroupType> types = Collections.emptySet(); + + /** + * If types is set, only groups of these types will be returned by listGroups(). + * Otherwise, all groups are returned. + */ + public ListGroupsOptions withTypes(Set<GroupType> types) { Review Comment: Java enums are really inflexible. Here is my suggestion. 1) Create a new `GroupState` enum which is basically a copy of `ConsumerGroupState` but which applies to all group types. Deprecate `ConsumerGroupState`. 1) Add `ListGroupsOptions.inStates(Set<GroupState>)`. This means that `Admin.listGroups` is able to do everything that `Admin.listConsumerGroups` and `Admin.listShareGroups` can do. 1) `ConsumerGroupState` is referred to in 3 places: `ConsumerGroupListing` (deprecated by KIP-1043), `ListConsumerGroupsOptions` (also deprecated by KIP-1043), and `ConsumerGroupDescription`. 1) Add `ConsumerGroupDescription.groupState()` which returns `GroupState`. Deprecate `ConsumerGroupDescription.state()` which returns `ConsumerGroupState`. 1) Replace `ShareGroupState` with `GroupState`. Replace `ShareGroupDescription.state()` with `ShareGroupDesription.groupState()`. 1) Add `ConsumerGroupDescription.rawState()` which returns `String` so that a client can distinguish obtain more detail on the `GroupState.UNKNOWN` state. I'm not sure whether I like this, but included for completeness. 1) In AK 5.0, complete the tidying up by removing `ConsumerGroupState`, `ConsumerGroupListing` and `ListConsumerGroupsOptions`. @chia7712 @dajac wdyt? -- 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]
