dengziming commented on a change in pull request #10909:
URL: https://github.com/apache/kafka/pull/10909#discussion_r680283810
##########
File path: raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java
##########
@@ -2248,24 +2250,23 @@ public void poll() {
}
@Override
- public Long scheduleAppend(int epoch, List<T> records) {
+ public long scheduleAppend(int epoch, List<T> records) {
return append(epoch, records, false);
}
@Override
- public Long scheduleAtomicAppend(int epoch, List<T> records) {
+ public long scheduleAtomicAppend(int epoch, List<T> records) {
return append(epoch, records, true);
}
- private Long append(int epoch, List<T> records, boolean isAtomic) {
- Optional<LeaderState<T>> leaderStateOpt = quorum.maybeLeaderState();
- if (!leaderStateOpt.isPresent()) {
- return Long.MAX_VALUE;
- }
+ private long append(int epoch, List<T> records, boolean isAtomic) {
+ LeaderState<T> leaderState = quorum.<T>maybeLeaderState().orElseThrow(
+ () -> new NotLeaderException("Append failed because the
replication is not the current leader")
Review comment:
Here I referred to the practices of `KafkaController` in which we have
`NOT_CONTROLLER` and `STALE_CONTROLLER_EPOCH` for RPC errors, but here I also
think it's better to consolidate `NotLeaderException` and
`FencedEpochException` now.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]