dajac commented on code in PR #13639: URL: https://github.com/apache/kafka/pull/13639#discussion_r1192204200
########## group-coordinator/src/main/java/org/apache/kafka/coordinator/group/consumer/ConsumerGroup.java: ########## @@ -0,0 +1,535 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.kafka.coordinator.group.consumer; + +import org.apache.kafka.common.Uuid; +import org.apache.kafka.common.errors.UnknownMemberIdException; +import org.apache.kafka.coordinator.group.Group; +import org.apache.kafka.image.TopicImage; +import org.apache.kafka.image.TopicsImage; +import org.apache.kafka.timeline.SnapshotRegistry; +import org.apache.kafka.timeline.TimelineHashMap; +import org.apache.kafka.timeline.TimelineInteger; +import org.apache.kafka.timeline.TimelineObject; + +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; + +/** + * A Consumer Group. All the metadata in this class are backed by + * records in the __consumer_offsets partitions. + */ +public class ConsumerGroup implements Group { + + public enum ConsumerGroupState { + EMPTY("empty"), + ASSIGNING("assigning"), + RECONCILING("reconciling"), + STABLE("stable"), + DEAD("dead"); + + private final String name; + + ConsumerGroupState(String name) { + this.name = name; + } + + @Override + public String toString() { + return name; + } + } + + /** + * The snapshot registry. + */ + private final SnapshotRegistry snapshotRegistry; + + /** + * The group id. + */ + private final String groupId; + + /** + * The group state. + */ + private final TimelineObject<ConsumerGroupState> state; + + /** + * The group epoch. The epoch is incremented whenever the subscriptions + * are updated and it will trigger the computation of a new assignment + * for the group. + */ + private final TimelineInteger groupEpoch; + + /** + * The group members. + */ + private final TimelineHashMap<String, ConsumerGroupMember> members; + + /** + * The metadata of the subscribed topics. + */ + private final TimelineHashMap<String, TopicMetadata> subscribedTopicMetadata; + + /** + * The assignment epoch. An assignment epoch smaller than the group epoch means + * that a new assignment is required. The assignment epoch is updated when a new + * assignment is installed. + */ + private final TimelineInteger assignmentEpoch; + + /** + * The target assignment. + */ + private final TimelineHashMap<String, Assignment> assignments; + + /** + * The current partition epoch maps each topic-partitions to their current epoch where Review Comment: This is indeed not in the KIP because this is an implementation detail. We need to track epoch of partitions in order to know if they are free or not. An epoch with an old epoch basically means that the partition has not been revoked yet. -- 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