hachikuji commented on a change in pull request #9482: URL: https://github.com/apache/kafka/pull/9482#discussion_r514585353
########## File path: raft/src/main/java/org/apache/kafka/raft/RaftClient.java ########## @@ -26,30 +24,53 @@ interface Listener<T> { /** - * Callback which is invoked when records written through {@link #scheduleAppend(int, List)} - * become committed. + * Callback which is invoked for all records committed to the log. + * It is the responsibility of the caller to invoke {@link BatchReader#close()} + * after consuming the reader. * * Note that there is not a one-to-one correspondence between writes through * {@link #scheduleAppend(int, List)} and this callback. The Raft implementation * is free to batch together the records from multiple append calls provided * that batch boundaries are respected. This means that each batch specified * through {@link #scheduleAppend(int, List)} is guaranteed to be a subset of - * a batch passed to {@link #handleCommit(int, long, List)}. + * a batch provided by the {@link BatchReader}. + * + * @param reader reader instance which must be iterated and closed + */ + void handleCommit(BatchReader<T> reader); + + /** + * Invoked after this node has become a leader. This is only called after + * all commits up to the start of the leader's epoch have been sent to + * {@link #handleCommit(BatchReader)}. + * + * After becoming a leader, the client is eligible to write to the log + * using {@link #scheduleAppend(int, List)}. * - * @param epoch the epoch in which the write was accepted - * @param lastOffset the offset of the last record in the record list - * @param records the set of records that were committed + * @param epoch the claimed leader epoch */ - void handleCommit(int epoch, long lastOffset, List<T> records); + default void handleClaim(int epoch) {} Review comment: Yeah, I considered using `handleBecomeLeader` and `handleResignLeader`. In the end, I decided to use the more concise `handleClaim` and `handleResign` which are used in the kip-500 branch. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org