You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by zy...@apache.org on 2023/03/20 06:39:20 UTC
[iotdb] 03/13: [IOTDB-5682] Fix the update of nodeId in Metrics (#9344) (#9346)
This is an automated email from the ASF dual-hosted git repository.
zyk pushed a commit to branch rc/1.1.0
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit aadf1073e56d05ba00eb070da4a5e8eae8073c04
Author: ZhangHongYin <46...@users.noreply.github.com>
AuthorDate: Thu Mar 16 21:06:34 2023 +0800
[IOTDB-5682] Fix the update of nodeId in Metrics (#9344) (#9346)
(cherry picked from commit d14f37af8686dd7f8cdfb8cde60d422fe524688d)
---
.../iotdb/confignode/conf/ConfigNodeDescriptor.java | 2 +-
.../apache/iotdb/confignode/service/ConfigNode.java | 18 ++++++++++++++----
.../org/apache/iotdb/metrics/config/MetricConfig.java | 7 +++++--
.../java/org/apache/iotdb/db/conf/IoTDBDescriptor.java | 2 +-
.../java/org/apache/iotdb/db/service/DataNode.java | 7 ++++---
5 files changed, 25 insertions(+), 11 deletions(-)
diff --git a/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeDescriptor.java b/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeDescriptor.java
index 4aa8d54522..6e508da618 100644
--- a/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeDescriptor.java
+++ b/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeDescriptor.java
@@ -134,7 +134,7 @@ public class ConfigNodeDescriptor {
MetricConfigDescriptor.getInstance().loadProps(commonProperties);
MetricConfigDescriptor.getInstance()
.getMetricConfig()
- .updateRpcInstance(conf.getClusterName(), conf.getConfigNodeId(), NodeType.CONFIGNODE);
+ .updateRpcInstance(conf.getClusterName(), NodeType.CONFIGNODE);
}
} else {
LOGGER.warn(
diff --git a/confignode/src/main/java/org/apache/iotdb/confignode/service/ConfigNode.java b/confignode/src/main/java/org/apache/iotdb/confignode/service/ConfigNode.java
index e0d85b9b46..090d1f4bb0 100644
--- a/confignode/src/main/java/org/apache/iotdb/confignode/service/ConfigNode.java
+++ b/confignode/src/main/java/org/apache/iotdb/confignode/service/ConfigNode.java
@@ -42,6 +42,7 @@ import org.apache.iotdb.confignode.service.thrift.ConfigNodeRPCService;
import org.apache.iotdb.confignode.service.thrift.ConfigNodeRPCServiceProcessor;
import org.apache.iotdb.db.service.metrics.ProcessMetrics;
import org.apache.iotdb.db.service.metrics.SystemMetrics;
+import org.apache.iotdb.metrics.config.MetricConfigDescriptor;
import org.apache.iotdb.metrics.metricsets.disk.DiskMetrics;
import org.apache.iotdb.metrics.metricsets.jvm.JvmMetrics;
import org.apache.iotdb.metrics.metricsets.logback.LogbackMetrics;
@@ -114,6 +115,9 @@ public class ConfigNode implements ConfigNodeMBean {
}
configManager.initConsensusManager();
+ setUpMetricService();
+ // Notice: We always set up Seed-ConfigNode's RPC service lastly to ensure
+ // that the external service is not provided until ConfigNode is fully available
setUpRPCService();
LOGGER.info(
"{} has successfully restarted and joined the cluster: {}.",
@@ -144,8 +148,9 @@ public class ConfigNode implements ConfigNodeMBean {
SEED_CONFIG_NODE_ID,
new TEndPoint(CONF.getInternalAddress(), CONF.getInternalPort()),
new TEndPoint(CONF.getInternalAddress(), CONF.getConsensusPort())));
- // We always set up Seed-ConfigNode's RPC service lastly to ensure that
- // the external service is not provided until Seed-ConfigNode is fully initialized
+ setUpMetricService();
+ // Notice: We always set up Seed-ConfigNode's RPC service lastly to ensure
+ // that the external service is not provided until Seed-ConfigNode is fully initialized
setUpRPCService();
// The initial startup of Seed-ConfigNode finished
@@ -168,6 +173,7 @@ public class ConfigNode implements ConfigNodeMBean {
ConfigNodeConstant.GLOBAL_NAME,
CONF.getConfigNodeId(),
CONF.getClusterName());
+ setUpMetricService();
boolean isJoinedCluster = false;
for (int retry = 0; retry < SCHEDULE_WAITING_RETRY_NUM; retry++) {
@@ -184,6 +190,7 @@ public class ConfigNode implements ConfigNodeMBean {
TimeUnit.MILLISECONDS.sleep(STARTUP_RETRY_INTERVAL_IN_MS);
} catch (InterruptedException e) {
LOGGER.warn("Waiting leader's scheduling is interrupted.");
+ Thread.currentThread().interrupt();
}
}
@@ -210,6 +217,11 @@ public class ConfigNode implements ConfigNodeMBean {
registerManager.register(new JMXService());
JMXService.registerMBean(this, mbeanName);
+ LOGGER.info("Successfully setup internal services.");
+ }
+
+ private void setUpMetricService() throws StartupException {
+ MetricConfigDescriptor.getInstance().getMetricConfig().setNodeId(CONF.getConfigNodeId());
registerManager.register(MetricService.getInstance());
// bind predefined metric sets
MetricService.getInstance().addMetricSet(new JvmMetrics());
@@ -217,8 +229,6 @@ public class ConfigNode implements ConfigNodeMBean {
MetricService.getInstance().addMetricSet(new ProcessMetrics());
MetricService.getInstance().addMetricSet(new SystemMetrics(false));
MetricService.getInstance().addMetricSet(new DiskMetrics(IoTDBConstant.CN_ROLE));
-
- LOGGER.info("Successfully setup internal services.");
}
private void initConfigManager() {
diff --git a/metrics/interface/src/main/java/org/apache/iotdb/metrics/config/MetricConfig.java b/metrics/interface/src/main/java/org/apache/iotdb/metrics/config/MetricConfig.java
index 9d9b061847..2d551495d2 100644
--- a/metrics/interface/src/main/java/org/apache/iotdb/metrics/config/MetricConfig.java
+++ b/metrics/interface/src/main/java/org/apache/iotdb/metrics/config/MetricConfig.java
@@ -156,12 +156,15 @@ public class MetricConfig {
}
/** Update rpc address and rpc port of monitored node. */
- public void updateRpcInstance(String clusterName, int nodeId, NodeType nodeType) {
+ public void updateRpcInstance(String clusterName, NodeType nodeType) {
this.clusterName = clusterName;
- this.nodeId = nodeId;
this.nodeType = nodeType;
}
+ public void setNodeId(int nodeId) {
+ this.nodeId = nodeId;
+ }
+
/** Copy properties from another metric config. */
public void copy(MetricConfig newMetricConfig) {
metricFrameType = newMetricConfig.getMetricFrameType();
diff --git a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
index c708d6e402..29a9caf080 100644
--- a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
+++ b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
@@ -189,7 +189,7 @@ public class IoTDBDescriptor {
MetricConfigDescriptor.getInstance().loadProps(commonProperties);
MetricConfigDescriptor.getInstance()
.getMetricConfig()
- .updateRpcInstance(conf.getClusterName(), conf.getDataNodeId(), NodeType.DATANODE);
+ .updateRpcInstance(conf.getClusterName(), NodeType.DATANODE);
}
} else {
logger.warn(
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 31e89349fe..45959def26 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
@@ -168,12 +168,12 @@ public class DataNode implements DataNodeMBean {
// Active DataNode
active();
- // Setup rpc service
- setUpRPCService();
-
// Setup metric service
setUpMetricService();
+ // Setup rpc service
+ setUpRPCService();
+
// Serialize mutable system properties
IoTDBStartCheck.getInstance().serializeMutableSystemPropertiesIfNecessary();
@@ -555,6 +555,7 @@ public class DataNode implements DataNodeMBean {
}
private void setUpMetricService() throws StartupException {
+ MetricConfigDescriptor.getInstance().getMetricConfig().setNodeId(config.getDataNodeId());
registerManager.register(MetricService.getInstance());
// init metric service