This is an automated email from the ASF dual-hosted git repository.
qiaojialin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 7eaf6b05dd [IOTDB-3737] Update cluster tools: make the result
sequential (#6588)
7eaf6b05dd is described below
commit 7eaf6b05ddce86e7fdfebd3472f51d3c1038633c
Author: 任宇华 <[email protected]>
AuthorDate: Wed Jul 6 09:52:24 2022 +0800
[IOTDB-3737] Update cluster tools: make the result sequential (#6588)
---
.../iotdb/confignode/manager/ConfigManager.java | 6 +++
.../iotdb/confignode/manager/NodeManager.java | 11 +++--
.../Maintenance-Tools/Maintenance-Command.md | 49 +++++++++++++++------
.../Maintenance-Tools/Maintenance-Command.md | 51 +++++++++++++++-------
4 files changed, 85 insertions(+), 32 deletions(-)
diff --git
a/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java
b/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java
index 177dd9765f..6b8588d924 100644
---
a/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java
+++
b/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java
@@ -95,6 +95,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -209,10 +210,14 @@ public class ConfigManager implements IManager {
TSStatus status = confirmLeader();
if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
List<TConfigNodeLocation> configNodeLocations =
getNodeManager().getRegisteredConfigNodes();
+ configNodeLocations.sort(
+ Comparator.comparingInt(configNodeLocation ->
configNodeLocation.getConfigNodeId()));
List<TDataNodeLocation> dataNodeInfoLocations =
getNodeManager().getRegisteredDataNodes(-1).stream()
.map(TDataNodeInfo::getLocation)
.collect(Collectors.toList());
+ dataNodeInfoLocations.sort(
+ Comparator.comparingInt(dataNodeInfoLocation ->
dataNodeInfoLocation.getDataNodeId()));
Map<Integer, String> nodeStatus = new HashMap<>();
getLoadManager()
.getHeartbeatCacheMap()
@@ -824,6 +829,7 @@ public class ConfigManager implements IManager {
}));
}
+ dataNodesInfoList.sort(Comparator.comparingInt(dataNodeInfo ->
dataNodeInfo.getDataNodeId()));
dataNodeInfosResp.setStatus(regionsInfoDataSet.getStatus());
dataNodeInfosResp.setDataNodesInfoList(dataNodesInfoList);
diff --git
a/confignode/src/main/java/org/apache/iotdb/confignode/manager/NodeManager.java
b/confignode/src/main/java/org/apache/iotdb/confignode/manager/NodeManager.java
index a76089b205..01cea856f1 100644
---
a/confignode/src/main/java/org/apache/iotdb/confignode/manager/NodeManager.java
+++
b/confignode/src/main/java/org/apache/iotdb/confignode/manager/NodeManager.java
@@ -24,7 +24,6 @@ import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation;
import org.apache.iotdb.common.rpc.thrift.TDataNodesInfo;
import org.apache.iotdb.common.rpc.thrift.TFlushReq;
import org.apache.iotdb.common.rpc.thrift.TSStatus;
-import org.apache.iotdb.commons.cluster.NodeStatus;
import org.apache.iotdb.commons.consensus.ConsensusGroupId;
import org.apache.iotdb.confignode.client.AsyncDataNodeClientPool;
import org.apache.iotdb.confignode.client.handlers.FlushHandler;
@@ -185,8 +184,14 @@ public class NodeManager {
registeredDataNodes.forEach(
(dataNodeInfo) -> {
TDataNodesInfo tDataNodesLocation = new TDataNodesInfo();
-
tDataNodesLocation.setDataNodeId(dataNodeInfo.getLocation().getDataNodeId());
- tDataNodesLocation.setStatus(NodeStatus.Running.getStatus());
+ int dataNodeId = dataNodeInfo.getLocation().getDataNodeId();
+ tDataNodesLocation.setDataNodeId(dataNodeId);
+ tDataNodesLocation.setStatus(
+ getLoadManager()
+ .getHeartbeatCacheMap()
+ .get(dataNodeId)
+ .getNodeStatus()
+ .getStatus());
tDataNodesLocation.setRpcAddresss(
dataNodeInfo.getLocation().getClientRpcEndPoint().getIp());
tDataNodesLocation.setRpcPort(
diff --git a/docs/UserGuide/Maintenance-Tools/Maintenance-Command.md
b/docs/UserGuide/Maintenance-Tools/Maintenance-Command.md
index c4ba3e8e6e..5698c7c8a0 100644
--- a/docs/UserGuide/Maintenance-Tools/Maintenance-Command.md
+++ b/docs/UserGuide/Maintenance-Tools/Maintenance-Command.md
@@ -180,11 +180,17 @@ IoTDB> show schema regions
Total line number = 2
It costs 0.012s
```
-## Monitoring tool for cluster DataNode distribution
+## Monitoring tool for cluster Node distribution
+
+### Show all DataNode information
Currently, IoTDB supports DataNode query using the following SQL:
-- `SHOW DATANODES`: Show all DataNode
+```
+SHOW DATANODES
+```
+
+Eg :
```sql
IoTDB> create timeseries root.sg.d1.s1 with datatype=BOOLEAN,encoding=PLAIN
@@ -236,9 +242,24 @@ Total line number = 2
It costs 0.006s
```
-## Cluster node status viewing tool
+After a DataNode is stopped, its status will change, as shown below:
+
+```
+IoTDB> show datanodes
++------+-------+---------+----+-------------+---------------+
+|NodeID| Status| Host|Port|DataRegionNum|SchemaRegionNum|
++------+-------+---------+----+-------------+---------------+
+| 3|Running|127.0.0.1|6667| 0| 0|
+| 4|Unknown|127.0.0.1|6669| 0| 0|
+| 5|Running|127.0.0.1|6671| 0| 0|
++------+-------+---------+----+-------------+---------------+
+Total line number = 3
+It costs 0.009s
+```
+
+### Show all Node information
-Show all node information:
+ Currently, iotdb supports the following SQL to view the information of all
nodes :
```
SHOW CLUSTER
@@ -251,12 +272,12 @@ IoTDB> show cluster
+------+----------+-------+---------+-----+
|NodeID| NodeType| Status| Host| Port|
+------+----------+-------+---------+-----+
-| 4|ConfigNode|Running| 0.0.0.0|22279|
| 0|ConfigNode|Running| 0.0.0.0|22277|
-| 5|ConfigNode|Running| 0.0.0.0|22281|
-| 1| DataNode|Running|127.0.0.1| 9005|
-| 2| DataNode|Running|127.0.0.1| 9003|
-| 3| DataNode|Running|127.0.0.1| 9007|
+| 1|ConfigNode|Running| 0.0.0.0|22279|
+| 2|ConfigNode|Running| 0.0.0.0|22281|
+| 3| DataNode|Running|127.0.0.1| 9003|
+| 4| DataNode|Running|127.0.0.1| 9005|
+| 5| DataNode|Running|127.0.0.1| 9007|
+------+----------+-------+---------+-----+
Total line number = 6
It costs 0.011s
@@ -269,12 +290,12 @@ IoTDB> show cluster
+------+----------+-------+---------+-----+
|NodeID| NodeType| Status| Host| Port|
+------+----------+-------+---------+-----+
-| 4|ConfigNode|Running| 0.0.0.0|22279|
| 0|ConfigNode|Running| 0.0.0.0|22277|
-| 5|ConfigNode|Unknown| 0.0.0.0|22281|
-| 1| DataNode|Running|127.0.0.1| 9005|
-| 2| DataNode|Running|127.0.0.1| 9003|
-| 3| DataNode|Running|127.0.0.1| 9007|
+| 1|ConfigNode|Unknown| 0.0.0.0|22279|
+| 2|ConfigNode|Running| 0.0.0.0|22281|
+| 3| DataNode|Running|127.0.0.1| 9003|
+| 4| DataNode|Running|127.0.0.1| 9005|
+| 5| DataNode|Running|127.0.0.1| 9007|
+------+----------+-------+---------+-----+
Total line number = 6
It costs 0.012s
diff --git a/docs/zh/UserGuide/Maintenance-Tools/Maintenance-Command.md
b/docs/zh/UserGuide/Maintenance-Tools/Maintenance-Command.md
index cea43734ab..e43a3a5909 100644
--- a/docs/zh/UserGuide/Maintenance-Tools/Maintenance-Command.md
+++ b/docs/zh/UserGuide/Maintenance-Tools/Maintenance-Command.md
@@ -175,11 +175,17 @@ IoTDB> show schema regions
Total line number = 2
It costs 0.012s
```
-## 集群 DataNode 分布式监控工具
+## 集群节点分布式监控工具
-当前 IoTDB 支持使用如下 SQL 查看 DataNode:
+### 查看DataNode节点信息
-- `SHOW DATANODES`: 展示所有DataNode
+当前 IoTDB 支持使用如下 SQL 查看 DataNode的信息:
+
+```
+SHOW DATANODES
+```
+
+示例:
```sql
IoTDB> create timeseries root.sg.d1.s1 with datatype=BOOLEAN,encoding=PLAIN
@@ -231,9 +237,24 @@ Total line number = 2
It costs 0.006s
```
-## 集群节点状态查看工具
+停止一个节点之后,节点的状态会发生改变,状态显示如下:
+
+```
+IoTDB> show datanodes
++------+-------+---------+----+-------------+---------------+
+|NodeID| Status| Host|Port|DataRegionNum|SchemaRegionNum|
++------+-------+---------+----+-------------+---------------+
+| 3|Running|127.0.0.1|6667| 0| 0|
+| 4|Unknown|127.0.0.1|6669| 0| 0|
+| 5|Running|127.0.0.1|6671| 0| 0|
++------+-------+---------+----+-------------+---------------+
+Total line number = 3
+It costs 0.009s
+```
+
+### 查看全部节点信息
-查看全部节点信息 :
+当前 IoTDB 支持使用如下 SQL 查看全部节点的信息:
```
SHOW CLUSTER
@@ -246,12 +267,12 @@ IoTDB> show cluster
+------+----------+-------+---------+-----+
|NodeID| NodeType| Status| Host| Port|
+------+----------+-------+---------+-----+
-| 4|ConfigNode|Running| 0.0.0.0|22279|
| 0|ConfigNode|Running| 0.0.0.0|22277|
-| 5|ConfigNode|Running| 0.0.0.0|22281|
-| 1| DataNode|Running|127.0.0.1| 9005|
-| 2| DataNode|Running|127.0.0.1| 9003|
-| 3| DataNode|Running|127.0.0.1| 9007|
+| 1|ConfigNode|Running| 0.0.0.0|22279|
+| 2|ConfigNode|Running| 0.0.0.0|22281|
+| 3| DataNode|Running|127.0.0.1| 9003|
+| 4| DataNode|Running|127.0.0.1| 9005|
+| 5| DataNode|Running|127.0.0.1| 9007|
+------+----------+-------+---------+-----+
Total line number = 6
It costs 0.011s
@@ -264,12 +285,12 @@ IoTDB> show cluster
+------+----------+-------+---------+-----+
|NodeID| NodeType| Status| Host| Port|
+------+----------+-------+---------+-----+
-| 4|ConfigNode|Running| 0.0.0.0|22279|
| 0|ConfigNode|Running| 0.0.0.0|22277|
-| 5|ConfigNode|Unknown| 0.0.0.0|22281|
-| 1| DataNode|Running|127.0.0.1| 9005|
-| 2| DataNode|Running|127.0.0.1| 9003|
-| 3| DataNode|Running|127.0.0.1| 9007|
+| 1|ConfigNode|Unknown| 0.0.0.0|22279|
+| 2|ConfigNode|Running| 0.0.0.0|22281|
+| 3| DataNode|Running|127.0.0.1| 9003|
+| 4| DataNode|Running|127.0.0.1| 9005|
+| 5| DataNode|Running|127.0.0.1| 9007|
+------+----------+-------+---------+-----+
Total line number = 6
It costs 0.012s