szetszwo commented on code in PR #1448:
URL: https://github.com/apache/ratis/pull/1448#discussion_r4100532075


##########
ratis-server/src/main/java/org/apache/ratis/server/impl/WriteIndexCache.java:
##########
@@ -58,8 +59,13 @@ void add(ClientId key, CompletableFuture<Long> current) {
   }
 
   CompletableFuture<Long> getWriteIndexFuture(RaftClientRequest request) {
-    if (request != null && 
request.getType().getRead().getReadAfterWriteConsistent()) {
-      final AtomicReference<CompletableFuture<Long>> ref = 
cache.getIfPresent(request.getClientId());
+    return request != null ? getWriteIndexFuture(request.getClientId(), 
request.getType().getRead())
+        : CompletableFuture.completedFuture(null);
+  }

Review Comment:
   Message and Supplier actually are almost the same since they both are 
interface.  Indeed, Message is more flexible in this PR since we never call any 
methods in Message.  The StateMachine can choose to do what even it wants.  We 
may simulate a Supplier as below:
   
   ```java
     static class OmReadOzoneMessage implements Message {
       CompletableFuture<Message> getReply() {
         return ...
       }
   
       @Override
       public ByteString getContent() {
         throw new UnsupportedOperationException();
       }
     }
   
   //StateMachine implementation
     public CompletableFuture<Message> query(Message request) {
       if (request instanceof OmReadOzoneMessage) {
         return ((OmReadOzoneMessage)request).getReply();
       }
       
       ...
     }
   ```



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