You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/08/29 09:54:52 UTC

[GitHub] [iotdb] qiaojialin commented on a diff in pull request #7161: [IOTDB-4241] Fix set system mode

qiaojialin commented on code in PR #7161:
URL: https://github.com/apache/iotdb/pull/7161#discussion_r957117848


##########
server/src/main/java/org/apache/iotdb/db/utils/HandleSystemErrorStrategy.java:
##########
@@ -18,11 +18,38 @@
  */
 package org.apache.iotdb.db.utils;
 
+import org.apache.iotdb.commons.cluster.NodeStatus;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 public enum HandleSystemErrorStrategy {
   /** just set system status to error and then do nothing else */
   NONE,
   /** set system status to read-only and the system only accepts query operations */
   CHANGE_TO_READ_ONLY,
   /** the system will be shutdown */
-  SHUTDOWN,
+  SHUTDOWN;
+
+  private static final Logger logger = LoggerFactory.getLogger(HandleSystemErrorStrategy.class);
+
+  public NodeStatus handle() {
+    NodeStatus status = NodeStatus.Error;
+    if (this == HandleSystemErrorStrategy.NONE) {
+      logger.error(
+          "Unrecoverable error occurs! Just change system status to error when handle_system_error is NONE.",
+          new RuntimeException("System mode is set to ERROR"));
+    } else if (this == HandleSystemErrorStrategy.CHANGE_TO_READ_ONLY) {
+      logger.error(
+          "Unrecoverable error occurs! Change system status to read-only when handle_system_error is CHANGE_TO_READ_ONLY. Only query statements are permitted!",

Review Comment:
   ```suggestion
             "Unrecoverable error occurs! Change system status to read-only because handle_system_error is CHANGE_TO_READ_ONLY. Only query statements are permitted!",
   ```



##########
server/src/main/java/org/apache/iotdb/db/utils/HandleSystemErrorStrategy.java:
##########
@@ -18,11 +18,38 @@
  */
 package org.apache.iotdb.db.utils;
 
+import org.apache.iotdb.commons.cluster.NodeStatus;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 public enum HandleSystemErrorStrategy {
   /** just set system status to error and then do nothing else */
   NONE,
   /** set system status to read-only and the system only accepts query operations */
   CHANGE_TO_READ_ONLY,
   /** the system will be shutdown */
-  SHUTDOWN,
+  SHUTDOWN;
+
+  private static final Logger logger = LoggerFactory.getLogger(HandleSystemErrorStrategy.class);
+
+  public NodeStatus handle() {
+    NodeStatus status = NodeStatus.Error;
+    if (this == HandleSystemErrorStrategy.NONE) {
+      logger.error(
+          "Unrecoverable error occurs! Just change system status to error when handle_system_error is NONE.",
+          new RuntimeException("System mode is set to ERROR"));
+    } else if (this == HandleSystemErrorStrategy.CHANGE_TO_READ_ONLY) {
+      logger.error(
+          "Unrecoverable error occurs! Change system status to read-only when handle_system_error is CHANGE_TO_READ_ONLY. Only query statements are permitted!",
+          new RuntimeException("System mode is set to READ_ONLY"));
+      status = NodeStatus.ReadOnly;
+    } else if (this == HandleSystemErrorStrategy.SHUTDOWN) {
+      logger.error(
+          "Unrecoverable error occurs! Shutdown system directly when handle_system_error is SHUTDOWN.",

Review Comment:
   ```suggestion
             "Unrecoverable error occurs! Shutdown system directly because handle_system_error is SHUTDOWN.",
   ```



##########
server/src/main/java/org/apache/iotdb/db/utils/HandleSystemErrorStrategy.java:
##########
@@ -18,11 +18,38 @@
  */
 package org.apache.iotdb.db.utils;
 
+import org.apache.iotdb.commons.cluster.NodeStatus;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 public enum HandleSystemErrorStrategy {
   /** just set system status to error and then do nothing else */
   NONE,
   /** set system status to read-only and the system only accepts query operations */
   CHANGE_TO_READ_ONLY,
   /** the system will be shutdown */
-  SHUTDOWN,
+  SHUTDOWN;
+
+  private static final Logger logger = LoggerFactory.getLogger(HandleSystemErrorStrategy.class);
+
+  public NodeStatus handle() {
+    NodeStatus status = NodeStatus.Error;
+    if (this == HandleSystemErrorStrategy.NONE) {
+      logger.error(
+          "Unrecoverable error occurs! Just change system status to error when handle_system_error is NONE.",

Review Comment:
   ```suggestion
             "Unrecoverable error occurs! Just change system status to error because handle_system_error is NONE.",
   ```



-- 
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: reviews-unsubscribe@iotdb.apache.org

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