You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ca...@apache.org on 2022/10/13 04:14:30 UTC

[iotdb] branch beyyes/remove_datanode_improvement created (now 1ace3ab2f6)

This is an automated email from the ASF dual-hosted git repository.

caogaofei pushed a change to branch beyyes/remove_datanode_improvement
in repository https://gitbox.apache.org/repos/asf/iotdb.git


      at 1ace3ab2f6 add more logs for remove confignode

This branch includes the following new commits:

     new 1ace3ab2f6 add more logs for remove confignode

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[iotdb] 01/01: add more logs for remove confignode

Posted by ca...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

caogaofei pushed a commit to branch beyyes/remove_datanode_improvement
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 1ace3ab2f661b584370a558a8c58ad2af4a05a3c
Author: Beyyes <cg...@foxmail.com>
AuthorDate: Thu Oct 13 12:14:15 2022 +0800

    add more logs for remove confignode
---
 .../iotdb/confignode/conf/ConfigNodeConstant.java  |  2 ++
 .../confignode/service/ConfigNodeCommandLine.java  | 20 ++++++++------
 .../db/service/DataNodeServerCommandLine.java      | 31 +++++++++++-----------
 3 files changed, 30 insertions(+), 23 deletions(-)

diff --git a/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeConstant.java b/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeConstant.java
index 70c2a1c620..3a9a9013f5 100644
--- a/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeConstant.java
+++ b/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeConstant.java
@@ -45,6 +45,8 @@ public class ConfigNodeConstant {
   public static final String METRIC_STATUS_ONLINE = "Online";
   public static final String METRIC_STATUS_UNKNOWN = "Unknown";
 
+  public static final String REMOVE_CONFIGNODE_USAGE = "Executed failed, check usage: <Node-id>/<internal_address>:<internal_port>";
+
   public static final String REMOVE_DATANODE_PROCESS = "[REMOVE_DATANODE_PROCESS]";
 
   private ConfigNodeConstant() {
diff --git a/confignode/src/main/java/org/apache/iotdb/confignode/service/ConfigNodeCommandLine.java b/confignode/src/main/java/org/apache/iotdb/confignode/service/ConfigNodeCommandLine.java
index bb0e4ff669..06ea1f87a3 100644
--- a/confignode/src/main/java/org/apache/iotdb/confignode/service/ConfigNodeCommandLine.java
+++ b/confignode/src/main/java/org/apache/iotdb/confignode/service/ConfigNodeCommandLine.java
@@ -24,7 +24,6 @@ import org.apache.iotdb.commons.exception.BadNodeUrlException;
 import org.apache.iotdb.commons.exception.ConfigurationException;
 import org.apache.iotdb.commons.exception.StartupException;
 import org.apache.iotdb.commons.service.StartupChecks;
-import org.apache.iotdb.confignode.conf.ConfigNodeConstant;
 import org.apache.iotdb.confignode.conf.ConfigNodeRemoveCheck;
 import org.apache.iotdb.confignode.conf.ConfigNodeStartupCheck;
 
@@ -33,6 +32,8 @@ import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 
+import static org.apache.iotdb.confignode.conf.ConfigNodeConstant.REMOVE_CONFIGNODE_USAGE;
+
 public class ConfigNodeCommandLine extends ServerCommandLine {
   private static final Logger LOGGER = LoggerFactory.getLogger(ConfigNodeCommandLine.class);
 
@@ -78,11 +79,11 @@ public class ConfigNodeCommandLine extends ServerCommandLine {
       }
       ConfigNode.getInstance().active();
     } else if (MODE_REMOVE.equals(mode)) {
-      // remove node
+      // remove ConfigNode
       try {
-        doRemoveNode(args);
+        doRemoveConfigNode(args);
       } catch (IOException e) {
-        LOGGER.error("Meet error when doing remove", e);
+        LOGGER.error("Meet error when doing remove ConfigNode", e);
         return -1;
       }
     } else {
@@ -93,13 +94,15 @@ public class ConfigNodeCommandLine extends ServerCommandLine {
     return 0;
   }
 
-  private void doRemoveNode(String[] args) throws IOException {
-    LOGGER.info("Starting to remove {}...", ConfigNodeConstant.GLOBAL_NAME);
+  private void doRemoveConfigNode(String[] args) throws IOException {
+
     if (args.length != 2) {
-      LOGGER.info("Usage: <Node-id>/<internal_address>:<internal_port>");
+      LOGGER.info(REMOVE_CONFIGNODE_USAGE);
       return;
     }
 
+    LOGGER.info("Starting to remove ConfigNode, parameter: {}, {}", args[0], args[1]);
+
     try {
       TConfigNodeLocation removeConfigNodeLocation =
           ConfigNodeRemoveCheck.getInstance().removeCheck(args[1]);
@@ -113,6 +116,7 @@ public class ConfigNodeCommandLine extends ServerCommandLine {
     } catch (BadNodeUrlException e) {
       LOGGER.warn("No ConfigNodes need to be removed.", e);
     }
-    LOGGER.info("{} is removed.", ConfigNodeConstant.GLOBAL_NAME);
+
+    LOGGER.info("ConfigNode: {} is removed.", args[1]);
   }
 }
diff --git a/server/src/main/java/org/apache/iotdb/db/service/DataNodeServerCommandLine.java b/server/src/main/java/org/apache/iotdb/db/service/DataNodeServerCommandLine.java
index d3de543558..39b4e875d0 100644
--- a/server/src/main/java/org/apache/iotdb/db/service/DataNodeServerCommandLine.java
+++ b/server/src/main/java/org/apache/iotdb/db/service/DataNodeServerCommandLine.java
@@ -45,7 +45,7 @@ import static org.apache.commons.lang3.StringUtils.isNumeric;
 
 public class DataNodeServerCommandLine extends ServerCommandLine {
 
-  private static final Logger logger = LoggerFactory.getLogger(DataNodeServerCommandLine.class);
+  private static final Logger LOGGER = LoggerFactory.getLogger(DataNodeServerCommandLine.class);
 
   // join an established cluster
   private static final String MODE_START = "-s";
@@ -76,15 +76,15 @@ public class DataNodeServerCommandLine extends ServerCommandLine {
     try {
       dataNode.serverCheckAndInit();
     } catch (ConfigurationException | IOException e) {
-      logger.error("Meet error when doing start checking", e);
+      LOGGER.error("Meet error when doing start checking", e);
       return -1;
     }
     String mode = args[0];
-    logger.info("Running mode {}", mode);
+    LOGGER.info("Running mode {}", mode);
 
     // initialize the current node and its services
     if (!dataNode.initLocalEngines()) {
-      logger.error("Init local engines error, stop process!");
+      LOGGER.error("Init local engines error, stop process!");
       return -1;
     }
 
@@ -94,7 +94,7 @@ public class DataNodeServerCommandLine extends ServerCommandLine {
     } else if (MODE_REMOVE.equals(mode)) {
       doRemoveNode(args);
     } else {
-      logger.error("Unrecognized mode {}", mode);
+      LOGGER.error("Unrecognized mode {}", mode);
     }
     return 0;
   }
@@ -106,27 +106,28 @@ public class DataNodeServerCommandLine extends ServerCommandLine {
    */
   private void doRemoveNode(String[] args) throws BadNodeUrlException, TException, IoTDBException {
 
-    logger.info("Start to remove DataNode from cluster");
     if (args.length != 2) {
-      logger.info("Usage: <node-id>/<ip>:<rpc-port>");
+      LOGGER.info("Usage: <node-id>/<ip>:<rpc-port>");
       return;
     }
 
+    LOGGER.info("Starting to remove DataNode from cluster, parameter: {}, {}", args[0], args[1]);
+
     ConfigNodeInfo.getInstance().loadConfigNodeList();
     List<TDataNodeLocation> dataNodeLocations = buildDataNodeLocations(args[1]);
     if (dataNodeLocations.isEmpty()) {
       throw new BadNodeUrlException("No DataNode to remove");
     }
-    logger.info("Start to remove datanode, removed datanode: {}", dataNodeLocations);
+    LOGGER.info("Start to remove datanode, removed datanode endpoints: {}", dataNodeLocations);
     TDataNodeRemoveReq removeReq = new TDataNodeRemoveReq(dataNodeLocations);
     try (ConfigNodeClient configNodeClient = new ConfigNodeClient()) {
       TDataNodeRemoveResp removeResp = configNodeClient.removeDataNode(removeReq);
-      logger.info("Remove result {} ", removeResp.toString());
+      LOGGER.info("Remove result {} ", removeResp.toString());
       if (removeResp.getStatus().getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
         throw new IoTDBException(
             removeResp.getStatus().toString(), removeResp.getStatus().getCode());
       }
-      logger.info(
+      LOGGER.info(
           "Submit remove-datanode request successfully, "
               + "more details are shown in the logs of confignode-leader and removed-datanode, "
               + "and after the process of removing datanode is over, "
@@ -148,7 +149,7 @@ public class DataNodeServerCommandLine extends ServerCommandLine {
 
     // Now support only single datanode deletion
     if (args.split(",").length > 1) {
-      logger.info("Incorrect input format, usage: <id>/<ip>:<rpc-port>");
+      LOGGER.info("Incorrect input format, usage: <id>/<ip>:<rpc-port>");
       return dataNodeLocations;
     }
 
@@ -162,13 +163,13 @@ public class DataNodeServerCommandLine extends ServerCommandLine {
                 .filter(location -> endPoints.contains(location.getClientRpcEndPoint()))
                 .collect(Collectors.toList());
       } catch (TException e) {
-        logger.error("Get data node locations failed", e);
+        LOGGER.error("Get data node locations failed", e);
       }
     } catch (BadNodeUrlException e) {
       try (ConfigNodeClient client = new ConfigNodeClient()) {
         for (String id : args.split(",")) {
           if (!isNumeric(id)) {
-            logger.warn("Incorrect id format {}, skipped...", id);
+            LOGGER.warn("Incorrect id format {}, skipped...", id);
             continue;
           }
           List<TDataNodeLocation> nodeLocationResult =
@@ -177,7 +178,7 @@ public class DataNodeServerCommandLine extends ServerCommandLine {
                   .map(TDataNodeConfiguration::getLocation)
                   .collect(Collectors.toList());
           if (nodeLocationResult.isEmpty()) {
-            logger.warn("DataNode {} is not in cluster, skipped...", id);
+            LOGGER.warn("DataNode {} is not in cluster, skipped...", id);
             continue;
           }
           if (!dataNodeLocations.contains(nodeLocationResult.get(0))) {
@@ -185,7 +186,7 @@ public class DataNodeServerCommandLine extends ServerCommandLine {
           }
         }
       } catch (TException e1) {
-        logger.error("Get data node locations failed", e);
+        LOGGER.error("Get data node locations failed", e);
       }
     }
     return dataNodeLocations;