Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private void loadProps() {
MetricConfigDescriptor.getInstance().loadProps(commonProperties);
MetricConfigDescriptor.getInstance()
.getMetricConfig()
.updateRpcInstance(conf.getClusterName(), conf.getConfigNodeId(), NodeType.CONFIGNODE);
.updateRpcInstance(conf.getClusterName(), NodeType.CONFIGNODE);
}
} else {
LOGGER.warn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
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;
Expand Down Expand Up @@ -114,6 +115,9 @@ public void active() {
}

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: {}.",
Expand Down Expand Up @@ -144,8 +148,9 @@ public void active() {
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

Expand All @@ -168,6 +173,7 @@ public void active() {
ConfigNodeConstant.GLOBAL_NAME,
CONF.getConfigNodeId(),
CONF.getClusterName());
setUpMetricService();

boolean isJoinedCluster = false;
for (int retry = 0; retry < SCHEDULE_WAITING_RETRY_NUM; retry++) {
Expand All @@ -184,6 +190,7 @@ public void active() {
TimeUnit.MILLISECONDS.sleep(STARTUP_RETRY_INTERVAL_IN_MS);
} catch (InterruptedException e) {
LOGGER.warn("Waiting leader's scheduling is interrupted.");
Thread.currentThread().interrupt();
}
}

Expand All @@ -210,15 +217,18 @@ private void setUpInternalServices() throws StartupException, IOException {
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());
MetricService.getInstance().addMetricSet(new LogbackMetrics());
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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,15 @@ public int getNodeId() {
}

/** 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ private void loadProps() {
MetricConfigDescriptor.getInstance().loadProps(commonProperties);
MetricConfigDescriptor.getInstance()
.getMetricConfig()
.updateRpcInstance(conf.getClusterName(), conf.getDataNodeId(), NodeType.DATANODE);
.updateRpcInstance(conf.getClusterName(), NodeType.DATANODE);
}
} else {
logger.warn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,12 @@ protected void doAddNode() {
// Active DataNode
active();

// Setup rpc service
setUpRPCService();

// Setup metric service
setUpMetricService();

// Setup rpc service
setUpRPCService();

// Serialize mutable system properties
IoTDBStartCheck.getInstance().serializeMutableSystemPropertiesIfNecessary();

Expand Down Expand Up @@ -555,6 +555,7 @@ private void setUpRPCService() throws StartupException {
}

private void setUpMetricService() throws StartupException {
MetricConfigDescriptor.getInstance().getMetricConfig().setNodeId(config.getDataNodeId());
registerManager.register(MetricService.getInstance());

// init metric service
Expand Down