cadonna commented on code in PR #18809:
URL: https://github.com/apache/kafka/pull/18809#discussion_r1954540074


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -3962,7 +4359,167 @@ public void replay(
             }
             removeGroup(groupId);
         }
+    }
+
+    /**
+     * Replays StreamsGroupMemberMetadataKey/Value to update the hard state of
+     * the streams group.
+     * It updates the subscription part of the member or deletes the member.
+     *
+     * @param key   A StreamsGroupMemberMetadataKey key.
+     * @param value A StreamsGroupMemberMetadataValue record.
+     */
+    public void replay(
+        StreamsGroupMemberMetadataKey key,
+        StreamsGroupMemberMetadataValue value
+    ) {
+        String groupId = key.groupId();
+        String memberId = key.memberId();
+
+        StreamsGroup streamsGroup;
+        try {
+            streamsGroup = getOrMaybeCreatePersistedStreamsGroup(groupId, 
value != null);
+        } catch (GroupIdNotFoundException ex) {
+            // If the group does not exist and a tombstone is replayed, we can 
ignore it.
+            return;
+        }
+
+        if (value != null) {
+            StreamsGroupMember oldMember = 
streamsGroup.getOrMaybeCreateMember(memberId, true);
+            streamsGroup.updateMember(new StreamsGroupMember.Builder(oldMember)
+                .updateWith(value)
+                .build());

Review Comment:
   I understand. I was not advertizing to add the member to the group within 
`getOrMaybeCreate()`, but rather to explicitly build the member outside of 
`getOrMaybeCreate()`. We would then have a simple `get()` method and depeding 
on the result of the get use the `Builder` of the member. That would make it 
quite clear that the member is not added to the group. But maybe a renaming of 
`getOrMaybeCreate()` to `getOrDefault()` or similar would also make it clear.   



-- 
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