szetszwo commented on code in PR #9796:
URL: https://github.com/apache/ozone/pull/9796#discussion_r2842292299


##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/ReadConsistency.java:
##########
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.om.helpers;
+
+import 
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ReadConsistencyType;
+
+/**
+ * Supported read consistency. It consists of two elements
+ * <ol>
+ *   <li>
+ *     {@link ConsistencyType} which specifies different types of read 
consistency
+ *     (e.g. LINEARIZABLE, LOCAL_LEASE)
+ *   </li>
+ *   <li>
+ *     Whether to allow follower read. Some consistency types supports
+ *     follower read (e.g. LINEARIZABLE) while other consistency types only
+ *     supports leader read (e.g. NON_LINEARIZABLE).
+ *   </li>
+ * </ol>
+ *
+ * handles different types of read consistency (e.g. LINEARIZABLE, LOCAL_LEASE)
+ */
+public enum ReadConsistency {
+  DEFAULT(ConsistencyType.NON_LINEARIZABLE, false),
+  STALE(ConsistencyType.STALE, true),
+  LINEARIZABLE_LEADER_READ(ConsistencyType.LINEARIZABLE, false),
+  LINEARIZABLE_FOLLOWER_READ(ConsistencyType.LINEARIZABLE, true),
+  LOCAL_LEASE_FOLLOWER_READ(ConsistencyType.LOCAL_LEASE, true);

Review Comment:
   1. Stale read can be supported by local lease with infinite log lag and time 
limit.  We may remove STALE for simplicity.
   2. I think we don't need the inner enum `ConsistencyType`.  Just add a 
boolean for linearizable.
   3. `isAllowFollowerRead` sounds odd.  Let's use nouns for the fields and add 
the verb to the method.
   
   Below is my suggestion:
   
   ```java
   public enum ReadConsistency {
     DEFAULT(false, false),
     LOCAL_LEASE(false, true),
     LINEARIZABLE_LEADER_ONLY(true, false),
     LINEARIZABLE_ALLOW_FOLLOWER(true, true);
   
     private final boolean linearizable;
     private final boolean followerRead;
   
     ReadConsistency(boolean linearizable, boolean followerRead) {
       this.linearizable = linearizable;
       this.followerRead = followerRead;
     }
   
     public boolean isLinearizable() {
       return linearizable;
     }
   
     public boolean allowFollowerRead() {
       return followerRead;
     }
   
     ...
   }
   ```
   



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