neuyilan commented on a change in pull request #1380:
URL: https://github.com/apache/incubator-iotdb/pull/1380#discussion_r441944071



##########
File path: 
cluster/src/main/java/org/apache/iotdb/cluster/config/ConsistencyLevel.java
##########
@@ -0,0 +1,64 @@
+/*
+ * 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.iotdb.cluster.config;
+
+
+public enum ConsistencyLevel {
+  /**
+   * Strong consistency means the server will first try to synchronize with 
the leader to get the
+   * newest meta data, if failed(timeout), directly report an error to the 
user;
+   */
+  STRONG_CONSISTENCY("strong"),
+
+  /**
+   * mid consistency means the server will first try to synchronize with the 
leader, but if
+   * failed(timeout), it will give up and just use current data it has cached 
before;
+   */
+  MID_CONSISTENCY("mid"),
+
+  /**
+   * weak consistency do not synchronize with the leader and simply use the 
local data
+   */
+  WEAK_CONSISTENCY("weak"),
+  ;
+
+  private String consistencyLevel;
+
+  ConsistencyLevel(String consistencyLevel) {
+    this.consistencyLevel = consistencyLevel;
+  }
+
+
+  public static ConsistencyLevel getConsistencyLevel(String consistencyLevel) {
+    if (consistencyLevel == null) {
+      return ConsistencyLevel.MID_CONSISTENCY;
+    }
+    switch (consistencyLevel.toLowerCase()) {
+      case "strong":
+        return ConsistencyLevel.STRONG_CONSISTENCY;
+      case "mid":
+        return ConsistencyLevel.MID_CONSISTENCY;
+      case "weak":
+        return ConsistencyLevel.WEAK_CONSISTENCY;
+      default:
+        return ConsistencyLevel.MID_CONSISTENCY;

Review comment:
       > I would suggest print a warning log in the default branch in case that 
the user mistyped this configuration, e.g., the user types "weak" as "waek" 
without notice, and we should inform him that the consistency is not what he 
has thought.
   
   Good suggestion, I will fix 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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to