SzyWilliam commented on code in PR #700:
URL: https://github.com/apache/ratis/pull/700#discussion_r939542836


##########
ratis-server/src/main/java/org/apache/ratis/server/impl/LeaderStateImpl.java:
##########
@@ -422,6 +423,40 @@ CompletableFuture<RaftClientReply> 
addWatchReqeust(RaftClientRequest request) {
         .exceptionally(e -> exception2RaftClientReply(request, e));
   }
 
+  /**
+   * Obtain the current readIndex for read only requests. See Raft paper 
section 6.4.
+   * 1. Leader makes sure at least one log from current term is committed.
+   * 2. Leader record last committed index as readIndex.
+   * 3. Leader broadcast heartbeats to followers and waits for 
acknowledgements.
+   * 4. If majority respond success, returns readIndex.
+   * @return current readIndex.
+   */
+  public CompletableFuture<Long> getReadIndex() {
+    // if group contains only one member, fast path
+    if (server.getGroup().getPeers().size() == 1) {

Review Comment:
   I think we should use  `if (server.getRaftConf().getCurrentPeerSize() == 0) {
   since getCurrentPeerSize will return follower peers.



-- 
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]

Reply via email to