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


##########
ratis-server-api/src/main/java/org/apache/ratis/server/RaftServerConfigKeys.java:
##########
@@ -157,6 +157,42 @@ static void setClientSize(RaftProperties properties, int 
port) {
     }
   }
 
+  interface Read {
+    String PREFIX = RaftServerConfigKeys.PREFIX
+            + "." + JavaUtils.getClassSimpleName(Read.class).toLowerCase();
+
+    String TIMEOUT_KEY = PREFIX + ".timeout";
+    TimeDuration TIMEOUT_DEFAULT = TimeDuration.valueOf(10, TimeUnit.SECONDS);
+    static TimeDuration timeout(RaftProperties properties) {
+      return 
getTimeDuration(properties.getTimeDuration(TIMEOUT_DEFAULT.getUnit()),
+          TIMEOUT_KEY, TIMEOUT_DEFAULT, getDefaultLog(), requirePositive());
+    }
+    static void setTimeout(RaftProperties properties, TimeDuration 
readOnlyTimeout) {
+      setTimeDuration(properties::setTimeDuration, TIMEOUT_KEY, 
readOnlyTimeout);
+    }
+
+    enum ReadOption {
+      /** Directly query the statemachine. Efficient but may undermine 
linearizability */
+      DEFAULT,
+      /** Use ReadIndex (see Raft section 6.4), strictly linearizable */
+      SAFE;
+      // TODO LEADER_LEASE

Review Comment:
   LEADER_LEASE obtains ReadIndex in a different way (using lease), which may 
undermine linearizability under unbounded CPU clock drift but is about 15% 
faster than LINEARIZABLE. So we use either LINEARIZABLE or LEADER_LEASE to 
handle read-only requests.



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