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


##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/parser/ASTVisitor.java:
##########
@@ -2429,12 +2415,28 @@ public Statement 
visitLoadConfiguration(IoTDBSqlParser.LoadConfigurationContext
       throw new SemanticException(
           "LOAD CONFIGURATION ON CLUSTER is not supported in standalone mode");
     }
-    if (ctx.LOCAL() != null) {
-      loadConfigurationStatement.setCluster(false);
+    loadConfigurationStatement.setOnCluster(ctx.LOCAL() == null);
+    return loadConfigurationStatement;
+  }
+
+  // Set System Status
+
+  @Override
+  public Statement visitSetSystemStatus(IoTDBSqlParser.SetSystemStatusContext 
ctx) {
+    SetSystemStatusStatement setSystemStatusStatement = new 
SetSystemStatusStatement();
+    if (ctx.CLUSTER() != null && 
!IoTDBDescriptor.getInstance().getConfig().isClusterMode()) {
+      throw new SemanticException(
+          "SET SYSTEM STATUS ON CLUSTER is not supported in standalone mode");
+    }
+    setSystemStatusStatement.setOnCluster(ctx.LOCAL() == null);
+    if (ctx.RUNNING() != null) {
+      setSystemStatusStatement.setStatus(NodeStatus.Running);
+    } else if (ctx.READONLY() != null) {
+      setSystemStatusStatement.setStatus(NodeStatus.ReadOnly);
     } else {
-      loadConfigurationStatement.setCluster(true);
+      setSystemStatusStatement.setStatus(NodeStatus.Error);

Review Comment:
   check if  ctx.ERROR() != null



##########
server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java:
##########
@@ -2239,12 +2240,12 @@ public Operator 
visitSettle(IoTDBSqlParser.SettleContext ctx) {
 
   @Override
   public Operator visitSetSystemStatus(IoTDBSqlParser.SetSystemStatusContext 
ctx) {
-    if (ctx.READONLY() != null) {
-      // Set system to ReadOnly
-      return new SetSystemModeOperator(SQLConstant.TOK_SET_SYSTEM_MODE, true);
+    if (ctx.RUNNING() != null) {
+      return new SetSystemModeOperator(SQLConstant.TOK_SET_SYSTEM_MODE, 
NodeStatus.Running);
+    } else if (ctx.READONLY() != null) {
+      return new SetSystemModeOperator(SQLConstant.TOK_SET_SYSTEM_MODE, 
NodeStatus.ReadOnly);
     } else {
-      // Set system to Writable
-      return new SetSystemModeOperator(SQLConstant.TOK_SET_SYSTEM_MODE, false);
+      return new SetSystemModeOperator(SQLConstant.TOK_SET_SYSTEM_MODE, 
NodeStatus.Error);

Review Comment:
   Only ctx.ERROR() != null  will set System to ERROR. otherwise, throw 
exception here.



##########
server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java:
##########
@@ -1566,17 +1569,21 @@ public NodeStatus getNodeStatus() {
   public void setNodeStatus(NodeStatus newStatus) {
     if (newStatus == NodeStatus.ReadOnly) {
       logger.error(
-          "Change system mode to read-only! Only query statements are 
permitted!",
+          "Change system status to read-only! Only query statements are 
permitted!",
           new RuntimeException("System mode is set to READ_ONLY"));
     } else if (newStatus == NodeStatus.Error) {

Review Comment:
   move this logic to HandleSystemErrorStrategy



##########
docs/zh/UserGuide/Maintenance-Tools/Maintenance-Command.md:
##########
@@ -66,13 +66,15 @@ IoTDB> CLEAR CACHE ON LOCAL
 IoTDB> CLEAR CACHE ON CLUSTER
 ```
 
-## SET STSTEM TO READONLY / WRITABLE
 
-手动设置系统为只读或者可写入模式。
+## SET SYSTEM TO READONLY / RUNNING / ERROR
+
+手动设置系统为正常运行、只读、错误状态。在集群模式下,我们提供了设置本节点状态、设置整个集群状态的命令。

Review Comment:
   默认为对整个集群生效。



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