dajac commented on code in PR #15785: URL: https://github.com/apache/kafka/pull/15785#discussion_r1587922375
########## group-coordinator/src/main/java/org/apache/kafka/coordinator/group/consumer/ConsumerGroup.java: ########## @@ -966,6 +979,53 @@ private static void maybeUpdateSubscribedTopicNames( } } + /** + * Updates the subscription count. + * + * @param oldMember The old member. + * @param newMember The new member. + * + * @return Copy of the map of topics to the count of number of subscribers. + */ + public Map<String, Integer> computeSubscribedTopicNames( + ConsumerGroupMember oldMember, + ConsumerGroupMember newMember + ) { + Map<String, Integer> subscribedTopicNames = new HashMap<>(this.subscribedTopicNames); + maybeUpdateSubscribedTopicNames( + subscribedTopicNames, + oldMember, + newMember + ); + return subscribedTopicNames; + } + + /** + * Compute the subscription type of the consumer group. + * + * @param subscribedTopicNames A map of topic names to the count of members subscribed to each topic. + * + * @return {@link SubscriptionType#HOMOGENEOUS} if all members are subscribed to exactly the same topics; + * otherwise, {@link SubscriptionType#HETEROGENEOUS}. + */ + public static SubscriptionType subscriptionType( + Map<String, Integer> subscribedTopicNames + ) { + if (subscribedTopicNames.isEmpty()) { + return HOMOGENEOUS; + } + + // Take the subscriber count of the first topic as the reference. + int referenceCount = subscribedTopicNames.values().iterator().next(); Review Comment: > we need to somehow get the accurate total member count and use this only We can get the current count and update it locally when a new member is created and we don't replace a static member, I suppose. -- 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