This is an automated email from the ASF dual-hosted git repository.

schofielaj pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 7a8dba35a7e KAFKA-19784: KIP-1227: Expose rack ID in MemberDescription 
and ShareMemberDescription (#20691)
7a8dba35a7e is described below

commit 7a8dba35a7e7592af31ffd6214293d91eeabc8b5
Author: stroller <[email protected]>
AuthorDate: Mon Oct 27 20:09:38 2025 +0800

    KAFKA-19784: KIP-1227: Expose rack ID in MemberDescription and 
ShareMemberDescription (#20691)
    
    Hi Team:
    
    Currently, the AdminClient’s describeConsumerGroups API returns a
    MemberDescription that does not include rack information, even though
    the underlying ConsumerGroupDescribeResponse protocol already supports a
    rackId field.  This causes users to be unable to retrieve member rack
    information through the Admin API.
    
    Rack information is crucial for:
    
    1. Monitoring and visualization tools
    2. Operational analysis of rack distribution
    3. Diagnosing rack-aware assignment issues
    
    In addition, StreamsGroupMemberDescription already includes the rackId,
    so adding it here would make the behavior more consistent.
    
    BTW, I have currently implemented our AZ/Rack analysis using a
    workaround — passing the rack information into the clientId field and
    parsing it afterward.
    
    ```
    kafkaConsumerConfig.customConfig(ConsumerConfig.CLIENT_ID_CONFIG,
    generateClientIdWithRack(ip, rack));
    ```
    
    <img width="1092" height="764" alt="image"
    
    
src="https://github.com/user-attachments/assets/b53acde9-3c67-4daf-b6fa-52bbe2415a0b";
    />
    
    So I propose this change with tiny code change to support this feature.
    After the change. We can easy to get all the rack info for every
    consumer by the API:
    `Admin#describeConsumerGroups(java.util.Collection<java.lang.String>)`
    
    Thanks for review!
    
    Reviewers: Andrew Schofield <[email protected]>
    
    ---------
    
    Signed-off-by: stroller <[email protected]>
---
 .../kafka/clients/admin/MemberDescription.java     | 57 +++++++++++++++++++---
 .../clients/admin/ShareMemberDescription.java      | 15 +++++-
 .../internals/DescribeClassicGroupsHandler.java    |  1 +
 .../internals/DescribeConsumerGroupsHandler.java   |  2 +
 .../internals/DescribeShareGroupsHandler.java      |  2 +
 .../kafka/clients/admin/KafkaAdminClientTest.java  |  6 ++-
 .../kafka/clients/admin/MemberDescriptionTest.java | 10 ++++
 .../DescribeConsumerGroupsHandlerTest.java         |  7 ++-
 .../consumer/group/ConsumerGroupServiceTest.java   |  4 +-
 .../consumer/group/ShareGroupCommandTest.java      | 22 ++++-----
 10 files changed, 102 insertions(+), 24 deletions(-)

diff --git 
a/clients/src/main/java/org/apache/kafka/clients/admin/MemberDescription.java 
b/clients/src/main/java/org/apache/kafka/clients/admin/MemberDescription.java
index e72a48d8a62..b45abcdcd7c 100644
--- 
a/clients/src/main/java/org/apache/kafka/clients/admin/MemberDescription.java
+++ 
b/clients/src/main/java/org/apache/kafka/clients/admin/MemberDescription.java
@@ -28,6 +28,7 @@ import java.util.Optional;
 public class MemberDescription {
     private final String memberId;
     private final Optional<String> groupInstanceId;
+    private final Optional<String> rackId;
     private final String clientId;
     private final String host;
     private final MemberAssignment assignment;
@@ -38,6 +39,7 @@ public class MemberDescription {
     public MemberDescription(
         String memberId,
         Optional<String> groupInstanceId,
+        Optional<String> rackId,
         String clientId,
         String host,
         MemberAssignment assignment,
@@ -47,6 +49,7 @@ public class MemberDescription {
     ) {
         this.memberId = memberId == null ? "" : memberId;
         this.groupInstanceId = groupInstanceId;
+        this.rackId = rackId;
         this.clientId = clientId == null ? "" : clientId;
         this.host = host == null ? "" : host;
         this.assignment = assignment == null ?
@@ -57,9 +60,36 @@ public class MemberDescription {
     }
 
     /**
-     * @deprecated Since 4.0. Use {@link #MemberDescription(String, Optional, 
String, String, MemberAssignment, Optional, Optional, Optional)} instead.
+     * @deprecated Since 4.2. Use {@link #MemberDescription(String, Optional, 
Optional, String, String, MemberAssignment, Optional, Optional, Optional)} 
instead.
      */
-    @Deprecated
+    @Deprecated(since = "4.2", forRemoval = true)
+    public MemberDescription(
+        String memberId,
+        Optional<String> groupInstanceId,
+        String clientId,
+        String host,
+        MemberAssignment assignment,
+        Optional<MemberAssignment> targetAssignment,
+        Optional<Integer> memberEpoch,
+        Optional<Boolean> upgraded
+    ) {
+        this(
+            memberId,
+            groupInstanceId,
+            Optional.empty(),
+            clientId,
+            host,
+            assignment,
+            targetAssignment,
+            memberEpoch,
+            upgraded
+        );
+    }
+
+    /**
+     * @deprecated Since 4.0. Use {@link #MemberDescription(String, Optional, 
Optional, String, String, MemberAssignment, Optional, Optional, Optional)} 
instead.
+     */
+    @Deprecated(since = "4.0", forRemoval = true)
     public MemberDescription(
         String memberId,
         Optional<String> groupInstanceId,
@@ -81,9 +111,9 @@ public class MemberDescription {
     }
 
     /**
-     * @deprecated Since 4.0. Use {@link #MemberDescription(String, Optional, 
String, String, MemberAssignment, Optional, Optional, Optional)} instead.
+     * @deprecated Since 4.0. Use {@link #MemberDescription(String, Optional, 
Optional, String, String, MemberAssignment, Optional, Optional, Optional)} 
instead.
      */
-    @Deprecated
+    @Deprecated(since = "4.0", forRemoval = true)
     public MemberDescription(
         String memberId,
         Optional<String> groupInstanceId,
@@ -102,9 +132,9 @@ public class MemberDescription {
     }
 
     /**
-     * @deprecated Since 4.0. Use {@link #MemberDescription(String, Optional, 
String, String, MemberAssignment, Optional, Optional, Optional)} instead.
+     * @deprecated Since 4.0. Use {@link #MemberDescription(String, Optional, 
Optional, String, String, MemberAssignment, Optional, Optional, Optional)} 
instead.
      */
-    @Deprecated
+    @Deprecated(since = "4.0", forRemoval = true)
     public MemberDescription(String memberId,
                              String clientId,
                              String host,
@@ -119,6 +149,7 @@ public class MemberDescription {
         MemberDescription that = (MemberDescription) o;
         return memberId.equals(that.memberId) &&
             groupInstanceId.equals(that.groupInstanceId) &&
+            rackId.equals(that.rackId) &&
             clientId.equals(that.clientId) &&
             host.equals(that.host) &&
             assignment.equals(that.assignment) &&
@@ -129,7 +160,7 @@ public class MemberDescription {
 
     @Override
     public int hashCode() {
-        return Objects.hash(memberId, groupInstanceId, clientId, host, 
assignment, targetAssignment, memberEpoch, upgraded);
+        return Objects.hash(memberId, groupInstanceId, rackId, clientId, host, 
assignment, targetAssignment, memberEpoch, upgraded);
     }
 
     /**
@@ -146,6 +177,17 @@ public class MemberDescription {
         return groupInstanceId;
     }
 
+    /**
+     * The rack id of the group member.
+     * <p>
+     * It is only available for consumer groups using the new consumer group 
protocol
+     * ({@code group.protocol=consumer}).
+     * <p>
+     */
+    public Optional<String> rackId() {
+        return rackId;
+    }
+
     /**
      * The client id of the group member.
      */
@@ -197,6 +239,7 @@ public class MemberDescription {
     public String toString() {
         return "(memberId=" + memberId +
             ", groupInstanceId=" + groupInstanceId.orElse("null") +
+            ", rackId=" + rackId.orElse("null") +
             ", clientId=" + clientId +
             ", host=" + host +
             ", assignment=" + assignment +
diff --git 
a/clients/src/main/java/org/apache/kafka/clients/admin/ShareMemberDescription.java
 
b/clients/src/main/java/org/apache/kafka/clients/admin/ShareMemberDescription.java
index 5fb74d8b242..db9e41612d0 100644
--- 
a/clients/src/main/java/org/apache/kafka/clients/admin/ShareMemberDescription.java
+++ 
b/clients/src/main/java/org/apache/kafka/clients/admin/ShareMemberDescription.java
@@ -20,6 +20,7 @@ import org.apache.kafka.common.annotation.InterfaceStability;
 
 import java.util.Collections;
 import java.util.Objects;
+import java.util.Optional;
 
 /**
  * A detailed description of a single share group member in the cluster.
@@ -27,6 +28,7 @@ import java.util.Objects;
 @InterfaceStability.Evolving
 public class ShareMemberDescription {
     private final String memberId;
+    private final Optional<String> rackId;
     private final String clientId;
     private final String host;
     private final ShareMemberAssignment assignment;
@@ -34,12 +36,14 @@ public class ShareMemberDescription {
 
     public ShareMemberDescription(
         String memberId,
+        Optional<String> rackId,
         String clientId,
         String host,
         ShareMemberAssignment assignment,
         int memberEpoch
     ) {
         this.memberId = memberId == null ? "" : memberId;
+        this.rackId = rackId;
         this.clientId = clientId == null ? "" : clientId;
         this.host = host == null ? "" : host;
         this.assignment = assignment == null ?
@@ -53,6 +57,7 @@ public class ShareMemberDescription {
         if (o == null || getClass() != o.getClass()) return false;
         ShareMemberDescription that = (ShareMemberDescription) o;
         return memberId.equals(that.memberId) &&
+            rackId.equals(that.rackId) &&
             clientId.equals(that.clientId) &&
             host.equals(that.host) &&
             assignment.equals(that.assignment) &&
@@ -61,7 +66,7 @@ public class ShareMemberDescription {
 
     @Override
     public int hashCode() {
-        return Objects.hash(memberId, clientId, host, assignment, memberEpoch);
+        return Objects.hash(memberId, rackId, clientId, host, assignment, 
memberEpoch);
     }
 
     /**
@@ -71,6 +76,13 @@ public class ShareMemberDescription {
         return memberId;
     }
 
+    /**
+     * The rack id of the group member.
+     */
+    public Optional<String> rackId() {
+        return rackId;
+    }
+
     /**
      * The client id of the group member.
      */
@@ -102,6 +114,7 @@ public class ShareMemberDescription {
     @Override
     public String toString() {
         return "(memberId=" + memberId +
+            ", rackId=" + rackId.orElse("null") +
             ", clientId=" + clientId +
             ", host=" + host +
             ", assignment=" + assignment +
diff --git 
a/clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeClassicGroupsHandler.java
 
b/clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeClassicGroupsHandler.java
index 686ee43a44b..3ff4726661b 100644
--- 
a/clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeClassicGroupsHandler.java
+++ 
b/clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeClassicGroupsHandler.java
@@ -134,6 +134,7 @@ public class DescribeClassicGroupsHandler extends 
AdminApiHandler.Batched<Coordi
                 memberDescriptions.add(new MemberDescription(
                     groupMember.memberId(),
                     Optional.ofNullable(groupMember.groupInstanceId()),
+                    Optional.empty(),
                     groupMember.clientId(),
                     groupMember.clientHost(),
                     new MemberAssignment(partitions),
diff --git 
a/clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeConsumerGroupsHandler.java
 
b/clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeConsumerGroupsHandler.java
index 6a04873c0b7..9cb7f9deace 100644
--- 
a/clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeConsumerGroupsHandler.java
+++ 
b/clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeConsumerGroupsHandler.java
@@ -219,6 +219,7 @@ public class DescribeConsumerGroupsHandler implements 
AdminApiHandler<Coordinato
                 memberDescriptions.add(new MemberDescription(
                     groupMember.memberId(),
                     Optional.ofNullable(groupMember.instanceId()),
+                    Optional.ofNullable(groupMember.rackId()),
                     groupMember.clientId(),
                     groupMember.clientHost(),
                     new 
MemberAssignment(convertAssignment(groupMember.assignment())),
@@ -283,6 +284,7 @@ public class DescribeConsumerGroupsHandler implements 
AdminApiHandler<Coordinato
                     memberDescriptions.add(new MemberDescription(
                         groupMember.memberId(),
                         Optional.ofNullable(groupMember.groupInstanceId()),
+                        Optional.empty(),
                         groupMember.clientId(),
                         groupMember.clientHost(),
                         new MemberAssignment(partitions),
diff --git 
a/clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeShareGroupsHandler.java
 
b/clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeShareGroupsHandler.java
index 1f49a0d6058..5ce8af38baa 100644
--- 
a/clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeShareGroupsHandler.java
+++ 
b/clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeShareGroupsHandler.java
@@ -41,6 +41,7 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.Set;
 import java.util.stream.Collectors;
 
@@ -119,6 +120,7 @@ public class DescribeShareGroupsHandler extends 
AdminApiHandler.Batched<Coordina
             describedGroup.members().forEach(groupMember ->
                 memberDescriptions.add(new ShareMemberDescription(
                     groupMember.memberId(),
+                    Optional.ofNullable(groupMember.rackId()),
                     groupMember.clientId(),
                     groupMember.clientHost(),
                     new 
ShareMemberAssignment(convertAssignment(groupMember.assignment())),
diff --git 
a/clients/src/test/java/org/apache/kafka/clients/admin/KafkaAdminClientTest.java
 
b/clients/src/test/java/org/apache/kafka/clients/admin/KafkaAdminClientTest.java
index 9084a25836e..d01cde83bb3 100644
--- 
a/clients/src/test/java/org/apache/kafka/clients/admin/KafkaAdminClientTest.java
+++ 
b/clients/src/test/java/org/apache/kafka/clients/admin/KafkaAdminClientTest.java
@@ -4694,7 +4694,7 @@ public class KafkaAdminClientTest {
                                     .setClientHost("host")
                                     .setClientId("clientId")
                                     .setMemberEpoch(10)
-                                    .setRackId("rackid")
+                                    .setRackId("rackId")
                                     
.setSubscribedTopicNames(singletonList("foo"))
                                     .setSubscribedTopicRegex("regex")
                                     .setAssignment(new 
ConsumerGroupDescribeResponseData.Assignment()
@@ -4758,6 +4758,7 @@ public class KafkaAdminClientTest {
                     new MemberDescription(
                         "memberId",
                         Optional.of("instanceId"),
+                        Optional.of("rackId"),
                         "clientId",
                         "host",
                         new MemberAssignment(
@@ -4785,6 +4786,7 @@ public class KafkaAdminClientTest {
                     new MemberDescription(
                         "0",
                         Optional.empty(),
+                        Optional.empty(),
                         "clientId0",
                         "clientHost",
                         new MemberAssignment(
@@ -10673,6 +10675,7 @@ public class KafkaAdminClientTest {
                                                                  
MemberAssignment assignment) {
         return new MemberDescription(member.memberId(),
                                      
Optional.ofNullable(member.groupInstanceId()),
+                                     Optional.empty(),
                                      member.clientId(),
                                      member.clientHost(),
                                      assignment,
@@ -10684,6 +10687,7 @@ public class KafkaAdminClientTest {
     private static ShareMemberDescription 
convertToShareMemberDescriptions(ShareGroupDescribeResponseData.Member member,
                                                                            
ShareMemberAssignment assignment) {
         return new ShareMemberDescription(member.memberId(),
+                                          Optional.ofNullable(member.rackId()),
                                           member.clientId(),
                                           member.clientHost(),
                                           assignment,
diff --git 
a/clients/src/test/java/org/apache/kafka/clients/admin/MemberDescriptionTest.java
 
b/clients/src/test/java/org/apache/kafka/clients/admin/MemberDescriptionTest.java
index 7c3e928b3a6..8630dbf7f03 100644
--- 
a/clients/src/test/java/org/apache/kafka/clients/admin/MemberDescriptionTest.java
+++ 
b/clients/src/test/java/org/apache/kafka/clients/admin/MemberDescriptionTest.java
@@ -30,6 +30,7 @@ public class MemberDescriptionTest {
 
     private static final String MEMBER_ID = "member_id";
     private static final Optional<String> INSTANCE_ID = 
Optional.of("instanceId");
+    private static final Optional<String> RACK_ID = Optional.of("rackId");
     private static final String CLIENT_ID = "client_id";
     private static final String HOST = "host";
     private static final MemberAssignment ASSIGNMENT;
@@ -39,6 +40,7 @@ public class MemberDescriptionTest {
         ASSIGNMENT = new MemberAssignment(Collections.singleton(new 
TopicPartition("topic", 1)));
         STATIC_MEMBER_DESCRIPTION = new MemberDescription(MEMBER_ID,
                                                           INSTANCE_ID,
+                                                          RACK_ID,
                                                           CLIENT_ID,
                                                           HOST,
                                                           ASSIGNMENT,
@@ -50,6 +52,7 @@ public class MemberDescriptionTest {
     @Test
     public void testEqualsWithoutGroupInstanceId() {
         MemberDescription dynamicMemberDescription = new 
MemberDescription(MEMBER_ID,
+                                                                           
Optional.empty(),
                                                                            
Optional.empty(),
                                                                            
CLIENT_ID,
                                                                            
HOST,
@@ -59,6 +62,7 @@ public class MemberDescriptionTest {
                                                                            
Optional.empty());
 
         MemberDescription identityDescription = new 
MemberDescription(MEMBER_ID,
+                                                                      
Optional.empty(),
                                                                       
Optional.empty(),
                                                                       
CLIENT_ID,
                                                                       HOST,
@@ -83,6 +87,7 @@ public class MemberDescriptionTest {
 
         MemberDescription identityDescription = new 
MemberDescription(MEMBER_ID,
                                                                       
INSTANCE_ID,
+                                                                      RACK_ID,
                                                                       
CLIENT_ID,
                                                                       HOST,
                                                                       
ASSIGNMENT,
@@ -98,6 +103,7 @@ public class MemberDescriptionTest {
     public void testNonEqual() {
         MemberDescription newMemberDescription = new 
MemberDescription("new_member",
                                                                        
INSTANCE_ID,
+                                                                       RACK_ID,
                                                                        
CLIENT_ID,
                                                                        HOST,
                                                                        
ASSIGNMENT,
@@ -110,6 +116,7 @@ public class MemberDescriptionTest {
 
         MemberDescription newInstanceDescription = new 
MemberDescription(MEMBER_ID,
                                                                          
Optional.of("new_instance"),
+                                                                         
RACK_ID,
                                                                          
CLIENT_ID,
                                                                          HOST,
                                                                          
ASSIGNMENT,
@@ -122,6 +129,7 @@ public class MemberDescriptionTest {
 
         MemberDescription newTargetAssignmentDescription = new 
MemberDescription(MEMBER_ID,
                                                                                
  INSTANCE_ID,
+                                                                               
  RACK_ID,
                                                                                
  CLIENT_ID,
                                                                                
  HOST,
                                                                                
  ASSIGNMENT,
@@ -133,6 +141,7 @@ public class MemberDescriptionTest {
 
         MemberDescription newMemberEpochDescription = new 
MemberDescription(MEMBER_ID,
                                                                             
INSTANCE_ID,
+                                                                            
RACK_ID,
                                                                             
CLIENT_ID,
                                                                             
HOST,
                                                                             
ASSIGNMENT,
@@ -144,6 +153,7 @@ public class MemberDescriptionTest {
 
         MemberDescription newIsClassicDescription = new 
MemberDescription(MEMBER_ID,
                                                                           
INSTANCE_ID,
+                                                                          
RACK_ID,
                                                                           
CLIENT_ID,
                                                                           HOST,
                                                                           
ASSIGNMENT,
diff --git 
a/clients/src/test/java/org/apache/kafka/clients/admin/internals/DescribeConsumerGroupsHandlerTest.java
 
b/clients/src/test/java/org/apache/kafka/clients/admin/internals/DescribeConsumerGroupsHandlerTest.java
index eb3e99dc621..b91d2f95471 100644
--- 
a/clients/src/test/java/org/apache/kafka/clients/admin/internals/DescribeConsumerGroupsHandlerTest.java
+++ 
b/clients/src/test/java/org/apache/kafka/clients/admin/internals/DescribeConsumerGroupsHandlerTest.java
@@ -158,6 +158,7 @@ public class DescribeConsumerGroupsHandlerTest {
             new MemberDescription(
                 "memberId",
                 Optional.of("instanceId"),
+                Optional.of("rackId"),
                 "clientId",
                 "host",
                 new MemberAssignment(Set.of(
@@ -172,6 +173,7 @@ public class DescribeConsumerGroupsHandlerTest {
             new MemberDescription(
                 "memberId-classic",
                 Optional.of("instanceId-classic"),
+                Optional.empty(),
                 "clientId-classic",
                 "host",
                 new MemberAssignment(Set.of(
@@ -215,7 +217,7 @@ public class DescribeConsumerGroupsHandlerTest {
                                     .setClientHost("host")
                                     .setClientId("clientId")
                                     .setMemberEpoch(10)
-                                    .setRackId("rackid")
+                                    .setRackId("rackId")
                                     
.setSubscribedTopicNames(singletonList("foo"))
                                     .setSubscribedTopicRegex("regex")
                                     .setAssignment(new 
ConsumerGroupDescribeResponseData.Assignment()
@@ -239,7 +241,7 @@ public class DescribeConsumerGroupsHandlerTest {
                                     .setClientHost("host")
                                     .setClientId("clientId-classic")
                                     .setMemberEpoch(9)
-                                    .setRackId("rackid")
+                                    .setRackId(null)
                                     
.setSubscribedTopicNames(singletonList("bar"))
                                     .setSubscribedTopicRegex("regex")
                                     .setAssignment(new 
ConsumerGroupDescribeResponseData.Assignment()
@@ -269,6 +271,7 @@ public class DescribeConsumerGroupsHandlerTest {
         Collection<MemberDescription> members = singletonList(new 
MemberDescription(
                 "memberId",
                 Optional.empty(),
+                Optional.empty(),
                 "clientId",
                 "host",
                 new MemberAssignment(tps),
diff --git 
a/tools/src/test/java/org/apache/kafka/tools/consumer/group/ConsumerGroupServiceTest.java
 
b/tools/src/test/java/org/apache/kafka/tools/consumer/group/ConsumerGroupServiceTest.java
index 956bebaad82..c8c01fbf746 100644
--- 
a/tools/src/test/java/org/apache/kafka/tools/consumer/group/ConsumerGroupServiceTest.java
+++ 
b/tools/src/test/java/org/apache/kafka/tools/consumer/group/ConsumerGroupServiceTest.java
@@ -142,7 +142,7 @@ public class ConsumerGroupServiceTest {
                 true,
                 Set.of(
                     new MemberDescription(
-                        "member1", Optional.of("instance1"), "client1", 
"host1", new MemberAssignment(assignedTopicPartitions),
+                        "member1", Optional.of("instance1"), 
Optional.of("rackId1"), "client1", "host1", new 
MemberAssignment(assignedTopicPartitions),
                         Optional.empty(), Optional.empty(), Optional.empty()
                     )
                 ),
@@ -259,7 +259,7 @@ public class ConsumerGroupServiceTest {
     @SuppressWarnings("deprecation")
     private DescribeConsumerGroupsResult describeGroupsResult(GroupState 
groupState) {
         MemberDescription member1 = new MemberDescription(
-            "member1", Optional.of("instance1"), "client1", "host1", null,
+            "member1", Optional.of("instance1"), Optional.of("rackId1"), 
"client1", "host1", null,
             Optional.empty(), Optional.empty(), Optional.empty());
         ConsumerGroupDescription description = new 
ConsumerGroupDescription(GROUP,
                 true,
diff --git 
a/tools/src/test/java/org/apache/kafka/tools/consumer/group/ShareGroupCommandTest.java
 
b/tools/src/test/java/org/apache/kafka/tools/consumer/group/ShareGroupCommandTest.java
index 7c7d38822b9..28e51e8c530 100644
--- 
a/tools/src/test/java/org/apache/kafka/tools/consumer/group/ShareGroupCommandTest.java
+++ 
b/tools/src/test/java/org/apache/kafka/tools/consumer/group/ShareGroupCommandTest.java
@@ -199,7 +199,7 @@ public class ShareGroupCommandTest {
             DescribeShareGroupsResult describeShareGroupsResult = 
mock(DescribeShareGroupsResult.class);
             ShareGroupDescription exp = new ShareGroupDescription(
                 firstGroup,
-                List.of(new ShareMemberDescription("memid1", "clId1", "host1", 
new ShareMemberAssignment(
+                List.of(new ShareMemberDescription("memid1", 
Optional.of("rackId1"), "clId1", "host1", new ShareMemberAssignment(
                     Set.of(new TopicPartition("topic1", 0))
                 ), 0)),
                 GroupState.STABLE,
@@ -247,7 +247,7 @@ public class ShareGroupCommandTest {
             DescribeShareGroupsResult describeShareGroupsResult = 
mock(DescribeShareGroupsResult.class);
             ShareGroupDescription exp = new ShareGroupDescription(
                 firstGroup,
-                List.of(new ShareMemberDescription("memid1", "clId1", "host1", 
new ShareMemberAssignment(
+                List.of(new ShareMemberDescription("memid1", Optional.empty(), 
"clId1", "host1", new ShareMemberAssignment(
                     Set.of(new TopicPartition("topic1", 0))
                 ), 0)),
                 GroupState.STABLE,
@@ -300,14 +300,14 @@ public class ShareGroupCommandTest {
             DescribeShareGroupsResult describeShareGroupsResult = 
mock(DescribeShareGroupsResult.class);
             ShareGroupDescription exp1 = new ShareGroupDescription(
                 firstGroup,
-                List.of(new ShareMemberDescription("memid1", "clId1", "host1", 
new ShareMemberAssignment(
+                List.of(new ShareMemberDescription("memid1", 
Optional.of("rackId1"), "clId1", "host1", new ShareMemberAssignment(
                     Set.of(new TopicPartition("topic1", 0))
                 ), 0)),
                 GroupState.STABLE,
                 new Node(0, "host1", 9090), 0, 0);
             ShareGroupDescription exp2 = new ShareGroupDescription(
                 secondGroup,
-                List.of(new ShareMemberDescription("memid1", "clId1", "host1", 
new ShareMemberAssignment(
+                List.of(new ShareMemberDescription("memid1", 
Optional.of("rackId1"), "clId1", "host1", new ShareMemberAssignment(
                     Set.of(new TopicPartition("topic1", 0))
                 ), 0)),
                 GroupState.STABLE,
@@ -375,7 +375,7 @@ public class ShareGroupCommandTest {
             DescribeShareGroupsResult describeShareGroupsResult = 
mock(DescribeShareGroupsResult.class);
             ShareGroupDescription exp1 = new ShareGroupDescription(
                 firstGroup,
-                List.of(new ShareMemberDescription("memid1", "clId1", "host1", 
new ShareMemberAssignment(
+                List.of(new ShareMemberDescription("memid1", 
Optional.of("rackId1"), "clId1", "host1", new ShareMemberAssignment(
                     Set.of(new TopicPartition("topic1", 0))
                 ), 0)),
                 GroupState.STABLE,
@@ -421,14 +421,14 @@ public class ShareGroupCommandTest {
             DescribeShareGroupsResult describeShareGroupsResult = 
mock(DescribeShareGroupsResult.class);
             ShareGroupDescription exp1 = new ShareGroupDescription(
                 firstGroup,
-                List.of(new ShareMemberDescription("memid1", "clId1", "host1", 
new ShareMemberAssignment(
+                List.of(new ShareMemberDescription("memid1", 
Optional.of("rackId1"), "clId1", "host1", new ShareMemberAssignment(
                     Set.of(new TopicPartition("topic1", 0))
                 ), 0)),
                 GroupState.STABLE,
                 new Node(0, "host1", 9090), 0, 0);
             ShareGroupDescription exp2 = new ShareGroupDescription(
                 secondGroup,
-                List.of(new ShareMemberDescription("memid1", "clId1", "host1", 
new ShareMemberAssignment(
+                List.of(new ShareMemberDescription("memid1", 
Optional.of("rackId1"), "clId1", "host1", new ShareMemberAssignment(
                     Set.of(new TopicPartition("topic1", 0))
                 ), 0)),
                 GroupState.STABLE,
@@ -476,7 +476,7 @@ public class ShareGroupCommandTest {
             DescribeShareGroupsResult describeShareGroupsResult = 
mock(DescribeShareGroupsResult.class);
             ShareGroupDescription exp1 = new ShareGroupDescription(
                 firstGroup,
-                List.of(new ShareMemberDescription("memid1", "clId1", "host1", 
new ShareMemberAssignment(
+                List.of(new ShareMemberDescription("memid1", 
Optional.of("rackId1"), "clId1", "host1", new ShareMemberAssignment(
                     Set.of(new TopicPartition("topic1", 0), new 
TopicPartition("topic1", 1), new TopicPartition("topic2", 0))
                 ), 0)),
                 GroupState.STABLE,
@@ -522,14 +522,14 @@ public class ShareGroupCommandTest {
             DescribeShareGroupsResult describeShareGroupsResult = 
mock(DescribeShareGroupsResult.class);
             ShareGroupDescription exp1 = new ShareGroupDescription(
                 firstGroup,
-                List.of(new ShareMemberDescription("memid1", "clId1", "host1", 
new ShareMemberAssignment(
+                List.of(new ShareMemberDescription("memid1", 
Optional.of("rackId1"), "clId1", "host1", new ShareMemberAssignment(
                     Set.of(new TopicPartition("topic1", 0), new 
TopicPartition("topic1", 1), new TopicPartition("topic2", 0))
                 ), 0)),
                 GroupState.STABLE,
                 new Node(0, "host1", 9090), 0, 0);
             ShareGroupDescription exp2 = new ShareGroupDescription(
                 secondGroup,
-                List.of(new ShareMemberDescription("memid1", "clId1", "host1", 
new ShareMemberAssignment(
+                List.of(new ShareMemberDescription("memid1", 
Optional.of("rackId1"), "clId1", "host1", new ShareMemberAssignment(
                     Set.of(new TopicPartition("topic1", 0))
                 ), 0)),
                 GroupState.STABLE,
@@ -1333,7 +1333,7 @@ public class ShareGroupCommandTest {
 
         ShareGroupDescription exp = new ShareGroupDescription(
             group,
-            List.of(new ShareMemberDescription("memid1", "clId1", "host1", new 
ShareMemberAssignment(
+            List.of(new ShareMemberDescription("memid1", Optional.empty(), 
"clId1", "host1", new ShareMemberAssignment(
                 Set.of(new TopicPartition("topic", 0))
             ), 0)),
             GroupState.STABLE,

Reply via email to