Phuc-Hong-Tran commented on code in PR #14327:
URL: https://github.com/apache/kafka/pull/14327#discussion_r1469332580


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -1573,6 +1589,33 @@ private void updateGroupsByTopics(
                 }
             });
         }
+        if (!oldSubscribedTopicRegex.isEmpty()) {
+            oldSubscribedTopicRegex.forEach(regex -> {
+                groupsByRegex.computeIfPresent(regex, (__, groupIds) -> {
+                    groupIds.remove(groupId);
+                    return groupIds.isEmpty() ? null : groupIds;
+                });
+                Pattern pattern = Pattern.compile(regex);
+                for (String topicName : 
metadataImage.topics().topicsByName().keySet()) {
+                    if (pattern.matcher(topicName).matches()) {
+                        unsubscribeGroupFromTopic(groupId, topicName);
+                    }
+                }
+            });
+        }
+        if (!newSubscribedTopicRegex.isEmpty()) {
+            newSubscribedTopicRegex.forEach(regex -> {
+                groupsByRegex
+                        .computeIfAbsent(regex, __ -> new 
TimelineHashSet<>(snapshotRegistry, 1))
+                        .add(groupId);
+                Pattern pattern = Pattern.compile(regex);
+                for (String topicName : 
metadataImage.topics().topicsByName().keySet()) {
+                    if (pattern.matcher(topicName).matches()) {
+                        subscribeGroupToTopic(groupId, topicName);
+                    }
+                }

Review Comment:
   Just one question, why is computing the list of topics to subscribe to 
expensive here? My guess is that metadataImage is something that we need to 
load from disk?



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