peterxcli commented on code in PR #11252:
URL: https://github.com/apache/ozone/pull/11252#discussion_r4152973824


##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/ha/OMFailoverProxyProviderBase.java:
##########
@@ -425,6 +427,25 @@ public List<OMProxyInfo<T>> getOMProxies() {
     return omProxies.getProxies();
   }
 
+  /**
+   * Determines whether an eligible read request may be sent to an OM follower.
+   *
+   * <p>An explicit consistency hint takes precedence over the configured
+   * default follower-read behavior.</p>
+   */
+  public static boolean shouldUseFollowerRead(OMRequest request,
+      boolean omServiceSupportsFollowerRead,
+      boolean defaultFollowerReadEnabled) {
+    if (!omServiceSupportsFollowerRead || 
!OmUtils.shouldSendToFollower(request)) {
+      return false;
+    }
+    if (request.hasReadConsistencyHint()) {
+      return ReadConsistency.fromProto(request.getReadConsistencyHint()
+          .getReadConsistency()).allowFollowerRead();
+    }
+    return defaultFollowerReadEnabled;
+  }

Review Comment:
   we might want to extract/refactor the change introduced in 
https://github.com/apache/ozone/pull/10591 to 
`GrpcOMFollowerReadFailoverProxyProvider`, and add 
`FollowerReadFailoverProxyProviderBase` as base class for 
`GrpcOMFollowerReadFailoverProxyProvider` and 
`HadoopRpcOMFollowerReadFailoverProxyProvider`, so we can put follower read 
things (eg. `defaultFollowerReadEnabled`, some helper) in it.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to