vamossagar12 commented on code in PR #14432:
URL: https://github.com/apache/kafka/pull/14432#discussion_r1370538866


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -983,27 +1052,125 @@ private 
CoordinatorResult<ConsumerGroupHeartbeatResponseData, Record> consumerGr
         return new CoordinatorResult<>(records, response);
     }
 
+    private void replaceStaticMemberInConsumerGroup(
+        String groupId,
+        List<Record> records,
+        ConsumerGroup group,
+        ConsumerGroupMember member,
+        ConsumerGroupMember existingStaticMember,
+        ConsumerGroupMember updatedMember
+    ) {
+        // Write tombstones for the departed static member. Follow the same 
order as the one followed when fencing
+        // a member
+        records.add(newCurrentAssignmentTombstoneRecord(group.groupId(), 
existingStaticMember.memberId()));
+        records.add(newTargetAssignmentTombstoneRecord(group.groupId(), 
existingStaticMember.memberId()));
+        records.add(newMemberSubscriptionTombstoneRecord(group.groupId(), 
existingStaticMember.memberId()));
+        // Cancel all the timers of the departed static member.
+        cancelConsumerGroupSessionTimeout(group.groupId(), 
existingStaticMember.memberId());
+        cancelConsumerGroupRevocationTimeout(group.groupId(), 
existingStaticMember.memberId());
+        // Write a record corresponding to the new member
+        records.add(newMemberSubscriptionRecord(groupId, updatedMember));
+        TargetAssignmentBuilder.TargetAssignmentResult assignmentResult = 
computeTargetAssignment(group, group.groupEpoch(), member, updatedMember);
+        records.addAll(assignmentResult.records());
+        records.add(newCurrentAssignmentRecord(groupId, updatedMember));
+    }
+
+    private TargetAssignmentBuilder.TargetAssignmentResult 
computeTargetAssignment(
+        ConsumerGroup group,
+        int groupEpoch,
+        ConsumerGroupMember member,
+        ConsumerGroupMember updatedMember) {
+        String preferredServerAssignor = group.computePreferredServerAssignor(
+            member,
+            updatedMember
+        ).orElse(defaultAssignor.name());
+
+        String groupId = group.groupId();
+        Map<String, TopicMetadata> subscriptionMetadata = 
group.subscriptionMetadata();
+        String memberId = member.memberId();
+        try {
+            TargetAssignmentBuilder.TargetAssignmentResult assignmentResult =
+                new TargetAssignmentBuilder(groupId, groupEpoch, 
assignors.get(preferredServerAssignor))
+                    .withMembers(group.members())

Review Comment:
   Also, regarding 
   
   > Then we only need to recompute the assignment if there is a group epoch 
bump.
   
   Given that now we will have a group epoch bump whenever a static member 
re-joins with a different subscription, should this be mentioned in the KIP? As 
we noticed, this is a deviation from how the static member rejoining with a 
different subscription case as of today. 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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to