You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "dengziming (Jira)" <ji...@apache.org> on 2021/05/19 00:15:00 UTC

[jira] [Resolved] (KAFKA-10195) Move offset management codes from ConsumerCoordinator to a new class

     [ https://issues.apache.org/jira/browse/KAFKA-10195?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

dengziming resolved KAFKA-10195.
--------------------------------
    Resolution: Won't Fix

> Move offset management codes from ConsumerCoordinator to a new class
> --------------------------------------------------------------------
>
>                 Key: KAFKA-10195
>                 URL: https://issues.apache.org/jira/browse/KAFKA-10195
>             Project: Kafka
>          Issue Type: Improvement
>          Components: clients, consumer
>            Reporter: dengziming
>            Assignee: dengziming
>            Priority: Minor
>
> ConsumerCoordinator has 2 main functions:
>  # partitions assignment
>  # offset management
> We are adding some new features in it, for example KAFKA-9657 add a field `throwOnFetchStableOffsetsUnsupported` which only used in offset management.
> And the 2 functions almost don't interact with each other, so it's not wise to put these code in one single class, can we try to move offset management code to a new class?
> For example, the below fields only used in offset management:
>  ```
> // can be move to another class directly
>  private final OffsetCommitCallback defaultOffsetCommitCallback;
>  private final ConsumerInterceptors<?, ?> interceptors;
>  private final AtomicInteger pendingAsyncCommits;
>  private final ConcurrentLinkedQueue<OffsetCommitCompletion> completedOffsetCommits;
>  private AtomicBoolean asyncCommitFenced;
>  private final boolean throwOnFetchStableOffsetsUnsupported;
>  private PendingCommittedOffsetRequest pendingCommittedOffsetRequest = null;
>  
> // used in `onJoinComplete` but can also be moved out.
> private final boolean autoCommitEnabled;
>  private final int autoCommitIntervalMs;
>  private Timer nextAutoCommitTimer;
>  ```
> So we can just create a new class `OffsetManageCoordinator` and move the related codes into it. Similarly, a new class `SubscribeManager` can also be created. here is the UML class diagram:
> !image-2020-06-28-19-50-26-570.png!
>  
> The above is the current design in which KafkaConsumer interact with Consumer directly. the below is the new design, we add a `ConsumerCoordinatorFacade` in which we put `OffsetCoordinator` and `SubscribeCoordinator` to manage offset and assigning respectively. both `OffsetCoordinator` and `SubscribeCoordinator` need a `AbstractCoordinator` cause they will interact with each other(even rarely).
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)