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/08/31 03:44:33 UTC
[iotdb] branch beyyes/remove_datanode_and_kill_process updated: add system.exit(0) for the stop method of datanode
This is an automated email from the ASF dual-hosted git repository.
caogaofei pushed a commit to branch beyyes/remove_datanode_and_kill_process
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/beyyes/remove_datanode_and_kill_process by this push:
new 9ff73421b1 add system.exit(0) for the stop method of datanode
9ff73421b1 is described below
commit 9ff73421b1b239158ec84204069be68b69b40005
Author: Beyyes <cg...@foxmail.com>
AuthorDate: Wed Aug 31 11:44:16 2022 +0800
add system.exit(0) for the stop method of datanode
---
.../java/org/apache/iotdb/db/service/DataNode.java | 18 ++++++++++++++++--
.../iotdb/db/service/DataNodeServerCommandLine.java | 2 +-
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/server/src/main/java/org/apache/iotdb/db/service/DataNode.java b/server/src/main/java/org/apache/iotdb/db/service/DataNode.java
index 2d794003b2..16e0287367 100644
--- a/server/src/main/java/org/apache/iotdb/db/service/DataNode.java
+++ b/server/src/main/java/org/apache/iotdb/db/service/DataNode.java
@@ -74,6 +74,7 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.TimeUnit;
public class DataNode implements DataNodeMBean {
private static final Logger logger = LoggerFactory.getLogger(DataNode.class);
@@ -119,7 +120,7 @@ public class DataNode implements DataNodeMBean {
thisNode.setPort(IoTDBDescriptor.getInstance().getConfig().getInternalPort());
}
- protected void doAddNode(String[] args) {
+ protected void doAddNode() {
try {
// prepare cluster IoTDB-DataNode
prepareDataNode();
@@ -388,7 +389,6 @@ public class DataNode implements DataNodeMBean {
public void stop() {
deactivate();
- // QSW
try {
MetricService.getInstance().stop();
SchemaRegionConsensusImpl.getInstance().stop();
@@ -396,6 +396,20 @@ public class DataNode implements DataNodeMBean {
} catch (Exception e) {
logger.error("stop data node error", e);
}
+
+ // kill the datanode process 5 seconds later
+ // if remove this step, datanode process will still alive
+ new Thread(
+ () -> {
+ try {
+ TimeUnit.SECONDS.sleep(5);
+ } catch (InterruptedException e) {
+ logger.error("Meets InterruptedException in stop method of DataNode");
+ } finally {
+ System.exit(0);
+ }
+ })
+ .start();
}
private void initServiceProvider() throws QueryProcessException {
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 038f0e2612..15d902041d 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
@@ -92,7 +92,7 @@ public class DataNodeServerCommandLine extends ServerCommandLine {
// we start IoTDB kernel first. then we start the cluster module.
if (MODE_START.equals(mode)) {
- dataNode.doAddNode(args);
+ dataNode.doAddNode();
} else if (MODE_REMOVE.equals(mode)) {
doRemoveNode(args);
} else {