You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/06/16 10:58:12 UTC

[GitHub] [iotdb] RYH61 opened a new pull request, #6315: [IOTDB-3511] Show Region tool

RYH61 opened a new pull request, #6315:
URL: https://github.com/apache/iotdb/pull/6315

   add new function: show (data | schema)? regions
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] RYH61 commented on a diff in pull request #6315: [IOTDB-3511] Show Region tool

Posted by GitBox <gi...@apache.org>.
RYH61 commented on code in PR #6315:
URL: https://github.com/apache/iotdb/pull/6315#discussion_r899230100


##########
confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/read/GetRegionsInfoReq.java:
##########
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.confignode.consensus.request.read;
+
+import org.apache.iotdb.confignode.consensus.request.ConfigRequest;
+import org.apache.iotdb.confignode.consensus.request.ConfigRequestType;
+import org.apache.iotdb.tsfile.utils.ReadWriteIOUtils;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+public class GetRegionsInfoReq extends ConfigRequest {
+
+  private int regionType;

Review Comment:
   fixed~



##########
confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/read/GetRegionsInfoReq.java:
##########
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.confignode.consensus.request.read;
+
+import org.apache.iotdb.confignode.consensus.request.ConfigRequest;
+import org.apache.iotdb.confignode.consensus.request.ConfigRequestType;
+import org.apache.iotdb.tsfile.utils.ReadWriteIOUtils;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+public class GetRegionsInfoReq extends ConfigRequest {

Review Comment:
   fixed~



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] RYH61 commented on a diff in pull request #6315: [IOTDB-3511] Show Region tool

Posted by GitBox <gi...@apache.org>.
RYH61 commented on code in PR #6315:
URL: https://github.com/apache/iotdb/pull/6315#discussion_r899835674


##########
server/src/main/java/org/apache/iotdb/db/mpp/common/header/HeaderConstant.java:
##########
@@ -200,4 +209,19 @@ public class HeaderConstant {
                 new ColumnHeader(COLUMN_FUNCTION_CLASS, TSDataType.TEXT)),
             true);
   }
