You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ha...@apache.org on 2022/05/16 00:00:14 UTC
[iotdb] branch master updated: Report cpu core and total memory to config node (#5914)
This is an automated email from the ASF dual-hosted git repository.
haonan 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 b452368eb9 Report cpu core and total memory to config node (#5914)
b452368eb9 is described below
commit b452368eb9814ed7b1ba3f3287aacb2918b33252
Author: Mrquan <50...@users.noreply.github.com>
AuthorDate: Mon May 16 08:00:08 2022 +0800
Report cpu core and total memory to config node (#5914)
* Scripts of stop and remove datanode
* [DataNode] Add dataNodeInfo
* [DataNode] Add dataNodeInfo
---
.../service/thrift/ConfigNodeRPCServiceProcessorTest.java | 13 +++++++++++--
.../src/main/java/org/apache/iotdb/db/service/DataNode.java | 6 ++++++
thrift-commons/src/main/thrift/common.thrift | 5 +++++
thrift-confignode/src/main/thrift/confignode.thrift | 3 ++-
4 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/confignode/src/test/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessorTest.java b/confignode/src/test/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessorTest.java
index bc172462ab..3853edc0ca 100644
--- a/confignode/src/test/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessorTest.java
+++ b/confignode/src/test/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessorTest.java
@@ -19,6 +19,7 @@
package org.apache.iotdb.confignode.service.thrift;
import org.apache.iotdb.common.rpc.thrift.TConsensusGroupType;
+import org.apache.iotdb.common.rpc.thrift.TDataNodeInfo;
import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation;
import org.apache.iotdb.common.rpc.thrift.TEndPoint;
import org.apache.iotdb.common.rpc.thrift.TRegionReplicaSet;
@@ -137,7 +138,11 @@ public class ConfigNodeRPCServiceProcessorTest {
dataNodeLocation.setDataBlockManagerEndPoint(new TEndPoint("0.0.0.0", 8777 + i));
dataNodeLocation.setConsensusEndPoint(new TEndPoint("0.0.0.0", 40010 + i));
- TDataNodeRegisterReq req = new TDataNodeRegisterReq(dataNodeLocation);
+ TDataNodeInfo dataNodeInfo = new TDataNodeInfo();
+ dataNodeInfo.setCpuCoreNum(8);
+ dataNodeInfo.setMaxMemory(1024 * 1024);
+
+ TDataNodeRegisterReq req = new TDataNodeRegisterReq(dataNodeLocation, dataNodeInfo);
TDataNodeRegisterResp resp = processor.registerDataNode(req);
Assert.assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), resp.getStatus().getCode());
@@ -157,7 +162,11 @@ public class ConfigNodeRPCServiceProcessorTest {
dataNodeLocation.setDataBlockManagerEndPoint(new TEndPoint("0.0.0.0", 8778));
dataNodeLocation.setConsensusEndPoint(new TEndPoint("0.0.0.0", 40011));
- TDataNodeRegisterReq req = new TDataNodeRegisterReq(dataNodeLocation);
+ TDataNodeInfo dataNodeInfo = new TDataNodeInfo();
+ dataNodeInfo.setCpuCoreNum(8);
+ dataNodeInfo.setMaxMemory(1024 * 1024);
+
+ TDataNodeRegisterReq req = new TDataNodeRegisterReq(dataNodeLocation, dataNodeInfo);
TDataNodeRegisterResp resp = processor.registerDataNode(req);
Assert.assertEquals(
TSStatusCode.DATANODE_ALREADY_REGISTERED.getStatusCode(), resp.getStatus().getCode());
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 8875150162..bf77e28b2d 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
@@ -19,6 +19,7 @@
package org.apache.iotdb.db.service;
import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation;
+import org.apache.iotdb.common.rpc.thrift.TDataNodeInfo;
import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation;
import org.apache.iotdb.common.rpc.thrift.TEndPoint;
import org.apache.iotdb.commons.concurrent.IoTDBDefaultThreadExceptionHandler;
@@ -154,6 +155,11 @@ public class DataNode implements DataNodeMBean {
new TEndPoint(config.getInternalIp(), config.getConsensusPort()));
req.setDataNodeLocation(location);
+ TDataNodeInfo info = new TDataNodeInfo();
+ info.setCpuCoreNum(Runtime.getRuntime().availableProcessors());
+ info.setMaxMemory(Runtime.getRuntime().totalMemory());
+ req.setDataNodeInfo(info);
+
TDataNodeRegisterResp dataNodeRegisterResp = configNodeClient.registerDataNode(req);
// store config node lists from resp
diff --git a/thrift-commons/src/main/thrift/common.thrift b/thrift-commons/src/main/thrift/common.thrift
index 8ffdf3ff40..5d3b70e9d5 100644
--- a/thrift-commons/src/main/thrift/common.thrift
+++ b/thrift-commons/src/main/thrift/common.thrift
@@ -80,4 +80,9 @@ struct TDataNodeLocation {
struct THeartbeatResp {
1: required i64 heartbeatTimestamp
+}
+
+struct TDataNodeInfo {
+ 1: required i32 cpuCoreNum
+ 2: required i64 maxMemory
}
\ No newline at end of file
diff --git a/thrift-confignode/src/main/thrift/confignode.thrift b/thrift-confignode/src/main/thrift/confignode.thrift
index 7fa76108e8..29b4a04449 100644
--- a/thrift-confignode/src/main/thrift/confignode.thrift
+++ b/thrift-confignode/src/main/thrift/confignode.thrift
@@ -24,9 +24,10 @@ namespace py iotdb.thrift.confignode
// DataNode
struct TDataNodeRegisterReq {
1: required common.TDataNodeLocation dataNodeLocation
+ 2: required common.TDataNodeInfo dataNodeInfo
// Map<StorageGroupName, TStorageGroupSchema>
// DataNode can use statusMap to report its status to the ConfigNode when restart
- 2: optional map<string, TStorageGroupSchema> statusMap
+ 3: optional map<string, TStorageGroupSchema> statusMap
}
struct TGlobalConfig {