SzyWilliam commented on code in PR #898:
URL: https://github.com/apache/ratis/pull/898#discussion_r1320925484
##########
ratis-server/src/main/java/org/apache/ratis/server/impl/LeaderStateImpl.java:
##########
@@ -1127,6 +1139,47 @@ public void onAppendEntriesReply(LogAppender appender,
RaftProtos.AppendEntriesR
readIndexHeartbeats.onAppendEntriesReply(appender, reply,
this::hasMajority);
}
+ boolean hasValidLeaderLease() {
+ if (checkLeaderLease()) {
+ return true;
+ }
+
+ extendLeaderLease();
+ return checkLeaderLease();
+ }
+
+ private boolean checkLeaderLease() {
+ return isReady() && lease.get().elapsedTimeMs() < leaseTimeoutMs;
+ }
+
+ private void extendLeaderLease() {
Review Comment:
Thanks for the reminding! We should also include the previous peers too.
##########
ratis-server/src/main/java/org/apache/ratis/server/impl/LeaderStateImpl.java:
##########
@@ -1127,6 +1139,47 @@ public void onAppendEntriesReply(LogAppender appender,
RaftProtos.AppendEntriesR
readIndexHeartbeats.onAppendEntriesReply(appender, reply,
this::hasMajority);
}
+ boolean hasValidLeaderLease() {
+ if (checkLeaderLease()) {
+ return true;
+ }
+
+ extendLeaderLease();
+ return checkLeaderLease();
+ }
+
+ private boolean checkLeaderLease() {
+ return isReady() && lease.get().elapsedTimeMs() < leaseTimeoutMs;
Review Comment:
Done.
--
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]