DUE TO SPAM, SIGN-UP IS DISABLED. Goto Selfserve wiki signup and request an account.
...
| Code Block |
|---|
package org.apache.kafka.client.admin;
import org.apache.kafka.common.GroupType;
/**
* Options for {@link Admin#listGroups(ListGroupsOptions)}.
*
* The API of this class is evolving, see {@link Admin} for details.
*/
@InterfaceStability.Evolving
public class ListGroupsOptions extends AbstractOptions<ListGroupsOptions> {
/**
* 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) {
this.types = (types == null || types.isEmpty()) ? Collections.emptySet() : new HashSet<>(types);
return this;
}
/**
* Returns the list of group types that are requested or empty if no types have been specified.
*/
public Set<GroupType> types() {
return types;
}
} |
...
AbstractListGroupsResult
| Code Block |
|---|
package org.apache.kafka.clients.admin; /** * TheThis resultclass ofimplements the {@link Admin#listGroups(ListGroupsOptions)} call common APIs that are shared by results classes * for various AdminClient commands for listing groups. * <p> * The API of this class is evolving, see {@link Admin} for details. */ @InterfaceStability.Evolving public class AbstractListGroupsResult<T ListGroupsResultextends GroupListing> { /** AbstractListGroupsResult(KafkaFuture<Collection<Object>> future); /** * Returns a future that yields either an exception, or the full set of group listings. */ public KafkaFuture<Collection<GroupListing>>KafkaFuture<Collection<T>> all() { } /** * Returns a future which yields just the valid listings. */ public KafkaFuture<Collection<GroupListing>>KafkaFuture<Collection<T>> valid() { } /** * Returns a future which yields just the errors which occurred. */ public KafkaFuture<Collection<Throwable>> errors() { } }} |
ListGroupsResult
| Code Block |
|---|
package org.apache.kafka.clients.admin;
/**
* The result of the {@link Admin#listGroups(ListGroupsOptions)} call.
* <p>
* The API of this class is evolving, see {@link Admin} for details.
*/
@InterfaceStability.Evolving
public class ListGroupsResult extends AbstractListGroupsResult<GroupListing> {
ListGroupsResult(KafkaFuture<Collection<Object>> future) {
super(future);
}
} |
ListConsumerGroupsResult
This is changed to extends AbstractListGroupsResult<ConsumerGroupListing> .
ListShareGroupsResult
This is changed to extend AbstractListGroupsResult<ShareGroupListing> .
GroupListing
| Code Block |
|---|
package org.apache.kafka.client.admin;
import org.apache.kafka.common.ShareGroupState;
/**
* A listing of a group in the cluster.
* <p>
* The API of this class is evolving, see {@link Admin} for details.
*/
@InterfaceStability.Evolving
public class GroupListing {
public GroupListing(String groupId, String protocol);
public GroupListing(String groupId, GroupType type, String protocol);
public GroupListing(String groupId, Optional<GroupType> type, String protocol);
/**
* The id of the group.
*/
public String groupId();
/**
* The group type.
*/
public Optional<GroupType> type();
/**
* The group protocol type.
*/
public String protocol();
} |
...
Note that --consumer actually matches all groups whose type is Consumer , and groups whose type is Classic and protocol type is "consumer", and also "simple" consumer groups whose type is Classic and protocol type is "" . The filtering is done in the kafka-groups.sh tool.
...
| Code Block |
|---|
$ bin/kafka-groups.sh --bootstrap-server localhost:9092 --list
old-consumer-group
new-consumer-group
connect-cluster
share-group
schema-registry
simple-consumer-group |
To describe all of the groups and their types:
| Code Block |
|---|
$ bin/kafka-groups.sh --bootstrap-server localhost:9092 --describe GROUP TYPE PROTOCOL old-consumer-group Classic consumer new-consumer-group ConsumerConsumer consumer connect-cluster Classic connect share-group consumer connect-cluster Share Classic connectshare shareschema-groupregistry Classic Share sr simple-consumer-group shareClassic |
To list all of the consumer groups:
| Code Block |
|---|
$ bin/kafka-groups.sh --bootstrap-server localhost:9092 --list --consumer
old-consumer-group
new-consumer-group
simple-consumer-group |
To describe all of the consumer groups:
| Code Block |
|---|
$ bin/kafka-groups.sh --bootstrap-server localhost:9092 --describe --consumer GROUP TYPE PROTOCOL old-consumer-group Classic consumer new-consumer-group Consumer consumer simple-consumer-group Classic |
To describe all of the share groups:
...
The ListGroups RPC response returns three pieces of information for each group: group ID, type and protocol. For the common types of group, here is what they mean:
Type | Protocol | Meaning |
|---|---|---|
Classic |
| Consumer group with the "classic" consumer group protocol |
Classic | "" | "Simple" consumer group that has committed offsets only |
Consumer |
| Consumer group with the KIP-848 consumer group protocol |
Share |
| Share group |
Classic |
| Kafka Connect distributed worker cluster group |
Classic | Any other string | Other customization of "classic" consumer group protocol, such as a schema registry |
The new kafka-groups.sh tool makes all of this information available.
...