+
+  static {
+    showRegionHeader =
+        new DatasetHeader(
+            Arrays.asList(
+                new ColumnHeader(COLUMN_REGION_ID, TSDataType.INT32),
+                new ColumnHeader(COLUMN_TYPE, TSDataType.TEXT),
+                new ColumnHeader(COLUMN_STATUS, TSDataType.TEXT),
+                new ColumnHeader(COLUMN_STORAGE_GROUP, TSDataType.TEXT),
+                new ColumnHeader(COLUMN_SLOTS, TSDataType.INT32),

Review Comment:
   fixed~



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] RYH61 commented on a diff in pull request #6315: [IOTDB-3511] Show Region tool

Posted by GitBox <gi...@apache.org>.
RYH61 commented on code in PR #6315:
URL: https://github.com/apache/iotdb/pull/6315#discussion_r900706722


##########
confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java:
##########
@@ -644,6 +646,18 @@ public UDFManager getUDFManager() {
     return udfManager;
   }
 
+  @Override
+  public DataSet showRegion(GetRegionLocationsReq getRegionsinfoReq) {
+    TSStatus status = confirmLeader();
+    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
+      return partitionManager.getRegionInfos(getRegionsinfoReq);

Review Comment:
   fixed~



##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/parser/ASTVisitor.java:
##########
@@ -2217,4 +2219,19 @@ public Statement visitFlush(IoTDBSqlParser.FlushContext ctx) {
     flushStatement.setStorageGroups(storageGroups);
     return flushStatement;
   }
+
+  // show region
+
+  @Override
+  public Statement visitShowRegion(IoTDBSqlParser.ShowRegionContext ctx) {
+    ShowRegionStatement showRegionStatement = new ShowRegionStatement();
+    if (ctx.DATA() != null) {
+      showRegionStatement.setRegionType(TConsensusGroupType.DataRegion);
+    } else if (ctx.SCHEMA() != null) {
+      showRegionStatement.setRegionType(TConsensusGroupType.SchemaRegion);
+    } else {
+      showRegionStatement.setRegionType(TConsensusGroupType.PartitionRegion);

Review Comment:
   fixed~



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] RYH61 commented on a diff in pull request #6315: [IOTDB-3511] Show Region tool

Posted by GitBox <gi...@apache.org>.
RYH61 commented on code in PR #6315:
URL: https://github.com/apache/iotdb/pull/6315#discussion_r899742240


##########
confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/StorageGroupPartitionTable.java:
##########
@@ -361,6 +366,48 @@ public List<Pair<Long, TConsensusGroupId>> getSortedRegionSlotsCounter(TConsensu
     return result;
   }
 
+  public void getRegionInfos(
+      GetRegionLocationsReq regionsInfoReq, List<TRegionLocation> tRegionInfosList) {
+    regionInfoMap.forEach(
+        (consensusGroupId, regionInfoMap) -> {
+          TRegionReplicaSet replicaSet = regionInfoMap.getReplicaSet();
+          if (replicaSet.getRegionId().getType().ordinal()
+              == regionsInfoReq.getRegionType().ordinal()) {
+            buildTRegionsInfo(tRegionInfosList, storageGroupName, replicaSet, regionInfoMap);
+          }
+          if (regionsInfoReq.getRegionType() == TConsensusGroupType.PartitionRegion) {
+            buildTRegionsInfo(tRegionInfosList, storageGroupName, replicaSet, regionInfoMap);
+          }
+        });
+  }
+
+  private void buildTRegionsInfo(
+      List<TRegionLocation> tRegionInfosList,
+      String storageGroup,
+      TRegionReplicaSet replicaSet,
+      RegionGroup regionInfoMap) {
+    List<Integer> dataNodeIdList = null;
+    List<String> rpcAddressList = null;
+    List<Integer> rpcPortList = null;
+    TRegionLocation tRegionInfos = new TRegionLocation();
+    tRegionInfos.setRegionId(replicaSet.getRegionId().getId());
+    tRegionInfos.setRegionType(replicaSet.getRegionId().getType().getValue());
+    tRegionInfos.setStorageGroup(storageGroup);
+    long slots = regionInfoMap.getCounter();
+    tRegionInfos.setSlots((int) slots);
+    for (TDataNodeLocation dataNodeLocation : replicaSet.getDataNodeLocations()) {
+      dataNodeIdList = Arrays.asList(dataNodeLocation.getDataNodeId());
+      rpcAddressList = Arrays.asList(dataNodeLocation.getExternalEndPoint().getIp());
+      rpcPortList = Arrays.asList(dataNodeLocation.getExternalEndPoint().getPort());
+    }

Review Comment:
   fixed~



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] RYH61 commented on a diff in pull request #6315: [IOTDB-3511] Show Region tool

Posted by GitBox <gi...@apache.org>.
RYH61 commented on code in PR #6315:
URL: https://github.com/apache/iotdb/pull/6315#discussion_r899742120


##########
confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/StorageGroupPartitionTable.java:
##########
@@ -361,6 +366,48 @@ public List<Pair<Long, TConsensusGroupId>> getSortedRegionSlotsCounter(TConsensu
     return result;
   }
 
+  public void getRegionInfos(
+      GetRegionLocationsReq regionsInfoReq, List<TRegionLocation> tRegionInfosList) {
+    regionInfoMap.forEach(
+        (consensusGroupId, regionInfoMap) -> {
+          TRegionReplicaSet replicaSet = regionInfoMap.getReplicaSet();
+          if (replicaSet.getRegionId().getType().ordinal()
+              == regionsInfoReq.getRegionType().ordinal()) {
+            buildTRegionsInfo(tRegionInfosList, storageGroupName, replicaSet, regionInfoMap);
+          }
+          if (regionsInfoReq.getRegionType() == TConsensusGroupType.PartitionRegion) {
+            buildTRegionsInfo(tRegionInfosList, storageGroupName, replicaSet, regionInfoMap);
+          }
+        });
+  }
+
+  private void buildTRegionsInfo(
+      List<TRegionLocation> tRegionInfosList,
+      String storageGroup,
+      TRegionReplicaSet replicaSet,
+      RegionGroup regionInfoMap) {

Review Comment:
   fixed~



##########
thrift-commons/src/main/thrift/common.thrift:
##########
@@ -77,6 +77,17 @@ struct TDataNodeLocation {
   6: required TEndPoint schemaRegionConsensusEndPoint
 }
 
+struct TRegionLocation {
+  1: required i32 regionId;
+  2: required i64 regionType;

Review Comment:
   fixed~



##########
thrift-commons/src/main/thrift/common.thrift:
##########
@@ -77,6 +77,17 @@ struct TDataNodeLocation {
   6: required TEndPoint schemaRegionConsensusEndPoint
 }
 
+struct TRegionLocation {
+  1: required i32 regionId;
+  2: required i64 regionType;
+  3: required string storageGroup
+  4: required i32 dataNodeId;
+  5: required string rpcAddresss;
+  6: required i32 rpcPort;
+  7: required i32 slots;

Review Comment:
   fixed~



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] RYH61 commented on a diff in pull request #6315: [IOTDB-3511] Show Region tool

Posted by GitBox <gi...@apache.org>.
RYH61 commented on code in PR #6315:
URL: https://github.com/apache/iotdb/pull/6315#discussion_r899231209


##########
server/src/test/resources/datanode4conf/iotdb-metric.yml:
##########
@@ -0,0 +1,53 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+# whether enable the module

Review Comment:
   My mistake, I have deleted it
   



##########
thrift-confignode/src/main/thrift/confignode.thrift:
##########
@@ -229,6 +229,27 @@ struct TDropFunctionReq {
   1: required string udfName
 }
 
+// show regions
+struct TShowRegionReq {
+  1: optional i32 regionType;
+}
+
+struct TRegionInfos {

Review Comment:
   fixed~



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] CRZbulabula commented on a diff in pull request #6315: [IOTDB-3511] Show Region tool

Posted by GitBox <gi...@apache.org>.
CRZbulabula commented on code in PR #6315:
URL: https://github.com/apache/iotdb/pull/6315#discussion_r899685351


##########
confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/StorageGroupPartitionTable.java:
##########
@@ -361,6 +366,48 @@ public List<Pair<Long, TConsensusGroupId>> getSortedRegionSlotsCounter(TConsensu
     return result;
   }
 
+  public void getRegionInfos(
+      GetRegionLocationsReq regionsInfoReq, List<TRegionLocation> tRegionInfosList) {
+    regionInfoMap.forEach(
+        (consensusGroupId, regionInfoMap) -> {

Review Comment:
   `(consensusGroupId, regionGroup)`



##########
confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/StorageGroupPartitionTable.java:
##########
@@ -361,6 +366,48 @@ public List<Pair<Long, TConsensusGroupId>> getSortedRegionSlotsCounter(TConsensu
     return result;
   }
 
+  public void getRegionInfos(
+      GetRegionLocationsReq regionsInfoReq, List<TRegionLocation> tRegionInfosList) {
+    regionInfoMap.forEach(
+        (consensusGroupId, regionInfoMap) -> {
+          TRegionReplicaSet replicaSet = regionInfoMap.getReplicaSet();
+          if (replicaSet.getRegionId().getType().ordinal()
+              == regionsInfoReq.getRegionType().ordinal()) {
+            buildTRegionsInfo(tRegionInfosList, storageGroupName, replicaSet, regionInfoMap);
+          }
+          if (regionsInfoReq.getRegionType() == TConsensusGroupType.PartitionRegion) {
+            buildTRegionsInfo(tRegionInfosList, storageGroupName, replicaSet, regionInfoMap);
+          }
+        });
+  }
+
+  private void buildTRegionsInfo(
+      List<TRegionLocation> tRegionInfosList,
+      String storageGroup,
+      TRegionReplicaSet replicaSet,
+      RegionGroup regionInfoMap) {

Review Comment:
   Rename _regionInfoMap_ to _regionGroup_



##########
confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/StorageGroupPartitionTable.java:
##########
@@ -361,6 +366,48 @@ public List<Pair<Long, TConsensusGroupId>> getSortedRegionSlotsCounter(TConsensu
     return result;
   }
 
+  public void getRegionInfos(
+      GetRegionLocationsReq regionsInfoReq, List<TRegionLocation> tRegionInfosList) {
+    regionInfoMap.forEach(
+        (consensusGroupId, regionInfoMap) -> {
+          TRegionReplicaSet replicaSet = regionInfoMap.getReplicaSet();
+          if (replicaSet.getRegionId().getType().ordinal()
+              == regionsInfoReq.getRegionType().ordinal()) {
+            buildTRegionsInfo(tRegionInfosList, storageGroupName, replicaSet, regionInfoMap);
+          }
+          if (regionsInfoReq.getRegionType() == TConsensusGroupType.PartitionRegion) {
+            buildTRegionsInfo(tRegionInfosList, storageGroupName, replicaSet, regionInfoMap);
+          }
+        });
+  }
+
+  private void buildTRegionsInfo(
+      List<TRegionLocation> tRegionInfosList,
+      String storageGroup,

Review Comment:
   The parameter  _storageGroup_ can be removed



##########
confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/StorageGroupPartitionTable.java:
##########
@@ -361,6 +366,48 @@ public List<Pair<Long, TConsensusGroupId>> getSortedRegionSlotsCounter(TConsensu
     return result;
   }
 
+  public void getRegionInfos(
+      GetRegionLocationsReq regionsInfoReq, List<TRegionLocation> tRegionInfosList) {
+    regionInfoMap.forEach(
+        (consensusGroupId, regionInfoMap) -> {
+          TRegionReplicaSet replicaSet = regionInfoMap.getReplicaSet();
+          if (replicaSet.getRegionId().getType().ordinal()
+              == regionsInfoReq.getRegionType().ordinal()) {
+            buildTRegionsInfo(tRegionInfosList, storageGroupName, replicaSet, regionInfoMap);
+          }
+          if (regionsInfoReq.getRegionType() == TConsensusGroupType.PartitionRegion) {
+            buildTRegionsInfo(tRegionInfosList, storageGroupName, replicaSet, regionInfoMap);
+          }
+        });
+  }
+
+  private void buildTRegionsInfo(
+      List<TRegionLocation> tRegionInfosList,
+      String storageGroup,
+      TRegionReplicaSet replicaSet,
+      RegionGroup regionInfoMap) {
+    List<Integer> dataNodeIdList = null;
+    List<String> rpcAddressList = null;
+    List<Integer> rpcPortList = null;
+    TRegionLocation tRegionInfos = new TRegionLocation();
+    tRegionInfos.setRegionId(replicaSet.getRegionId().getId());
+    tRegionInfos.setRegionType(replicaSet.getRegionId().getType().getValue());
+    tRegionInfos.setStorageGroup(storageGroup);
+    long slots = regionInfoMap.getCounter();
+    tRegionInfos.setSlots((int) slots);
+    for (TDataNodeLocation dataNodeLocation : replicaSet.getDataNodeLocations()) {
+      dataNodeIdList = Arrays.asList(dataNodeLocation.getDataNodeId());
+      rpcAddressList = Arrays.asList(dataNodeLocation.getExternalEndPoint().getIp());
+      rpcPortList = Arrays.asList(dataNodeLocation.getExternalEndPoint().getPort());
+    }

Review Comment:
   When there are multiple replicas in a RegionGroup, the same number of TregionLocations should be created when querying.



##########
thrift-commons/src/main/thrift/common.thrift:
##########
@@ -77,6 +77,17 @@ struct TDataNodeLocation {
   6: required TEndPoint schemaRegionConsensusEndPoint
 }
 
+struct TRegionLocation {
+  1: required i32 regionId;
+  2: required i64 regionType;

Review Comment:
   These two parameter _regionId_ and _regionType_ can be replaced by one parameter _TConsensusGroupId_



##########
thrift-commons/src/main/thrift/common.thrift:
##########
@@ -77,6 +77,17 @@ struct TDataNodeLocation {
   6: required TEndPoint schemaRegionConsensusEndPoint
 }
 
+struct TRegionLocation {
+  1: required i32 regionId;
+  2: required i64 regionType;
+  3: required string storageGroup
+  4: required i32 dataNodeId;
+  5: required string rpcAddresss;
+  6: required i32 rpcPort;
+  7: required i32 slots;

Review Comment:
   The type of parameter _slots_ should be i64, sorry for didn't explain clearly last night.



##########
thrift-confignode/src/main/thrift/confignode.thrift:
##########
@@ -229,6 +229,16 @@ struct TDropFunctionReq {
   1: required string udfName
 }
 
+// show regions
+struct TShowRegionReq {
+  1: optional i32 regionType;

Review Comment:
   TConsensusGroupType



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] CRZbulabula commented on a diff in pull request #6315: [IOTDB-3511] Show Region tool

Posted by GitBox <gi...@apache.org>.
CRZbulabula commented on code in PR #6315:
URL: https://github.com/apache/iotdb/pull/6315#discussion_r899832881


##########
server/src/main/java/org/apache/iotdb/db/mpp/common/header/HeaderConstant.java:
##########
@@ -200,4 +209,19 @@ public class HeaderConstant {
                 new ColumnHeader(COLUMN_FUNCTION_CLASS, TSDataType.TEXT)),
             true);
   }
+
+  static {
+    showRegionHeader =
+        new DatasetHeader(
+            Arrays.asList(
+                new ColumnHeader(COLUMN_REGION_ID, TSDataType.INT32),
+                new ColumnHeader(COLUMN_TYPE, TSDataType.TEXT),
+                new ColumnHeader(COLUMN_STATUS, TSDataType.TEXT),
+                new ColumnHeader(COLUMN_STORAGE_GROUP, TSDataType.TEXT),
+                new ColumnHeader(COLUMN_SLOTS, TSDataType.INT32),

Review Comment:
   CLOUMN_SLOTS's datatype should be TSDataType.INT64?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] RYH61 commented on a diff in pull request #6315: [IOTDB-3511] Show Region tool

Posted by GitBox <gi...@apache.org>.
RYH61 commented on code in PR #6315:
URL: https://github.com/apache/iotdb/pull/6315#discussion_r899741989


##########
confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/PartitionInfo.java:
##########
@@ -685,6 +691,62 @@ public void processLoadSnapshot(File snapshotDir) throws TException, IOException
     }
   }
 
+  public DataSet getRegionInfos(GetRegionsInfoReq regionsInfoReq) {
+    RegionsInfoResp regionResp = new RegionsInfoResp();
+    List<TRegionInfos> tRegionInfosList = new ArrayList<>();
+    if (storageGroupPartitionTables.isEmpty()) {
+      regionResp.setStatus(RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS));
+      return regionResp;
+    }
+    storageGroupPartitionTables.forEach(
+        (storageGroup, storageGroupPartitionTable) ->
+            storageGroupPartitionTable
+                .getRegionInfoMap()
+                .forEach(
+                    (consensusGroupId, regionInfoMap) -> {
+                      TRegionReplicaSet replicaSet = regionInfoMap.getReplicaSet();
+                      if (replicaSet.getRegionId().getType().ordinal()
+                          == regionsInfoReq.getRegionType()) {
+                        buildTRegionsInfo(
+                            tRegionInfosList, storageGroup, replicaSet, regionInfoMap);
+                      }
+                      if (regionsInfoReq.getRegionType() == -1) {
+                        buildTRegionsInfo(
+                            tRegionInfosList, storageGroup, replicaSet, regionInfoMap);
+                      }
+                    }));
+    regionResp.setRegionInfosList(tRegionInfosList);
+    regionResp.setStatus(RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS));
+    return regionResp;
+  }
+
+  private void buildTRegionsInfo(
+      List<TRegionInfos> tRegionInfosList,
+      String storageGroup,
+      TRegionReplicaSet replicaSet,
+      RegionGroup regionInfoMap) {
+    List<Integer> dataNodeIdList = null;
+    List<String> rpcAddressList = null;
+    List<Integer> rpcPortList = null;
+    TRegionInfos tRegionInfos = new TRegionInfos();
+    tRegionInfos.setRegionId(replicaSet.getRegionId().getId());
+    tRegionInfos.setRegionType(replicaSet.getRegionId().getType().getValue());
+    tRegionInfos.setStorageGroup(storageGroup);
+    long slots = regionInfoMap.getCounter();
+    tRegionInfos.setSlots((int) slots);
+    for (TDataNodeLocation dataNodeLocation : replicaSet.getDataNodeLocations()) {
+      dataNodeIdList = Arrays.asList(dataNodeLocation.getDataNodeId());
+      rpcAddressList = Arrays.asList(dataNodeLocation.getExternalEndPoint().getIp());
+      rpcPortList = Arrays.asList(dataNodeLocation.getExternalEndPoint().getPort());
+    }

Review Comment:
   fixed~



##########
confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/StorageGroupPartitionTable.java:
##########
@@ -361,6 +366,48 @@ public List<Pair<Long, TConsensusGroupId>> getSortedRegionSlotsCounter(TConsensu
     return result;
   }
 
+  public void getRegionInfos(
+      GetRegionLocationsReq regionsInfoReq, List<TRegionLocation> tRegionInfosList) {
+    regionInfoMap.forEach(
+        (consensusGroupId, regionInfoMap) -> {

Review Comment:
   fixed~



##########
confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/StorageGroupPartitionTable.java:
##########
@@ -361,6 +366,48 @@ public List<Pair<Long, TConsensusGroupId>> getSortedRegionSlotsCounter(TConsensu
     return result;
   }
 
+  public void getRegionInfos(
+      GetRegionLocationsReq regionsInfoReq, List<TRegionLocation> tRegionInfosList) {
+    regionInfoMap.forEach(
+        (consensusGroupId, regionInfoMap) -> {
+          TRegionReplicaSet replicaSet = regionInfoMap.getReplicaSet();
+          if (replicaSet.getRegionId().getType().ordinal()
+              == regionsInfoReq.getRegionType().ordinal()) {
+            buildTRegionsInfo(tRegionInfosList, storageGroupName, replicaSet, regionInfoMap);
+          }
+          if (regionsInfoReq.getRegionType() == TConsensusGroupType.PartitionRegion) {
+            buildTRegionsInfo(tRegionInfosList, storageGroupName, replicaSet, regionInfoMap);
+          }
+        });
+  }
+
+  private void buildTRegionsInfo(
+      List<TRegionLocation> tRegionInfosList,
+      String storageGroup,

Review Comment:
   fixed~



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] RYH61 commented on a diff in pull request #6315: [IOTDB-3511] Show Region tool

Posted by GitBox <gi...@apache.org>.
RYH61 commented on code in PR #6315:
URL: https://github.com/apache/iotdb/pull/6315#discussion_r899229941


##########
confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/ConfigRequestType.java:
##########
@@ -61,5 +61,6 @@ public enum ConfigRequestType {
   ApplyConfigNode,
   CreateFunction,
   DropFunction,
-  GetNodePathsPartition;
+  GetNodePathsPartition,
+  GetRegionsInfo;

Review Comment:
   fixed~



##########
confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/read/GetRegionsInfoReq.java:
##########
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.confignode.consensus.request.read;
+
+import org.apache.iotdb.confignode.consensus.request.ConfigRequest;
+import org.apache.iotdb.confignode.consensus.request.ConfigRequestType;
+import org.apache.iotdb.tsfile.utils.ReadWriteIOUtils;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+public class GetRegionsInfoReq extends ConfigRequest {
+
+  private int regionType;
+
+  public GetRegionsInfoReq() {
+    super(ConfigRequestType.GetRegionsInfo);
+  }
+
+  public GetRegionsInfoReq(int regionType) {
+    super(ConfigRequestType.GetRegionsInfo);
+    this.regionType = regionType;
+  }
+
+  public int getRegionType() {
+    return regionType;
+  }
+
+  public void setRegionType(int regionType) {
+    this.regionType = regionType;
+  }
+
+  @Override
+  protected void serializeImpl(DataOutputStream stream) throws IOException {
+    stream.writeInt(getType().ordinal());
+    ReadWriteIOUtils.write(regionType, stream);
+  }
+
+  @Override
+  protected void deserializeImpl(ByteBuffer buffer) throws IOException {
+    regionType = ReadWriteIOUtils.readInt(buffer);
+  }
+}

Review Comment:
   fixed~



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] RYH61 commented on a diff in pull request #6315: [IOTDB-3511] Show Region tool

Posted by GitBox <gi...@apache.org>.
RYH61 commented on code in PR #6315:
URL: https://github.com/apache/iotdb/pull/6315#discussion_r899742185


##########
thrift-confignode/src/main/thrift/confignode.thrift:
##########
@@ -229,6 +229,16 @@ struct TDropFunctionReq {
   1: required string udfName
 }
 
+// show regions
+struct TShowRegionReq {
+  1: optional i32 regionType;

Review Comment:
   fixed~



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] RYH61 commented on a diff in pull request #6315: [IOTDB-3511] Show Region tool

Posted by GitBox <gi...@apache.org>.
RYH61 commented on code in PR #6315:
URL: https://github.com/apache/iotdb/pull/6315#discussion_r899230349


##########
confignode/src/main/java/org/apache/iotdb/confignode/consensus/response/RegionsInfoResp.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.confignode.consensus.response;
+
+import org.apache.iotdb.common.rpc.thrift.TSStatus;
+import org.apache.iotdb.confignode.rpc.thrift.TRegionInfos;
+import org.apache.iotdb.consensus.common.DataSet;
+
+import java.util.List;
+
+public class RegionsInfoResp implements DataSet {

Review Comment:
   fixed~



##########
thrift-confignode/src/main/thrift/confignode.thrift:
##########
@@ -229,6 +229,27 @@ struct TDropFunctionReq {
   1: required string udfName
 }
 
+// show regions
+struct TShowRegionReq {
+  1: optional i32 regionType;
+}
+
+struct TRegionInfos {
+  1: required i32 regionId;
+  2: required i32 regionType;
+  3: required string storageGroup
+  4: required list<i32> dataNodeId;
+  5: required list<string> rpcAddresss;
+  6: required list<i32> rpcPort;

Review Comment:
   fixed~



##########
thrift-confignode/src/main/thrift/confignode.thrift:
##########
@@ -229,6 +229,27 @@ struct TDropFunctionReq {
   1: required string udfName
 }
 
+// show regions
+struct TShowRegionReq {
+  1: optional i32 regionType;
+}
+
+struct TRegionInfos {
+  1: required i32 regionId;
+  2: required i32 regionType;
+  3: required string storageGroup
+  4: required list<i32> dataNodeId;
+  5: required list<string> rpcAddresss;
+  6: required list<i32> rpcPort;
+  7: required i32 slots;

Review Comment:
   fixed~



##########
confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/PartitionInfo.java:
##########
@@ -685,6 +691,62 @@ public void processLoadSnapshot(File snapshotDir) throws TException, IOException
     }
   }
 
+  public DataSet getRegionInfos(GetRegionsInfoReq regionsInfoReq) {
+    RegionsInfoResp regionResp = new RegionsInfoResp();
+    List<TRegionInfos> tRegionInfosList = new ArrayList<>();
+    if (storageGroupPartitionTables.isEmpty()) {
+      regionResp.setStatus(RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS));
+      return regionResp;
+    }
+    storageGroupPartitionTables.forEach(
+        (storageGroup, storageGroupPartitionTable) ->
+            storageGroupPartitionTable
+                .getRegionInfoMap()
+                .forEach(
+                    (consensusGroupId, regionInfoMap) -> {
+                      TRegionReplicaSet replicaSet = regionInfoMap.getReplicaSet();
+                      if (replicaSet.getRegionId().getType().ordinal()
+                          == regionsInfoReq.getRegionType()) {
+                        buildTRegionsInfo(
+                            tRegionInfosList, storageGroup, replicaSet, regionInfoMap);
+                      }
+                      if (regionsInfoReq.getRegionType() == -1) {
+                        buildTRegionsInfo(
+                            tRegionInfosList, storageGroup, replicaSet, regionInfoMap);
+                      }
+                    }));
+    regionResp.setRegionInfosList(tRegionInfosList);
+    regionResp.setStatus(RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS));
+    return regionResp;
+  }
+
+  private void buildTRegionsInfo(
+      List<TRegionInfos> tRegionInfosList,
+      String storageGroup,
+      TRegionReplicaSet replicaSet,
+      RegionGroup regionInfoMap) {

Review Comment:
   fixed~



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] RYH61 commented on a diff in pull request #6315: [IOTDB-3511] Show Region tool

Posted by GitBox <gi...@apache.org>.
RYH61 commented on code in PR #6315:
URL: https://github.com/apache/iotdb/pull/6315#discussion_r900706668


##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/config/executor/StandaloneConfigTaskExecutor.java:
##########
@@ -256,4 +257,15 @@ public SettableFuture<ConfigTaskResult> showTTL(ShowTTLStatement showTTLStatemen
     ShowTTLTask.buildTSBlock(storageGroupToTTL, future);
     return future;
   }
+
+  @Override
+  public SettableFuture<ConfigTaskResult> showRegion(ShowRegionStatement showRegionStatement) {
+    SettableFuture<ConfigTaskResult> future = SettableFuture.create();
+    future.setException(
+        new StatementExecutionException(
+            RpcUtils.getStatus(
+                TSStatusCode.EXECUTE_STATEMENT_ERROR,
+                "Executing this command in standalone mode is not supported")));

Review Comment:
   fixed~



##########
docs/zh/UserGuide/Maintenance-Tools/Maintenance-Command.md:
##########
@@ -111,3 +111,66 @@ KILL QUERY <queryId>
 |      |         |           |
 
 其中 statement 最大显示长度为 64 字符。对于超过 64 字符的查询语句,将截取部分进行显示。
+
+## 集群 Region 分布监控工具
+
+集群中以 Region 作为数据复制和数据管理的单元,Region 的状态和分布对于系统运维和测试有很大帮助,如以下场景:
+
+- 查看集群中各个 Region 被分配到了哪些 DataNode,是否均衡
+
+当前 IoTDB 支持使用如下 SQL 查看Region:

Review Comment:
   fixed~



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] qiaojialin commented on a diff in pull request #6315: [IOTDB-3511] Show Region tool

Posted by GitBox <gi...@apache.org>.
qiaojialin commented on code in PR #6315:
URL: https://github.com/apache/iotdb/pull/6315#discussion_r900315723


##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/config/executor/StandaloneConfigTaskExecutor.java:
##########
@@ -256,4 +257,15 @@ public SettableFuture<ConfigTaskResult> showTTL(ShowTTLStatement showTTLStatemen
     ShowTTLTask.buildTSBlock(storageGroupToTTL, future);
     return future;
   }
+
+  @Override
+  public SettableFuture<ConfigTaskResult> showRegion(ShowRegionStatement showRegionStatement) {
+    SettableFuture<ConfigTaskResult> future = SettableFuture.create();
+    future.setException(
+        new StatementExecutionException(
+            RpcUtils.getStatus(
+                TSStatusCode.EXECUTE_STATEMENT_ERROR,
+                "Executing this command in standalone mode is not supported")));

Review Comment:
   ```suggestion
                   "Executing show regions in standalone mode is not supported")));
   ```



##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/config/executor/ClusterConfigTaskExecutor.java:
##########
@@ -325,4 +329,26 @@ public SettableFuture<ConfigTaskResult> showTTL(ShowTTLStatement showTTLStatemen
     ShowTTLTask.buildTSBlock(storageGroupToTTL, future);
     return future;
   }
+
+  @Override
+  public SettableFuture<ConfigTaskResult> showRegion(ShowRegionStatement showRegionStatement) {
+    SettableFuture<ConfigTaskResult> future = SettableFuture.create();
+    TShowRegionResp showRegionResp = new TShowRegionResp();
+    TShowRegionReq showRegionReq = new TShowRegionReq();
+    showRegionReq.setConsensusGroupType(showRegionStatement.getRegionType());
+    try (ConfigNodeClient client =
+        CONFIG_NODE_CLIENT_MANAGER.borrowClient(ConfigNodeInfo.partitionRegionId)) {
+      showRegionResp = client.showRegion(showRegionReq);
+      if (showRegionResp.getStatus().getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
+        future.setException(new StatementExecutionException(showRegionResp.getStatus()));
+        return future;
+      }
+    } catch (TException | IOException e) {
+      LOGGER.error("Failed to connect to config node.");

Review Comment:
   ```suggestion
         LOGGER.error("Failed to connect to ConfigNode {} from DataNode {}.", ip+port, ip+port);
   ```



##########
docs/zh/UserGuide/Maintenance-Tools/Maintenance-Command.md:
##########
@@ -111,3 +111,66 @@ KILL QUERY <queryId>
 |      |         |           |
 
 其中 statement 最大显示长度为 64 字符。对于超过 64 字符的查询语句,将截取部分进行显示。
+
+## 集群 Region 分布监控工具
+
+集群中以 Region 作为数据复制和数据管理的单元,Region 的状态和分布对于系统运维和测试有很大帮助,如以下场景:
+
+- 查看集群中各个 Region 被分配到了哪些 DataNode,是否均衡
+
+当前 IoTDB 支持使用如下 SQL 查看Region:
+
+- `SHOW REGIONS`: 展示所有 Region
+- `SHOW SCHEMA REGIONS`: 展示所有 SchemaRegion 分布
+- `SHOW DATA REGIONS`: 展示所有 DataRegion 分布
+
+```sql
+IoTDB> show regions
++--------+------------+------+-------------+-----+----------+----------+----+
+|RegionId|        Type|Status|storage group|Slots|DataNodeId|HostAdress|Port|
++--------+------------+------+-------------+-----+----------+----------+----+
+|       5|  DataRegion|    Up|      root.sg|    1|         2| 127.0.0.1|6671|

Review Comment:
   How about sorting the result by regionId in ascending order by default



##########
docs/zh/UserGuide/Maintenance-Tools/Maintenance-Command.md:
##########
@@ -111,3 +111,66 @@ KILL QUERY <queryId>
 |      |         |           |
 
 其中 statement 最大显示长度为 64 字符。对于超过 64 字符的查询语句,将截取部分进行显示。
+
+## 集群 Region 分布监控工具
+
+集群中以 Region 作为数据复制和数据管理的单元,Region 的状态和分布对于系统运维和测试有很大帮助,如以下场景:
+
+- 查看集群中各个 Region 被分配到了哪些 DataNode,是否均衡
+
+当前 IoTDB 支持使用如下 SQL 查看Region:

Review Comment:
   ```suggestion
   当前 IoTDB 支持使用如下 SQL 查看 Region:
   ```



##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/parser/ASTVisitor.java:
##########
@@ -2217,4 +2219,19 @@ public Statement visitFlush(IoTDBSqlParser.FlushContext ctx) {
     flushStatement.setStorageGroups(storageGroups);
     return flushStatement;
   }
+
+  // show region
+
+  @Override
+  public Statement visitShowRegion(IoTDBSqlParser.ShowRegionContext ctx) {
+    ShowRegionStatement showRegionStatement = new ShowRegionStatement();
+    if (ctx.DATA() != null) {
+      showRegionStatement.setRegionType(TConsensusGroupType.DataRegion);
+    } else if (ctx.SCHEMA() != null) {
+      showRegionStatement.setRegionType(TConsensusGroupType.SchemaRegion);
+    } else {
+      showRegionStatement.setRegionType(TConsensusGroupType.PartitionRegion);

Review Comment:
   Set to Null? Maybe we will add a show partition region in the future.



##########
confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java:
##########
@@ -644,6 +646,18 @@ public UDFManager getUDFManager() {
     return udfManager;
   }
 
+  @Override
+  public DataSet showRegion(GetRegionLocationsReq getRegionsinfoReq) {
+    TSStatus status = confirmLeader();
+    if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
+      return partitionManager.getRegionInfos(getRegionsinfoReq);

Review Comment:
   getRetionLocations(getRegionLocationsReq)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] RYH61 commented on a diff in pull request #6315: [IOTDB-3511] Show Region tool

Posted by GitBox <gi...@apache.org>.
RYH61 commented on code in PR #6315:
URL: https://github.com/apache/iotdb/pull/6315#discussion_r900706674


##########
docs/zh/UserGuide/Maintenance-Tools/Maintenance-Command.md:
##########
@@ -111,3 +111,66 @@ KILL QUERY <queryId>
 |      |         |           |
 
 其中 statement 最大显示长度为 64 字符。对于超过 64 字符的查询语句,将截取部分进行显示。
+
+## 集群 Region 分布监控工具
+
+集群中以 Region 作为数据复制和数据管理的单元,Region 的状态和分布对于系统运维和测试有很大帮助,如以下场景:
+
+- 查看集群中各个 Region 被分配到了哪些 DataNode,是否均衡
+
+当前 IoTDB 支持使用如下 SQL 查看Region:
+
+- `SHOW REGIONS`: 展示所有 Region
+- `SHOW SCHEMA REGIONS`: 展示所有 SchemaRegion 分布
+- `SHOW DATA REGIONS`: 展示所有 DataRegion 分布
+
+```sql
+IoTDB> show regions
++--------+------------+------+-------------+-----+----------+----------+----+
+|RegionId|        Type|Status|storage group|Slots|DataNodeId|HostAdress|Port|
++--------+------------+------+-------------+-----+----------+----------+----+
+|       5|  DataRegion|    Up|      root.sg|    1|         2| 127.0.0.1|6671|

Review Comment:
   fixed~



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] qiaojialin merged pull request #6315: [IOTDB-3511] Show Region tool

Posted by GitBox <gi...@apache.org>.
qiaojialin merged PR #6315:
URL: https://github.com/apache/iotdb/pull/6315


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] CRZbulabula commented on a diff in pull request #6315: [IOTDB-3511] Show Region tool

Posted by GitBox <gi...@apache.org>.
CRZbulabula commented on code in PR #6315:
URL: https://github.com/apache/iotdb/pull/6315#discussion_r899032011


##########
thrift-confignode/src/main/thrift/confignode.thrift:
##########
@@ -229,6 +229,27 @@ struct TDropFunctionReq {
   1: required string udfName
 }
 
+// show regions
+struct TShowRegionReq {
+  1: optional i32 regionType;
+}
+
+struct TRegionInfos {

Review Comment:
   Rename to **TRegionLocation** to be consistent with TConfigNodeLocation and TDataNodeLocation



##########
server/src/test/resources/datanode4conf/iotdb-engine.properties:
##########
@@ -0,0 +1,38 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+rpc_address=0.0.0.0

Review Comment:
   What is this file for?



##########
confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/PartitionInfo.java:
##########
@@ -685,6 +691,62 @@ public void processLoadSnapshot(File snapshotDir) throws TException, IOException
     }
   }
 
+  public DataSet getRegionInfos(GetRegionsInfoReq regionsInfoReq) {

Review Comment:
   Add function java doc and move this interface to the _Consensus read/write interfaces_ block(search this annotation).



##########
confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/read/GetRegionsInfoReq.java:
##########
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.confignode.consensus.request.read;
+
+import org.apache.iotdb.confignode.consensus.request.ConfigRequest;
+import org.apache.iotdb.confignode.consensus.request.ConfigRequestType;
+import org.apache.iotdb.tsfile.utils.ReadWriteIOUtils;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+public class GetRegionsInfoReq extends ConfigRequest {

Review Comment:
   Rename to GetRegionLocationsReq, since the word _info_ is used in persistence module.



##########
server/src/test/resources/datanode4conf/logback.xml:
##########
@@ -0,0 +1,302 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+-->
+<configuration scan="true" scanPeriod="60 seconds">

Review Comment:
   What is this file for?



##########
confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/read/GetRegionsInfoReq.java:
##########
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.confignode.consensus.request.read;
+
+import org.apache.iotdb.confignode.consensus.request.ConfigRequest;
+import org.apache.iotdb.confignode.consensus.request.ConfigRequestType;
+import org.apache.iotdb.tsfile.utils.ReadWriteIOUtils;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+public class GetRegionsInfoReq extends ConfigRequest {
+
+  private int regionType;
+
+  public GetRegionsInfoReq() {
+    super(ConfigRequestType.GetRegionsInfo);
+  }
+
+  public GetRegionsInfoReq(int regionType) {
+    super(ConfigRequestType.GetRegionsInfo);
+    this.regionType = regionType;
+  }
+
+  public int getRegionType() {
+    return regionType;
+  }
+
+  public void setRegionType(int regionType) {
+    this.regionType = regionType;
+  }
+
+  @Override
+  protected void serializeImpl(DataOutputStream stream) throws IOException {
+    stream.writeInt(getType().ordinal());
+    ReadWriteIOUtils.write(regionType, stream);
+  }
+
+  @Override
+  protected void deserializeImpl(ByteBuffer buffer) throws IOException {
+    regionType = ReadWriteIOUtils.readInt(buffer);
+  }
+}

Review Comment:
   Add another test in **ConfigRequestSerDeTest**



##########
thrift-confignode/src/main/thrift/confignode.thrift:
##########
@@ -229,6 +229,27 @@ struct TDropFunctionReq {
   1: required string udfName
 }
 
+// show regions
+struct TShowRegionReq {
+  1: optional i32 regionType;
+}
+
+struct TRegionInfos {
+  1: required i32 regionId;
+  2: required i32 regionType;
+  3: required string storageGroup
+  4: required list<i32> dataNodeId;
+  5: required list<string> rpcAddresss;
+  6: required list<i32> rpcPort;
+  7: required i32 slots;

Review Comment:
   Type should be i64



##########
confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/PartitionInfo.java:
##########
@@ -685,6 +691,62 @@ public void processLoadSnapshot(File snapshotDir) throws TException, IOException
     }
   }
 
+  public DataSet getRegionInfos(GetRegionsInfoReq regionsInfoReq) {
+    RegionsInfoResp regionResp = new RegionsInfoResp();
+    List<TRegionInfos> tRegionInfosList = new ArrayList<>();
+    if (storageGroupPartitionTables.isEmpty()) {
+      regionResp.setStatus(RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS));
+      return regionResp;
+    }
+    storageGroupPartitionTables.forEach(
+        (storageGroup, storageGroupPartitionTable) ->
+            storageGroupPartitionTable
+                .getRegionInfoMap()
+                .forEach(
+                    (consensusGroupId, regionInfoMap) -> {
+                      TRegionReplicaSet replicaSet = regionInfoMap.getReplicaSet();
+                      if (replicaSet.getRegionId().getType().ordinal()
+                          == regionsInfoReq.getRegionType()) {
+                        buildTRegionsInfo(
+                            tRegionInfosList, storageGroup, replicaSet, regionInfoMap);
+                      }
+                      if (regionsInfoReq.getRegionType() == -1) {
+                        buildTRegionsInfo(
+                            tRegionInfosList, storageGroup, replicaSet, regionInfoMap);
+                      }
+                    }));
+    regionResp.setRegionInfosList(tRegionInfosList);
+    regionResp.setStatus(RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS));
+    return regionResp;
+  }
+
+  private void buildTRegionsInfo(
+      List<TRegionInfos> tRegionInfosList,
+      String storageGroup,
+      TRegionReplicaSet replicaSet,
+      RegionGroup regionInfoMap) {
+    List<Integer> dataNodeIdList = null;
+    List<String> rpcAddressList = null;
+    List<Integer> rpcPortList = null;
+    TRegionInfos tRegionInfos = new TRegionInfos();
+    tRegionInfos.setRegionId(replicaSet.getRegionId().getId());
+    tRegionInfos.setRegionType(replicaSet.getRegionId().getType().getValue());
+    tRegionInfos.setStorageGroup(storageGroup);
+    long slots = regionInfoMap.getCounter();
+    tRegionInfos.setSlots((int) slots);
+    for (TDataNodeLocation dataNodeLocation : replicaSet.getDataNodeLocations()) {
+      dataNodeIdList = Arrays.asList(dataNodeLocation.getDataNodeId());
+      rpcAddressList = Arrays.asList(dataNodeLocation.getExternalEndPoint().getIp());
+      rpcPortList = Arrays.asList(dataNodeLocation.getExternalEndPoint().getPort());
+    }
+    tRegionInfos.setDataNodeId(dataNodeIdList);
+    tRegionInfos.setRpcAddresss(rpcAddressList);
+    tRegionInfos.setRpcPort(rpcPortList);
+    // TODO: Wait for data migration. And then add the state
+    tRegionInfos.setStatus("Up");

Review Comment:
   Create a enum class **RegionStatus** in package org.apache.iotdb.commons.cluster like NodeStatus



##########
thrift-confignode/src/main/thrift/confignode.thrift:
##########
@@ -229,6 +229,27 @@ struct TDropFunctionReq {
   1: required string udfName
 }
 
+// show regions
+struct TShowRegionReq {
+  1: optional i32 regionType;
+}
+
+struct TRegionInfos {
+  1: required i32 regionId;
+  2: required i32 regionType;
+  3: required string storageGroup
+  4: required list<i32> dataNodeId;
+  5: required list<string> rpcAddresss;
+  6: required list<i32> rpcPort;

Review Comment:
   This three fields probably don't need to use _list_. Since we can specify the replication factor at will, each TRegionInfo represents a Region's information is enough.



##########
confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/PartitionInfo.java:
##########
@@ -685,6 +691,62 @@ public void processLoadSnapshot(File snapshotDir) throws TException, IOException
     }
   }
 
+  public DataSet getRegionInfos(GetRegionsInfoReq regionsInfoReq) {
+    RegionsInfoResp regionResp = new RegionsInfoResp();
+    List<TRegionInfos> tRegionInfosList = new ArrayList<>();
+    if (storageGroupPartitionTables.isEmpty()) {
+      regionResp.setStatus(RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS));
+      return regionResp;
+    }
+    storageGroupPartitionTables.forEach(
+        (storageGroup, storageGroupPartitionTable) ->
+            storageGroupPartitionTable
+                .getRegionInfoMap()
+                .forEach(
+                    (consensusGroupId, regionInfoMap) -> {
+                      TRegionReplicaSet replicaSet = regionInfoMap.getReplicaSet();
+                      if (replicaSet.getRegionId().getType().ordinal()
+                          == regionsInfoReq.getRegionType()) {
+                        buildTRegionsInfo(
+                            tRegionInfosList, storageGroup, replicaSet, regionInfoMap);
+                      }
+                      if (regionsInfoReq.getRegionType() == -1) {
+                        buildTRegionsInfo(
+                            tRegionInfosList, storageGroup, replicaSet, regionInfoMap);
+                      }
+                    }));
+    regionResp.setRegionInfosList(tRegionInfosList);
+    regionResp.setStatus(RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS));
+    return regionResp;
+  }
+
+  private void buildTRegionsInfo(
+      List<TRegionInfos> tRegionInfosList,
+      String storageGroup,
+      TRegionReplicaSet replicaSet,
+      RegionGroup regionInfoMap) {

Review Comment:
   Move this interface into **StorageGroupPartitionTable**, otherwise the PartitionInfo will soon be too interminable to maintain.



##########
confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/read/GetRegionsInfoReq.java:
##########
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.confignode.consensus.request.read;
+
+import org.apache.iotdb.confignode.consensus.request.ConfigRequest;
+import org.apache.iotdb.confignode.consensus.request.ConfigRequestType;
+import org.apache.iotdb.tsfile.utils.ReadWriteIOUtils;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+public class GetRegionsInfoReq extends ConfigRequest {
+
+  private int regionType;

Review Comment:
   Perhaps this field could use the **TConsensusType type**, with _PartitionRegion_ represents to read all Regions.



##########
confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/ConfigRequestType.java:
##########
@@ -61,5 +61,6 @@ public enum ConfigRequestType {
   ApplyConfigNode,
   CreateFunction,
   DropFunction,
-  GetNodePathsPartition;
+  GetNodePathsPartition,
+  GetRegionsInfo;

Review Comment:
   GetRegionLocations



##########
confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/PartitionInfo.java:
##########
@@ -685,6 +691,62 @@ public void processLoadSnapshot(File snapshotDir) throws TException, IOException
     }
   }
 
+  public DataSet getRegionInfos(GetRegionsInfoReq regionsInfoReq) {
+    RegionsInfoResp regionResp = new RegionsInfoResp();
+    List<TRegionInfos> tRegionInfosList = new ArrayList<>();
+    if (storageGroupPartitionTables.isEmpty()) {
+      regionResp.setStatus(RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS));
+      return regionResp;
+    }
+    storageGroupPartitionTables.forEach(
+        (storageGroup, storageGroupPartitionTable) ->
+            storageGroupPartitionTable
+                .getRegionInfoMap()
+                .forEach(
+                    (consensusGroupId, regionInfoMap) -> {
+                      TRegionReplicaSet replicaSet = regionInfoMap.getReplicaSet();
+                      if (replicaSet.getRegionId().getType().ordinal()
+                          == regionsInfoReq.getRegionType()) {
+                        buildTRegionsInfo(
+                            tRegionInfosList, storageGroup, replicaSet, regionInfoMap);
+                      }
+                      if (regionsInfoReq.getRegionType() == -1) {
+                        buildTRegionsInfo(
+                            tRegionInfosList, storageGroup, replicaSet, regionInfoMap);
+                      }
+                    }));
+    regionResp.setRegionInfosList(tRegionInfosList);
+    regionResp.setStatus(RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS));
+    return regionResp;
+  }
+
+  private void buildTRegionsInfo(
+      List<TRegionInfos> tRegionInfosList,
+      String storageGroup,
+      TRegionReplicaSet replicaSet,
+      RegionGroup regionInfoMap) {
+    List<Integer> dataNodeIdList = null;
+    List<String> rpcAddressList = null;
+    List<Integer> rpcPortList = null;
+    TRegionInfos tRegionInfos = new TRegionInfos();
+    tRegionInfos.setRegionId(replicaSet.getRegionId().getId());
+    tRegionInfos.setRegionType(replicaSet.getRegionId().getType().getValue());
+    tRegionInfos.setStorageGroup(storageGroup);
+    long slots = regionInfoMap.getCounter();
+    tRegionInfos.setSlots((int) slots);
+    for (TDataNodeLocation dataNodeLocation : replicaSet.getDataNodeLocations()) {
+      dataNodeIdList = Arrays.asList(dataNodeLocation.getDataNodeId());
+      rpcAddressList = Arrays.asList(dataNodeLocation.getExternalEndPoint().getIp());
+      rpcPortList = Arrays.asList(dataNodeLocation.getExternalEndPoint().getPort());
+    }

Review Comment:
   This code block discrads other RegionReplicas?



##########
confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/PartitionInfo.java:
##########
@@ -685,6 +691,62 @@ public void processLoadSnapshot(File snapshotDir) throws TException, IOException
     }
   }
 
+  public DataSet getRegionInfos(GetRegionsInfoReq regionsInfoReq) {
+    RegionsInfoResp regionResp = new RegionsInfoResp();
+    List<TRegionInfos> tRegionInfosList = new ArrayList<>();
+    if (storageGroupPartitionTables.isEmpty()) {
+      regionResp.setStatus(RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS));
+      return regionResp;
+    }
+    storageGroupPartitionTables.forEach(
+        (storageGroup, storageGroupPartitionTable) ->
+            storageGroupPartitionTable
+                .getRegionInfoMap()
+                .forEach(
+                    (consensusGroupId, regionInfoMap) -> {
+                      TRegionReplicaSet replicaSet = regionInfoMap.getReplicaSet();
+                      if (replicaSet.getRegionId().getType().ordinal()
+                          == regionsInfoReq.getRegionType()) {
+                        buildTRegionsInfo(
+                            tRegionInfosList, storageGroup, replicaSet, regionInfoMap);
+                      }
+                      if (regionsInfoReq.getRegionType() == -1) {
+                        buildTRegionsInfo(
+                            tRegionInfosList, storageGroup, replicaSet, regionInfoMap);
+                      }
+                    }));

Review Comment:
   Move this code block into **StorageGroupPartitionTable**, otherwise the PartitionInfo will soon be too interminable to maintain.



##########
server/src/test/resources/datanode4conf/iotdb-metric.yml:
##########
@@ -0,0 +1,53 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+# whether enable the module

Review Comment:
   What is this file for?



##########
confignode/src/main/java/org/apache/iotdb/confignode/consensus/response/RegionsInfoResp.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.confignode.consensus.response;
+
+import org.apache.iotdb.common.rpc.thrift.TSStatus;
+import org.apache.iotdb.confignode.rpc.thrift.TRegionInfos;
+import org.apache.iotdb.consensus.common.DataSet;
+
+import java.util.List;
+
+public class RegionsInfoResp implements DataSet {

Review Comment:
   Rename to RegionLocationsResp, since the word _info_ is used in persistence module.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] RYH61 commented on a diff in pull request #6315: [IOTDB-3511] Show Region tool

Posted by GitBox <gi...@apache.org>.
RYH61 commented on code in PR #6315:
URL: https://github.com/apache/iotdb/pull/6315#discussion_r899230576


##########
confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/PartitionInfo.java:
##########
@@ -685,6 +691,62 @@ public void processLoadSnapshot(File snapshotDir) throws TException, IOException
     }
   }
 
+  public DataSet getRegionInfos(GetRegionsInfoReq regionsInfoReq) {
+    RegionsInfoResp regionResp = new RegionsInfoResp();
+    List<TRegionInfos> tRegionInfosList = new ArrayList<>();
+    if (storageGroupPartitionTables.isEmpty()) {
+      regionResp.setStatus(RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS));
+      return regionResp;
+    }
+    storageGroupPartitionTables.forEach(
+        (storageGroup, storageGroupPartitionTable) ->
+            storageGroupPartitionTable
+                .getRegionInfoMap()
+                .forEach(
+                    (consensusGroupId, regionInfoMap) -> {
+                      TRegionReplicaSet replicaSet = regionInfoMap.getReplicaSet();
+                      if (replicaSet.getRegionId().getType().ordinal()
+                          == regionsInfoReq.getRegionType()) {
+                        buildTRegionsInfo(
+                            tRegionInfosList, storageGroup, replicaSet, regionInfoMap);
+                      }
+                      if (regionsInfoReq.getRegionType() == -1) {
+                        buildTRegionsInfo(
+                            tRegionInfosList, storageGroup, replicaSet, regionInfoMap);
+                      }
+                    }));

Review Comment:
   fixed~



##########
confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/PartitionInfo.java:
##########
@@ -685,6 +691,62 @@ public void processLoadSnapshot(File snapshotDir) throws TException, IOException
     }
   }
 
+  public DataSet getRegionInfos(GetRegionsInfoReq regionsInfoReq) {
+    RegionsInfoResp regionResp = new RegionsInfoResp();
+    List<TRegionInfos> tRegionInfosList = new ArrayList<>();
+    if (storageGroupPartitionTables.isEmpty()) {
+      regionResp.setStatus(RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS));
+      return regionResp;
+    }
+    storageGroupPartitionTables.forEach(
+        (storageGroup, storageGroupPartitionTable) ->
+            storageGroupPartitionTable
+                .getRegionInfoMap()
+                .forEach(
+                    (consensusGroupId, regionInfoMap) -> {
+                      TRegionReplicaSet replicaSet = regionInfoMap.getReplicaSet();
+                      if (replicaSet.getRegionId().getType().ordinal()
+                          == regionsInfoReq.getRegionType()) {
+                        buildTRegionsInfo(
+                            tRegionInfosList, storageGroup, replicaSet, regionInfoMap);
+                      }
+                      if (regionsInfoReq.getRegionType() == -1) {
+                        buildTRegionsInfo(
+                            tRegionInfosList, storageGroup, replicaSet, regionInfoMap);
+                      }
+                    }));
+    regionResp.setRegionInfosList(tRegionInfosList);
+    regionResp.setStatus(RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS));
+    return regionResp;
+  }
+
+  private void buildTRegionsInfo(
+      List<TRegionInfos> tRegionInfosList,
+      String storageGroup,
+      TRegionReplicaSet replicaSet,
+      RegionGroup regionInfoMap) {
+    List<Integer> dataNodeIdList = null;
+    List<String> rpcAddressList = null;
+    List<Integer> rpcPortList = null;
+    TRegionInfos tRegionInfos = new TRegionInfos();
+    tRegionInfos.setRegionId(replicaSet.getRegionId().getId());
+    tRegionInfos.setRegionType(replicaSet.getRegionId().getType().getValue());
+    tRegionInfos.setStorageGroup(storageGroup);
+    long slots = regionInfoMap.getCounter();
+    tRegionInfos.setSlots((int) slots);
+    for (TDataNodeLocation dataNodeLocation : replicaSet.getDataNodeLocations()) {
+      dataNodeIdList = Arrays.asList(dataNodeLocation.getDataNodeId());
+      rpcAddressList = Arrays.asList(dataNodeLocation.getExternalEndPoint().getIp());
+      rpcPortList = Arrays.asList(dataNodeLocation.getExternalEndPoint().getPort());
+    }
+    tRegionInfos.setDataNodeId(dataNodeIdList);
+    tRegionInfos.setRpcAddresss(rpcAddressList);
+    tRegionInfos.setRpcPort(rpcPortList);
+    // TODO: Wait for data migration. And then add the state
+    tRegionInfos.setStatus("Up");

Review Comment:
   fixed~



##########
confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/PartitionInfo.java:
##########
@@ -685,6 +691,62 @@ public void processLoadSnapshot(File snapshotDir) throws TException, IOException
     }
   }
 
+  public DataSet getRegionInfos(GetRegionsInfoReq regionsInfoReq) {

Review Comment:
   fixed~



##########
server/src/test/resources/datanode4conf/iotdb-engine.properties:
##########
@@ -0,0 +1,38 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+rpc_address=0.0.0.0

Review Comment:
   fixed~



##########
server/src/test/resources/datanode4conf/logback.xml:
##########
@@ -0,0 +1,302 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+-->
+<configuration scan="true" scanPeriod="60 seconds">

Review Comment:
   fixed~



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org