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 99279e0352 [IOTDB-3491] Assign an unique id to each ConfigNode (#6287)
99279e0352 is described below

commit 99279e0352f88e6189fb2771d395e4c034309749
Author: YongzaoDan <[email protected]>
AuthorDate: Thu Jun 16 14:40:17 2022 +0800

    [IOTDB-3491] Assign an unique id to each ConfigNode (#6287)
---
 .../confignode/conf/ConfigNodeStartupCheck.java    |  2 +
 .../iotdb/confignode/manager/ConsensusManager.java |  4 +-
 .../iotdb/confignode/manager/NodeManager.java      |  4 +-
 .../iotdb/confignode/persistence/NodeInfo.java     | 44 ++++++++++++++--------
 .../persistence/partition/PartitionInfo.java       | 11 ++++--
 .../consensus/request/ConfigRequestSerDeTest.java  |  2 +-
 .../iotdb/confignode/persistence/NodeInfoTest.java |  4 +-
 .../thrift/ConfigNodeRPCServiceProcessorTest.java  | 21 ++++++-----
 .../apache/iotdb/commons/utils/NodeUrlUtils.java   |  6 ++-
 .../iotdb/commons/utils/NodeUrlUtilsTest.java      |  8 ++--
 .../utils/ThriftConfigNodeSerDeUtilsTest.java      |  3 +-
 .../mpp/plan/execution/config/ShowClusterTask.java |  5 +--
 thrift-commons/src/main/thrift/common.thrift       | 13 ++++---
 13 files changed, 76 insertions(+), 51 deletions(-)

diff --git 
a/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeStartupCheck.java
 
b/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeStartupCheck.java
index 2c0c1c8f0a..8a2defa70d 100644
--- 
a/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeStartupCheck.java
+++ 
b/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeStartupCheck.java
@@ -171,6 +171,7 @@ public class ConfigNodeStartupCheck {
       conf.setConfigNodeList(
           Collections.singletonList(
               new TConfigNodeLocation(
+                  0,
                   new TEndPoint(conf.getRpcAddress(), conf.getRpcPort()),
                   new TEndPoint(conf.getRpcAddress(), 
conf.getConsensusPort()))));
     }
@@ -182,6 +183,7 @@ public class ConfigNodeStartupCheck {
     TConfigNodeRegisterReq req =
         new TConfigNodeRegisterReq(
             new TConfigNodeLocation(
+                -1,
                 new TEndPoint(conf.getRpcAddress(), conf.getRpcPort()),
                 new TEndPoint(conf.getRpcAddress(), conf.getConsensusPort())),
             conf.getDataRegionConsensusProtocolClass(),
diff --git 
a/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConsensusManager.java
 
b/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConsensusManager.java
index d46e6e66b3..0a666e428b 100644
--- 
a/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConsensusManager.java
+++ 
b/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConsensusManager.java
@@ -44,6 +44,7 @@ import org.slf4j.LoggerFactory;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.concurrent.TimeUnit;
 
 /** ConsensusManager maintains consensus class, request will redirect to 
consensus layer */
 public class ConsensusManager {
@@ -68,7 +69,7 @@ public class ConsensusManager {
       long maxWaitTime = 1000 * 60; // milliseconds, which is 60s
       try {
         while (!consensusImpl.isLeader(consensusGroupId)) {
-          Thread.sleep(100);
+          TimeUnit.MILLISECONDS.sleep(100);
           long elapsed = System.currentTimeMillis() - startTime;
           if (elapsed > maxWaitTime) {
             return;
@@ -116,6 +117,7 @@ public class ConsensusManager {
               .applyConfigNode(
                   conf.getTargetConfigNode(),
                   new TConfigNodeLocation(
+                      -1,
                       new TEndPoint(conf.getRpcAddress(), conf.getRpcPort()),
                       new TEndPoint(conf.getRpcAddress(), 
conf.getConsensusPort())));
       if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
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 e4cfb0c44e..01894c9308 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
@@ -95,7 +95,7 @@ public class NodeManager {
       dataSet.setStatus(status);
     } else {
       // Persist DataNodeInfo
-      
req.getInfo().getLocation().setDataNodeId(nodeInfo.generateNextDataNodeId());
+      req.getInfo().getLocation().setDataNodeId(nodeInfo.generateNextNodeId());
       ConsensusWriteResponse resp = getConsensusManager().write(req);
       dataSet.setStatus(resp.getStatus());
     }
@@ -170,6 +170,8 @@ public class NodeManager {
 
   public TSStatus applyConfigNode(ApplyConfigNodeReq applyConfigNodeReq) {
     if (getConsensusManager().addConfigNodePeer(applyConfigNodeReq)) {
+      // Generate new ConfigNode's index
+      
applyConfigNodeReq.getConfigNodeLocation().setConfigNodeId(nodeInfo.generateNextNodeId());
       return getConsensusManager().write(applyConfigNodeReq).getStatus();
     } else {
       return new TSStatus(TSStatusCode.APPLY_CONFIGNODE_FAILED.getStatusCode())
diff --git 
a/confignode/src/main/java/org/apache/iotdb/confignode/persistence/NodeInfo.java
 
b/confignode/src/main/java/org/apache/iotdb/confignode/persistence/NodeInfo.java
index fd335f978f..fd3a0db28d 100644
--- 
a/confignode/src/main/java/org/apache/iotdb/confignode/persistence/NodeInfo.java
+++ 
b/confignode/src/main/java/org/apache/iotdb/confignode/persistence/NodeInfo.java
@@ -87,7 +87,7 @@ public class NodeInfo implements SnapshotProcessor {
 
   // Online DataNodes
   private final ReentrantReadWriteLock dataNodeInfoReadWriteLock;
-  private AtomicInteger nextDataNodeId = new AtomicInteger(0);
+  private final AtomicInteger nextNodeId = new AtomicInteger(1);
   private final ConcurrentNavigableMap<Integer, TDataNodeInfo> onlineDataNodes 
=
       new ConcurrentSkipListMap<>();
 
@@ -137,18 +137,22 @@ public class NodeInfo implements SnapshotProcessor {
     try {
       onlineDataNodes.put(info.getLocation().getDataNodeId(), info);
 
-      if (nextDataNodeId.get() < info.getLocation().getDataNodeId()) {
-        // In this case, at least one Datanode is registered with the leader 
node,
-        // so the nextDataNodeID of the followers needs to be added
-        nextDataNodeId.getAndIncrement();
+      // To ensure that the nextNodeId is updated correctly when
+      // the ConfigNode-followers concurrently processes RegisterDataNodeReq,
+      // we need to add a synchronization lock here
+      synchronized (nextNodeId) {
+        if (nextNodeId.get() < info.getLocation().getDataNodeId()) {
+          nextNodeId.set(info.getLocation().getDataNodeId());
+        }
       }
+
       result = new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode());
-      if (nextDataNodeId.get() < minimumDataNode) {
+      if (nextNodeId.get() < minimumDataNode) {
         result.setMessage(
             String.format(
                 "To enable IoTDB-Cluster's data service, please register %d 
more IoTDB-DataNode",
-                minimumDataNode - nextDataNodeId.get()));
-      } else if (nextDataNodeId.get() == minimumDataNode) {
+                minimumDataNode - nextNodeId.get()));
+      } else if (nextNodeId.get() == minimumDataNode) {
         result.setMessage("IoTDB-Cluster could provide data service, now enjoy 
yourself!");
       }
     } finally {
@@ -243,6 +247,15 @@ public class NodeInfo implements SnapshotProcessor {
     TSStatus status = new TSStatus();
     configNodeInfoReadWriteLock.writeLock().lock();
     try {
+      // To ensure that the nextNodeId is updated correctly when
+      // the ConfigNode-followers concurrently processes ApplyConfigNodeReq,
+      // we need to add a synchronization lock here
+      synchronized (nextNodeId) {
+        if (nextNodeId.get() < 
applyConfigNodeReq.getConfigNodeLocation().getConfigNodeId()) {
+          
nextNodeId.set(applyConfigNodeReq.getConfigNodeLocation().getConfigNodeId());
+        }
+      }
+
       onlineConfigNodes.add(applyConfigNodeReq.getConfigNodeLocation());
       storeConfigNode();
       LOGGER.info(
@@ -285,8 +298,8 @@ public class NodeInfo implements SnapshotProcessor {
     return result;
   }
 
-  public int generateNextDataNodeId() {
-    return nextDataNodeId.getAndIncrement();
+  public int generateNextNodeId() {
+    return nextNodeId.getAndIncrement();
   }
 
   @Override
@@ -307,7 +320,7 @@ public class NodeInfo implements SnapshotProcessor {
 
       TProtocol protocol = new TBinaryProtocol(tioStreamTransport);
 
-      ReadWriteIOUtils.write(nextDataNodeId.get(), fileOutputStream);
+      ReadWriteIOUtils.write(nextNodeId.get(), fileOutputStream);
 
       serializeOnlineDataNode(fileOutputStream, protocol);
 
@@ -370,7 +383,7 @@ public class NodeInfo implements SnapshotProcessor {
 
       clear();
 
-      nextDataNodeId.set(ReadWriteIOUtils.readInt(fileInputStream));
+      nextNodeId.set(ReadWriteIOUtils.readInt(fileInputStream));
 
       deserializeOnlineDataNode(fileInputStream, protocol);
 
@@ -411,8 +424,9 @@ public class NodeInfo implements SnapshotProcessor {
     drainingDataNodes.addAll(tDataNodeLocations);
   }
 
-  public int getNextDataNodeId() {
-    return nextDataNodeId.get();
+  @TestOnly
+  public int getNextNodeId() {
+    return nextNodeId.get();
   }
 
   @TestOnly
@@ -421,7 +435,7 @@ public class NodeInfo implements SnapshotProcessor {
   }
 
   public void clear() {
-    nextDataNodeId = new AtomicInteger(0);
+    nextNodeId.set(0);
     onlineDataNodes.clear();
     drainingDataNodes.clear();
     onlineConfigNodes.clear();
diff --git 
a/confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/PartitionInfo.java
 
b/confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/PartitionInfo.java
index 742356df4d..bb22cf459e 100644
--- 
a/confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/PartitionInfo.java
+++ 
b/confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/PartitionInfo.java
@@ -140,10 +140,13 @@ public class PartitionInfo implements SnapshotProcessor {
                           Math.max(maxRegionId.get(), 
regionReplicaSet.getRegionId().getId())));
             });
 
-    if (nextRegionGroupId.get() < maxRegionId.get()) {
-      // In this case, at least one Region is created by the leader ConfigNode,
-      // so the nextRegionGroupID of the followers needs to be added
-      nextRegionGroupId.getAndAdd(req.getRegionMap().size());
+    // To ensure that the nextRegionGroupId is updated correctly when
+    // the ConfigNode-followers concurrently processes CreateRegionsReq,
+    // we need to add a synchronization lock here
+    synchronized (nextRegionGroupId) {
+      if (nextRegionGroupId.get() < maxRegionId.get()) {
+        nextRegionGroupId.set(maxRegionId.get());
+      }
     }
 
     result = new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode());
diff --git 
a/confignode/src/test/java/org/apache/iotdb/confignode/consensus/request/ConfigRequestSerDeTest.java
 
b/confignode/src/test/java/org/apache/iotdb/confignode/consensus/request/ConfigRequestSerDeTest.java
index 5d327923a6..ad42e3d4ef 100644
--- 
a/confignode/src/test/java/org/apache/iotdb/confignode/consensus/request/ConfigRequestSerDeTest.java
+++ 
b/confignode/src/test/java/org/apache/iotdb/confignode/consensus/request/ConfigRequestSerDeTest.java
@@ -475,7 +475,7 @@ public class ConfigRequestSerDeTest {
     ApplyConfigNodeReq req0 =
         new ApplyConfigNodeReq(
             new TConfigNodeLocation(
-                new TEndPoint("0.0.0.0", 22277), new TEndPoint("0.0.0.0", 
22278)));
+                0, new TEndPoint("0.0.0.0", 22277), new TEndPoint("0.0.0.0", 
22278)));
     ApplyConfigNodeReq req1 =
         (ApplyConfigNodeReq) 
ConfigRequest.Factory.create(req0.serializeToByteBuffer());
     Assert.assertEquals(req0, req1);
diff --git 
a/confignode/src/test/java/org/apache/iotdb/confignode/persistence/NodeInfoTest.java
 
b/confignode/src/test/java/org/apache/iotdb/confignode/persistence/NodeInfoTest.java
index d03cc6d5e7..93c59cdda8 100644
--- 
a/confignode/src/test/java/org/apache/iotdb/confignode/persistence/NodeInfoTest.java
+++ 
b/confignode/src/test/java/org/apache/iotdb/confignode/persistence/NodeInfoTest.java
@@ -77,14 +77,14 @@ public class NodeInfoTest {
     }
     nodeInfo.setDrainingDataNodes(drainingDataNodes_before);
 
-    int nextId = nodeInfo.getNextDataNodeId();
+    int nextId = nodeInfo.getNextNodeId();
     List<TDataNodeInfo> onlineDataNodes_before = 
nodeInfo.getOnlineDataNodes(-1);
 
     nodeInfo.processTakeSnapshot(snapshotDir);
     nodeInfo.clear();
     nodeInfo.processLoadSnapshot(snapshotDir);
 
-    Assert.assertEquals(nextId, nodeInfo.getNextDataNodeId());
+    Assert.assertEquals(nextId, nodeInfo.getNextNodeId());
 
     Set<TDataNodeLocation> drainingDataNodes_after = 
nodeInfo.getDrainingDataNodes();
     Assert.assertEquals(drainingDataNodes_before, drainingDataNodes_after);
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 1b9cbb8357..106b9f964b 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
@@ -161,7 +161,7 @@ public class ConfigNodeRPCServiceProcessorTest {
       TDataNodeRegisterResp resp = processor.registerDataNode(req);
 
       Assert.assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), 
resp.getStatus().getCode());
-      Assert.assertEquals(i, resp.getDataNodeId());
+      Assert.assertEquals(i + 1, resp.getDataNodeId());
       checkGlobalConfig(resp.getGlobalConfig());
     }
   }
@@ -187,7 +187,7 @@ public class ConfigNodeRPCServiceProcessorTest {
     TDataNodeRegisterResp resp = processor.registerDataNode(req);
     Assert.assertEquals(
         TSStatusCode.DATANODE_ALREADY_REGISTERED.getStatusCode(), 
resp.getStatus().getCode());
-    Assert.assertEquals(1, resp.getDataNodeId());
+    Assert.assertEquals(2, resp.getDataNodeId());
     checkGlobalConfig(resp.getGlobalConfig());
 
     // test query DataNodeInfo
@@ -199,7 +199,7 @@ public class ConfigNodeRPCServiceProcessorTest {
     List<Map.Entry<Integer, TDataNodeInfo>> infoList = new 
ArrayList<>(infoMap.entrySet());
     infoList.sort(Comparator.comparingInt(Map.Entry::getKey));
     for (int i = 0; i < 3; i++) {
-      dataNodeLocation.setDataNodeId(i);
+      dataNodeLocation.setDataNodeId(i + 1);
       dataNodeLocation.setExternalEndPoint(new TEndPoint("0.0.0.0", 6667 + i));
       dataNodeLocation.setInternalEndPoint(new TEndPoint("0.0.0.0", 9003 + i));
       dataNodeLocation.setDataBlockManagerEndPoint(new TEndPoint("0.0.0.0", 
8777 + i));
@@ -215,11 +215,11 @@ public class ConfigNodeRPCServiceProcessorTest {
     Assert.assertEquals(1, infoMap.size());
     Assert.assertNotNull(infoMap.get(1));
     dataNodeLocation.setDataNodeId(1);
-    dataNodeLocation.setExternalEndPoint(new TEndPoint("0.0.0.0", 6668));
-    dataNodeLocation.setInternalEndPoint(new TEndPoint("0.0.0.0", 9004));
-    dataNodeLocation.setDataBlockManagerEndPoint(new TEndPoint("0.0.0.0", 
8778));
-    dataNodeLocation.setDataRegionConsensusEndPoint(new TEndPoint("0.0.0.0", 
40011));
-    dataNodeLocation.setSchemaRegionConsensusEndPoint(new TEndPoint("0.0.0.0", 
50011));
+    dataNodeLocation.setExternalEndPoint(new TEndPoint("0.0.0.0", 6667));
+    dataNodeLocation.setInternalEndPoint(new TEndPoint("0.0.0.0", 9003));
+    dataNodeLocation.setDataBlockManagerEndPoint(new TEndPoint("0.0.0.0", 
8777));
+    dataNodeLocation.setDataRegionConsensusEndPoint(new TEndPoint("0.0.0.0", 
40010));
+    dataNodeLocation.setSchemaRegionConsensusEndPoint(new TEndPoint("0.0.0.0", 
50010));
     Assert.assertEquals(dataNodeLocation, infoMap.get(1).getLocation());
   }
 
@@ -232,14 +232,15 @@ public class ConfigNodeRPCServiceProcessorTest {
     List<TConfigNodeLocation> configNodeInfos = 
clusterNodes.getConfigNodeList();
     Assert.assertEquals(1, configNodeInfos.size());
     TConfigNodeLocation configNodeLocation =
-        new TConfigNodeLocation(new TEndPoint("0.0.0.0", 22277), new 
TEndPoint("0.0.0.0", 22278));
+        new TConfigNodeLocation(
+            0, new TEndPoint("0.0.0.0", 22277), new TEndPoint("0.0.0.0", 
22278));
     Assert.assertEquals(configNodeLocation, configNodeInfos.get(0));
 
     List<TDataNodeLocation> dataNodeInfos = clusterNodes.getDataNodeList();
     Assert.assertEquals(3, dataNodeInfos.size());
     TDataNodeLocation dataNodeLocation = new TDataNodeLocation();
     for (int i = 0; i < 3; i++) {
-      dataNodeLocation.setDataNodeId(i);
+      dataNodeLocation.setDataNodeId(i + 1);
       dataNodeLocation.setExternalEndPoint(new TEndPoint("0.0.0.0", 6667 + i));
       dataNodeLocation.setInternalEndPoint(new TEndPoint("0.0.0.0", 9003 + i));
       dataNodeLocation.setDataBlockManagerEndPoint(new TEndPoint("0.0.0.0", 
8777 + i));
diff --git 
a/node-commons/src/main/java/org/apache/iotdb/commons/utils/NodeUrlUtils.java 
b/node-commons/src/main/java/org/apache/iotdb/commons/utils/NodeUrlUtils.java
index a502e4d42e..39614cc469 100644
--- 
a/node-commons/src/main/java/org/apache/iotdb/commons/utils/NodeUrlUtils.java
+++ 
b/node-commons/src/main/java/org/apache/iotdb/commons/utils/NodeUrlUtils.java
@@ -122,6 +122,7 @@ public class NodeUrlUtils {
    */
   public static String convertTConfigNodeUrl(TConfigNodeLocation 
configNodeLocation) {
     StringJoiner url = new StringJoiner(",");
+    url.add(String.valueOf(configNodeLocation.getConfigNodeId()));
     url.add(convertTEndPointUrl(configNodeLocation.getInternalEndPoint()));
     url.add(convertTEndPointUrl(configNodeLocation.getConsensusEndPoint()));
     return url.toString();
@@ -151,11 +152,12 @@ public class NodeUrlUtils {
   public static TConfigNodeLocation parseTConfigNodeUrl(String configNodeUrl)
       throws BadNodeUrlException {
     String[] split = configNodeUrl.split(",");
-    if (split.length != 2) {
+    if (split.length != 3) {
       logger.warn("Bad ConfigNode url: {}", configNodeUrl);
       throw new BadNodeUrlException(String.format("Bad node url: %s", 
configNodeUrl));
     }
-    return new TConfigNodeLocation(parseTEndPointUrl(split[0]), 
parseTEndPointUrl(split[1]));
+    return new TConfigNodeLocation(
+        Integer.parseInt(split[0]), parseTEndPointUrl(split[1]), 
parseTEndPointUrl(split[2]));
   }
 
   /**
diff --git 
a/node-commons/src/test/java/org/apache/iotdb/commons/utils/NodeUrlUtilsTest.java
 
b/node-commons/src/test/java/org/apache/iotdb/commons/utils/NodeUrlUtilsTest.java
index f6e497f309..fca5f407ab 100644
--- 
a/node-commons/src/test/java/org/apache/iotdb/commons/utils/NodeUrlUtilsTest.java
+++ 
b/node-commons/src/test/java/org/apache/iotdb/commons/utils/NodeUrlUtilsTest.java
@@ -48,13 +48,13 @@ public class NodeUrlUtilsTest {
     final List<TConfigNodeLocation> configNodeLocations =
         Arrays.asList(
             new TConfigNodeLocation(
-                new TEndPoint("0.0.0.0", 22277), new TEndPoint("0.0.0.0", 
22278)),
+                0, new TEndPoint("0.0.0.0", 22277), new TEndPoint("0.0.0.0", 
22278)),
             new TConfigNodeLocation(
-                new TEndPoint("0.0.0.0", 22279), new TEndPoint("0.0.0.0", 
22280)),
+                1, new TEndPoint("0.0.0.0", 22279), new TEndPoint("0.0.0.0", 
22280)),
             new TConfigNodeLocation(
-                new TEndPoint("0.0.0.0", 22281), new TEndPoint("0.0.0.0", 
22282)));
+                2, new TEndPoint("0.0.0.0", 22281), new TEndPoint("0.0.0.0", 
22282)));
     final String configNodeUrls =
-        
"0.0.0.0:22277,0.0.0.0:22278;0.0.0.0:22279,0.0.0.0:22280;0.0.0.0:22281,0.0.0.0:22282";
+        
"0,0.0.0.0:22277,0.0.0.0:22278;1,0.0.0.0:22279,0.0.0.0:22280;2,0.0.0.0:22281,0.0.0.0:22282";
 
     Assert.assertEquals(configNodeUrls, 
NodeUrlUtils.convertTConfigNodeUrls(configNodeLocations));
     Assert.assertEquals(configNodeLocations, 
NodeUrlUtils.parseTConfigNodeUrls(configNodeUrls));
diff --git 
a/node-commons/src/test/java/org/apache/iotdb/commons/utils/ThriftConfigNodeSerDeUtilsTest.java
 
b/node-commons/src/test/java/org/apache/iotdb/commons/utils/ThriftConfigNodeSerDeUtilsTest.java
index d14de95682..6c85a7b3fe 100644
--- 
a/node-commons/src/test/java/org/apache/iotdb/commons/utils/ThriftConfigNodeSerDeUtilsTest.java
+++ 
b/node-commons/src/test/java/org/apache/iotdb/commons/utils/ThriftConfigNodeSerDeUtilsTest.java
@@ -56,7 +56,8 @@ public class ThriftConfigNodeSerDeUtilsTest {
   @Test
   public void readWriteTConfigNodeLocationTest() {
     TConfigNodeLocation configNodeLocation0 =
-        new TConfigNodeLocation(new TEndPoint("0.0.0.0", 22277), new 
TEndPoint("0.0.0.0", 22278));
+        new TConfigNodeLocation(
+            0, new TEndPoint("0.0.0.0", 22277), new TEndPoint("0.0.0.0", 
22278));
 
     
ThriftConfigNodeSerDeUtils.serializeTConfigNodeLocation(configNodeLocation0, 
buffer);
     buffer.flip();
diff --git 
a/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/config/ShowClusterTask.java
 
b/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/config/ShowClusterTask.java
index fb475edfd0..ddc1d78fc5 100644
--- 
a/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/config/ShowClusterTask.java
+++ 
b/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/config/ShowClusterTask.java
@@ -31,8 +31,6 @@ import org.apache.iotdb.tsfile.utils.Binary;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.SettableFuture;
 
-import java.util.concurrent.atomic.AtomicInteger;
-
 import static org.apache.iotdb.commons.conf.IoTDBConstant.NODE_STATUS_RUNNING;
 import static 
org.apache.iotdb.commons.conf.IoTDBConstant.NODE_TYPE_CONFIG_NODE;
 import static org.apache.iotdb.commons.conf.IoTDBConstant.NODE_TYPE_DATA_NODE;
@@ -68,14 +66,13 @@ public class ShowClusterTask implements IConfigTask {
     TsBlockBuilder builder =
         new 
TsBlockBuilder(HeaderConstant.showClusterHeader.getRespDataTypes());
 
-    AtomicInteger configNodeId = new AtomicInteger();
     clusterNodeInfos
         .getConfigNodeList()
         .forEach(
             e ->
                 buildTsBlock(
                     builder,
-                    configNodeId.getAndIncrement(),
+                    e.getConfigNodeId(),
                     NODE_TYPE_CONFIG_NODE,
                     NODE_STATUS_RUNNING,
                     e.getInternalEndPoint().getIp(),
diff --git a/thrift-commons/src/main/thrift/common.thrift 
b/thrift-commons/src/main/thrift/common.thrift
index ac6a17331b..e314a6327a 100644
--- a/thrift-commons/src/main/thrift/common.thrift
+++ b/thrift-commons/src/main/thrift/common.thrift
@@ -58,12 +58,9 @@ struct TRegionReplicaSet {
 }
 
 struct TConfigNodeLocation {
-  1: required TEndPoint internalEndPoint
-  2: required TEndPoint consensusEndPoint
-}
-
-struct THeartbeatReq {
-  1: required i64 heartbeatTimestamp
+  1: required i32 configNodeId
+  2: required TEndPoint internalEndPoint
+  3: required TEndPoint consensusEndPoint
 }
 
 struct TDataNodeLocation {
@@ -80,6 +77,10 @@ struct TDataNodeLocation {
   6: required TEndPoint schemaRegionConsensusEndPoint
 }
 
+struct THeartbeatReq {
+  1: required i64 heartbeatTimestamp
+}
+
 struct THeartbeatResp {
   1: required i64 heartbeatTimestamp
   2: optional i16 cpu

Reply via email to