ivandika3 commented on code in PR #1448:
URL: https://github.com/apache/ratis/pull/1448#discussion_r4068891657
##########
ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java:
##########
@@ -1109,6 +1116,74 @@ private CompletableFuture<ReadIndexReplyProto>
sendReadIndexAsync(RaftClientRequ
private CompletableFuture<Long> getReadIndex(RaftClientRequest request,
LeaderStateImpl leader) {
return
writeIndexCache.getWriteIndexFuture(request).thenCompose(leader::getReadIndex);
}
+ private CompletableFuture<Long>
getReadIndex(CompletableFuture<ReadIndexReplyProto> readIndexReply) {
+ return readIndexReply.thenApply(reply -> {
+ if (reply.getServerReply().getSuccess()) {
+ return reply.getReadIndex();
+ } else {
+ throw new CompletionException(new ReadIndexException(getId()
+ + ": Failed to get read index from the leader: " + reply));
+ }
+ });
+ }
+
+ private CompletableFuture<Long> getReadIndexForReadOnly(ClientId clientId,
ReadRequestTypeProto readRequestType) {
+ final LeaderStateImpl leader = role.getLeaderState().orElse(null);
+ if (leader != null) {
+ return leader.getReadIndex(null);
Review Comment:
Thanks, I have updated it so call `writeIndexCache`.
--
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]