This is an automated email from the ASF dual-hosted git repository.
jackietien 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 f6b2d07a61b Added nodes/config_nodes/data_nodes table for
information_schema & Fixed the header of show ainodes
f6b2d07a61b is described below
commit f6b2d07a61b424a06744e52c0b693badb99d114e
Author: Caideyipi <[email protected]>
AuthorDate: Thu May 29 11:40:52 2025 +0800
Added nodes/config_nodes/data_nodes table for information_schema & Fixed
the header of show ainodes
---
.../org/apache/iotdb/ainode/it/AINodeBasicIT.java | 2 +-
.../relational/it/schema/IoTDBDatabaseIT.java | 62 ++++++-
.../iotdb/confignode/manager/ConfigManager.java | 29 ++++
.../apache/iotdb/confignode/manager/IManager.java | 8 +
.../iotdb/confignode/manager/node/NodeManager.java | 88 ++++++++++
.../thrift/ConfigNodeRPCServiceProcessor.java | 12 ++
.../iotdb/db/protocol/client/ConfigNodeClient.java | 17 ++
.../InformationSchemaContentSupplierFactory.java | 182 +++++++++++++++++++++
.../DataNodeLocationSupplierFactory.java | 3 +
.../schema/column/ColumnHeaderConstant.java | 17 +-
.../commons/schema/table/InformationSchema.java | 61 +++++++
.../src/main/thrift/confignode.thrift | 37 ++++-
12 files changed, 512 insertions(+), 6 deletions(-)
diff --git
a/integration-test/src/test/java/org/apache/iotdb/ainode/it/AINodeBasicIT.java
b/integration-test/src/test/java/org/apache/iotdb/ainode/it/AINodeBasicIT.java
index d6c37023b5d..b503d67f814 100644
---
a/integration-test/src/test/java/org/apache/iotdb/ainode/it/AINodeBasicIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/ainode/it/AINodeBasicIT.java
@@ -107,7 +107,7 @@ public class AINodeBasicIT {
@Test
public void aiNodeConnectionTest() {
String sql = "SHOW AINODES";
- String title = "NodeID,Status,RpcAddress,RpcPort";
+ String title = "NodeID,Status,InternalAddress,InternalPort";
try (Connection connection = EnvFactory.getEnv().getConnection();
Statement statement = connection.createStatement()) {
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBDatabaseIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBDatabaseIT.java
index 7d5cda960fa..82e597e6db9 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBDatabaseIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBDatabaseIT.java
@@ -394,7 +394,10 @@ public class IoTDBDatabaseIT {
"models,INF,",
"functions,INF,",
"configurations,INF,",
- "keywords,INF,")));
+ "keywords,INF,",
+ "nodes,INF,",
+ "config_nodes,INF,",
+ "data_nodes,INF,")));
TestUtils.assertResultSetEqual(
statement.executeQuery("desc databases"),
@@ -513,6 +516,39 @@ public class IoTDBDatabaseIT {
statement.executeQuery("desc keywords"),
"ColumnName,DataType,Category,",
new HashSet<>(Arrays.asList("word,STRING,TAG,",
"reserved,INT32,ATTRIBUTE,")));
+ TestUtils.assertResultSetEqual(
+ statement.executeQuery("desc nodes"),
+ "ColumnName,DataType,Category,",
+ new HashSet<>(
+ Arrays.asList(
+ "node_id,INT32,TAG,",
+ "node_type,STRING,ATTRIBUTE,",
+ "status,STRING,ATTRIBUTE,",
+ "internal_address,STRING,ATTRIBUTE,",
+ "internal_port,INT32,ATTRIBUTE,",
+ "version,STRING,ATTRIBUTE,",
+ "build_info,STRING,ATTRIBUTE,")));
+ TestUtils.assertResultSetEqual(
+ statement.executeQuery("desc config_nodes"),
+ "ColumnName,DataType,Category,",
+ new HashSet<>(
+ Arrays.asList(
+ "node_id,INT32,TAG,",
+ "config_consensus_port,INT32,ATTRIBUTE,",
+ "role,STRING,ATTRIBUTE,")));
+ TestUtils.assertResultSetEqual(
+ statement.executeQuery("desc data_nodes"),
+ "ColumnName,DataType,Category,",
+ new HashSet<>(
+ Arrays.asList(
+ "node_id,INT32,TAG,",
+ "data_region_num,INT32,ATTRIBUTE,",
+ "schema_region_num,INT32,ATTRIBUTE,",
+ "rpc_address,STRING,ATTRIBUTE,",
+ "rpc_port,INT32,ATTRIBUTE,",
+ "mpp_port,INT32,ATTRIBUTE,",
+ "data_consensus_port,INT32,ATTRIBUTE,",
+ "schema_consensus_port,INT32,ATTRIBUTE,")));
// Only root user is allowed
Assert.assertThrows(SQLException.class, () -> statement.execute("select
* from regions"));
@@ -522,6 +558,10 @@ public class IoTDBDatabaseIT {
SQLException.class, () -> statement.execute("select * from
subscriptions"));
Assert.assertThrows(
SQLException.class, () -> statement.execute("select * from
configurations"));
+ Assert.assertThrows(SQLException.class, () -> statement.execute("select
* from nodes"));
+ Assert.assertThrows(
+ SQLException.class, () -> statement.execute("select * from
config_nodes"));
+ Assert.assertThrows(SQLException.class, () -> statement.execute("select
* from data_nodes"));
// No auth needed
TestUtils.assertResultSetEqual(
@@ -599,12 +639,15 @@ public class IoTDBDatabaseIT {
"information_schema,functions,INF,USING,null,SYSTEM VIEW,",
"information_schema,configurations,INF,USING,null,SYSTEM
VIEW,",
"information_schema,keywords,INF,USING,null,SYSTEM VIEW,",
+ "information_schema,nodes,INF,USING,null,SYSTEM VIEW,",
+ "information_schema,config_nodes,INF,USING,null,SYSTEM
VIEW,",
+ "information_schema,data_nodes,INF,USING,null,SYSTEM VIEW,",
"test,test,INF,USING,test,BASE TABLE,",
"test,view_table,100,USING,null,VIEW FROM TREE,")));
TestUtils.assertResultSetEqual(
statement.executeQuery("count devices from tables where status =
'USING'"),
"count(devices),",
- Collections.singleton("16,"));
+ Collections.singleton("19,"));
TestUtils.assertResultSetEqual(
statement.executeQuery(
"select * from columns where table_name = 'queries' or database
= 'test'"),
@@ -687,6 +730,21 @@ public class IoTDBDatabaseIT {
"select * from information_schema.keywords where reserved > 0
limit 1"),
"word,reserved,",
Collections.singleton("AINODES,1,"));
+
+ TestUtils.assertResultSetEqual(
+ statement.executeQuery("select distinct(status) from
information_schema.nodes"),
+ "status,",
+ Collections.singleton("Running,"));
+
+ TestUtils.assertResultSetEqual(
+ statement.executeQuery("select count(*) from
information_schema.config_nodes"),
+ "_col0,",
+
Collections.singleton(EnvFactory.getEnv().getConfigNodeWrapperList().size() +
","));
+
+ TestUtils.assertResultSetEqual(
+ statement.executeQuery("select data_region_num from
information_schema.data_nodes"),
+ "data_region_num,",
+ Collections.singleton("0,"));
}
}
diff --git
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java
index 509960d3196..cbd67795774 100644
---
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java
+++
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java
@@ -224,7 +224,9 @@ import
org.apache.iotdb.confignode.rpc.thrift.TSetSchemaTemplateReq;
import org.apache.iotdb.confignode.rpc.thrift.TShowAINodesResp;
import org.apache.iotdb.confignode.rpc.thrift.TShowCQResp;
import org.apache.iotdb.confignode.rpc.thrift.TShowClusterResp;
+import
org.apache.iotdb.confignode.rpc.thrift.TShowConfigNodes4InformationSchemaResp;
import org.apache.iotdb.confignode.rpc.thrift.TShowConfigNodesResp;
+import
org.apache.iotdb.confignode.rpc.thrift.TShowDataNodes4InformationSchemaResp;
import org.apache.iotdb.confignode.rpc.thrift.TShowDataNodesResp;
import org.apache.iotdb.confignode.rpc.thrift.TShowDatabaseResp;
import org.apache.iotdb.confignode.rpc.thrift.TShowModelReq;
@@ -1887,6 +1889,19 @@ public class ConfigManager implements IManager {
}
}
+ @Override
+ public TShowDataNodes4InformationSchemaResp
showDataNodes4InformationSchema() {
+ final TSStatus status = confirmLeader();
+ final TShowDataNodes4InformationSchemaResp resp = new
TShowDataNodes4InformationSchemaResp();
+ if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
+ return resp.setDataNodesInfoList(
+ nodeManager.getRegisteredDataNodeInfoList4InformationSchema())
+ .setStatus(StatusUtils.OK);
+ } else {
+ return resp.setStatus(status);
+ }
+ }
+
@Override
public TShowConfigNodesResp showConfigNodes() {
TSStatus status = confirmLeader();
@@ -1899,6 +1914,20 @@ public class ConfigManager implements IManager {
}
}
+ @Override
+ public TShowConfigNodes4InformationSchemaResp
showConfigNodes4InformationSchema() {
+ final TSStatus status = confirmLeader();
+ final TShowConfigNodes4InformationSchemaResp resp =
+ new TShowConfigNodes4InformationSchemaResp();
+ if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
+ return resp.setConfigNodesInfoList(
+ nodeManager.getRegisteredConfigNodeInfo4InformationSchema())
+ .setStatus(StatusUtils.OK);
+ } else {
+ return resp.setStatus(status);
+ }
+ }
+
@Override
public TShowDatabaseResp showDatabase(final TGetDatabaseReq req) {
final TSStatus status = confirmLeader();
diff --git
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/IManager.java
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/IManager.java
index 2e4a0a3cd89..db5cbe11e00 100644
---
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/IManager.java
+++
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/IManager.java
@@ -138,7 +138,9 @@ import
org.apache.iotdb.confignode.rpc.thrift.TSetSchemaTemplateReq;
import org.apache.iotdb.confignode.rpc.thrift.TShowAINodesResp;
import org.apache.iotdb.confignode.rpc.thrift.TShowCQResp;
import org.apache.iotdb.confignode.rpc.thrift.TShowClusterResp;
+import
org.apache.iotdb.confignode.rpc.thrift.TShowConfigNodes4InformationSchemaResp;
import org.apache.iotdb.confignode.rpc.thrift.TShowConfigNodesResp;
+import
org.apache.iotdb.confignode.rpc.thrift.TShowDataNodes4InformationSchemaResp;
import org.apache.iotdb.confignode.rpc.thrift.TShowDataNodesResp;
import org.apache.iotdb.confignode.rpc.thrift.TShowDatabaseResp;
import org.apache.iotdb.confignode.rpc.thrift.TShowModelReq;
@@ -627,9 +629,15 @@ public interface IManager {
/** Show DataNodes. */
TShowDataNodesResp showDataNodes();
+ /** Show DataNodes for information schema. */
+ TShowDataNodes4InformationSchemaResp showDataNodes4InformationSchema();
+
/** Show ConfigNodes. */
TShowConfigNodesResp showConfigNodes();
+ /** Show ConfigNodes for information schema. */
+ TShowConfigNodes4InformationSchemaResp showConfigNodes4InformationSchema();
+
/**
* Show StorageGroup.
*
diff --git
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java
index cd492cf8457..2c69a78b2d9 100644
---
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java
+++
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java
@@ -81,9 +81,11 @@ import
org.apache.iotdb.confignode.rpc.thrift.TAINodeRestartReq;
import org.apache.iotdb.confignode.rpc.thrift.TAINodeRestartResp;
import org.apache.iotdb.confignode.rpc.thrift.TCQConfig;
import org.apache.iotdb.confignode.rpc.thrift.TConfigNodeInfo;
+import
org.apache.iotdb.confignode.rpc.thrift.TConfigNodeInfo4InformationSchema;
import org.apache.iotdb.confignode.rpc.thrift.TConfigNodeRegisterReq;
import org.apache.iotdb.confignode.rpc.thrift.TConfigNodeRegisterResp;
import org.apache.iotdb.confignode.rpc.thrift.TDataNodeInfo;
+import org.apache.iotdb.confignode.rpc.thrift.TDataNodeInfo4InformationSchema;
import org.apache.iotdb.confignode.rpc.thrift.TDataNodeRegisterReq;
import org.apache.iotdb.confignode.rpc.thrift.TDataNodeRestartReq;
import org.apache.iotdb.confignode.rpc.thrift.TDataNodeRestartResp;
@@ -736,6 +738,70 @@ public class NodeManager {
return dataNodeInfoList;
}
+ public List<TDataNodeInfo4InformationSchema>
getRegisteredDataNodeInfoList4InformationSchema() {
+ final List<TDataNodeInfo4InformationSchema> dataNodeInfoList = new
ArrayList<>();
+ final List<TDataNodeConfiguration> registeredDataNodes =
this.getRegisteredDataNodes();
+ if (registeredDataNodes != null) {
+ registeredDataNodes.forEach(
+ registeredDataNode -> {
+ TDataNodeInfo4InformationSchema dataNodeInfo = new
TDataNodeInfo4InformationSchema();
+ int dataNodeId = registeredDataNode.getLocation().getDataNodeId();
+ dataNodeInfo.setDataNodeId(dataNodeId);
+ dataNodeInfo.setRpcAddress(
+
registeredDataNode.getLocation().getClientRpcEndPoint().getIp());
+ dataNodeInfo.setRpcPort(
+
registeredDataNode.getLocation().getClientRpcEndPoint().getPort());
+ dataNodeInfo.setDataRegionNum(0);
+ dataNodeInfo.setSchemaRegionNum(0);
+ dataNodeInfo.setMppPort(
+
registeredDataNode.getLocation().getMPPDataExchangeEndPoint().getPort());
+ dataNodeInfo.setDataConsensusPort(
+
registeredDataNode.getLocation().getDataRegionConsensusEndPoint().getPort());
+ dataNodeInfo.setSchemaConsensusPort(
+
registeredDataNode.getLocation().getSchemaRegionConsensusEndPoint().getPort());
+ dataNodeInfoList.add(dataNodeInfo);
+ });
+ }
+
+ // Map<DataNodeId, DataRegionNum>
+ final Map<Integer, AtomicInteger> dataRegionNumMap = new HashMap<>();
+ // Map<DataNodeId, SchemaRegionNum>
+ final Map<Integer, AtomicInteger> schemaRegionNumMap = new HashMap<>();
+ final List<TRegionReplicaSet> regionReplicaSets =
getPartitionManager().getAllReplicaSets();
+ regionReplicaSets.forEach(
+ regionReplicaSet ->
+ regionReplicaSet
+ .getDataNodeLocations()
+ .forEach(
+ dataNodeLocation -> {
+ switch (regionReplicaSet.getRegionId().getType()) {
+ case SchemaRegion:
+ schemaRegionNumMap
+ .computeIfAbsent(
+ dataNodeLocation.getDataNodeId(), key -> new
AtomicInteger())
+ .getAndIncrement();
+ break;
+ case DataRegion:
+ default:
+ dataRegionNumMap
+ .computeIfAbsent(
+ dataNodeLocation.getDataNodeId(), key -> new
AtomicInteger())
+ .getAndIncrement();
+ }
+ }));
+ final AtomicInteger zero = new AtomicInteger(0);
+ dataNodeInfoList.forEach(
+ (dataNodesInfo -> {
+ dataNodesInfo.setSchemaRegionNum(
+ schemaRegionNumMap.getOrDefault(dataNodesInfo.getDataNodeId(),
zero).get());
+ dataNodesInfo.setDataRegionNum(
+ dataRegionNumMap.getOrDefault(dataNodesInfo.getDataNodeId(),
zero).get());
+ }));
+
+
dataNodeInfoList.sort(Comparator.comparingInt(TDataNodeInfo4InformationSchema::getDataNodeId));
+ return dataNodeInfoList;
+ }
+
public int getDataNodeCpuCoreCount() {
return nodeInfo.getDataNodeTotalCpuCoreCount();
}
@@ -771,6 +837,28 @@ public class NodeManager {
return configNodeInfoList;
}
+ public List<TConfigNodeInfo4InformationSchema>
getRegisteredConfigNodeInfo4InformationSchema() {
+ final List<TConfigNodeInfo4InformationSchema> configNodeInfoList = new
ArrayList<>();
+ final List<TConfigNodeLocation> registeredConfigNodes =
this.getRegisteredConfigNodes();
+ if (registeredConfigNodes != null) {
+ registeredConfigNodes.forEach(
+ configNodeLocation -> {
+ final TConfigNodeInfo4InformationSchema info = new
TConfigNodeInfo4InformationSchema();
+ final int configNodeId = configNodeLocation.getConfigNodeId();
+ info.setConfigNodeId(configNodeId);
+
info.setConsensusPort(configNodeLocation.getConsensusEndPoint().getPort());
+ info.setRoleType(
+ configNodeLocation.getConfigNodeId() ==
ConfigNodeHeartbeatCache.CURRENT_NODE_ID
+ ? RegionRoleType.Leader.name()
+ : RegionRoleType.Follower.name());
+ configNodeInfoList.add(info);
+ });
+ }
+ configNodeInfoList.sort(
+
Comparator.comparingInt(TConfigNodeInfo4InformationSchema::getConfigNodeId));
+ return configNodeInfoList;
+ }
+
/**
* Only leader use this interface, record the new ConfigNode's information.
*
diff --git
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java
index 4f5bdfb482b..af8e7e593b4 100644
---
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java
+++
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java
@@ -193,7 +193,9 @@ import
org.apache.iotdb.confignode.rpc.thrift.TSetTimePartitionIntervalReq;
import org.apache.iotdb.confignode.rpc.thrift.TShowAINodesResp;
import org.apache.iotdb.confignode.rpc.thrift.TShowCQResp;
import org.apache.iotdb.confignode.rpc.thrift.TShowClusterResp;
+import
org.apache.iotdb.confignode.rpc.thrift.TShowConfigNodes4InformationSchemaResp;
import org.apache.iotdb.confignode.rpc.thrift.TShowConfigNodesResp;
+import
org.apache.iotdb.confignode.rpc.thrift.TShowDataNodes4InformationSchemaResp;
import org.apache.iotdb.confignode.rpc.thrift.TShowDataNodesResp;
import org.apache.iotdb.confignode.rpc.thrift.TShowDatabaseResp;
import org.apache.iotdb.confignode.rpc.thrift.TShowModelReq;
@@ -1032,11 +1034,21 @@ public class ConfigNodeRPCServiceProcessor implements
IConfigNodeRPCService.Ifac
return configManager.showDataNodes();
}
+ @Override
+ public TShowDataNodes4InformationSchemaResp
showDataNodes4InformationSchema() {
+ return configManager.showDataNodes4InformationSchema();
+ }
+
@Override
public TShowConfigNodesResp showConfigNodes() {
return configManager.showConfigNodes();
}
+ @Override
+ public TShowConfigNodes4InformationSchemaResp
showConfigNodes4InformationSchema() {
+ return configManager.showConfigNodes4InformationSchema();
+ }
+
@Override
public TShowDatabaseResp showDatabase(TGetDatabaseReq req) {
return configManager.showDatabase(req);
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/ConfigNodeClient.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/ConfigNodeClient.java
index 11699ffcf6e..9d0dcd22f91 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/ConfigNodeClient.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/ConfigNodeClient.java
@@ -151,7 +151,9 @@ import
org.apache.iotdb.confignode.rpc.thrift.TSetTimePartitionIntervalReq;
import org.apache.iotdb.confignode.rpc.thrift.TShowAINodesResp;
import org.apache.iotdb.confignode.rpc.thrift.TShowCQResp;
import org.apache.iotdb.confignode.rpc.thrift.TShowClusterResp;
+import
org.apache.iotdb.confignode.rpc.thrift.TShowConfigNodes4InformationSchemaResp;
import org.apache.iotdb.confignode.rpc.thrift.TShowConfigNodesResp;
+import
org.apache.iotdb.confignode.rpc.thrift.TShowDataNodes4InformationSchemaResp;
import org.apache.iotdb.confignode.rpc.thrift.TShowDataNodesResp;
import org.apache.iotdb.confignode.rpc.thrift.TShowDatabaseResp;
import org.apache.iotdb.confignode.rpc.thrift.TShowModelReq;
@@ -843,12 +845,27 @@ public class ConfigNodeClient implements
IConfigNodeRPCService.Iface, ThriftClie
() -> client.showDataNodes(), resp ->
!updateConfigNodeLeader(resp.status));
}
+ @Override
+ public TShowDataNodes4InformationSchemaResp
showDataNodes4InformationSchema() throws TException {
+ return executeRemoteCallWithRetry(
+ () -> client.showDataNodes4InformationSchema(),
+ resp -> !updateConfigNodeLeader(resp.status));
+ }
+
@Override
public TShowConfigNodesResp showConfigNodes() throws TException {
return executeRemoteCallWithRetry(
() -> client.showConfigNodes(), resp ->
!updateConfigNodeLeader(resp.status));
}
+ @Override
+ public TShowConfigNodes4InformationSchemaResp
showConfigNodes4InformationSchema()
+ throws TException {
+ return executeRemoteCallWithRetry(
+ () -> client.showConfigNodes4InformationSchema(),
+ resp -> !updateConfigNodeLeader(resp.status));
+ }
+
@Override
public TShowDatabaseResp showDatabase(TGetDatabaseReq req) throws TException
{
return executeRemoteCallWithRetry(
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/InformationSchemaContentSupplierFactory.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/InformationSchemaContentSupplierFactory.java
index 2d4df80fec1..c8f21a06440 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/InformationSchemaContentSupplierFactory.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/InformationSchemaContentSupplierFactory.java
@@ -20,7 +20,10 @@
package org.apache.iotdb.db.queryengine.execution.operator.source.relational;
import org.apache.iotdb.common.rpc.thrift.Model;
+import org.apache.iotdb.common.rpc.thrift.TAINodeLocation;
+import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation;
import org.apache.iotdb.common.rpc.thrift.TConsensusGroupType;
+import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation;
import org.apache.iotdb.commons.conf.IoTDBConstant;
import org.apache.iotdb.commons.exception.auth.AccessDeniedException;
import org.apache.iotdb.commons.model.ModelType;
@@ -38,11 +41,15 @@ import org.apache.iotdb.commons.udf.UDFInformation;
import
org.apache.iotdb.commons.udf.builtin.relational.TableBuiltinAggregationFunction;
import
org.apache.iotdb.commons.udf.builtin.relational.TableBuiltinScalarFunction;
import org.apache.iotdb.confignode.rpc.thrift.TClusterParameters;
+import
org.apache.iotdb.confignode.rpc.thrift.TConfigNodeInfo4InformationSchema;
+import org.apache.iotdb.confignode.rpc.thrift.TDataNodeInfo4InformationSchema;
import org.apache.iotdb.confignode.rpc.thrift.TDatabaseInfo;
import org.apache.iotdb.confignode.rpc.thrift.TDescTable4InformationSchemaResp;
import org.apache.iotdb.confignode.rpc.thrift.TGetDatabaseReq;
import org.apache.iotdb.confignode.rpc.thrift.TGetUdfTableReq;
+import org.apache.iotdb.confignode.rpc.thrift.TNodeVersionInfo;
import org.apache.iotdb.confignode.rpc.thrift.TRegionInfo;
+import org.apache.iotdb.confignode.rpc.thrift.TShowClusterResp;
import org.apache.iotdb.confignode.rpc.thrift.TShowModelReq;
import org.apache.iotdb.confignode.rpc.thrift.TShowPipeInfo;
import org.apache.iotdb.confignode.rpc.thrift.TShowPipeReq;
@@ -98,6 +105,9 @@ import static
org.apache.iotdb.commons.conf.IoTDBConstant.FUNCTION_TYPE_BUILTIN_
import static org.apache.iotdb.commons.conf.IoTDBConstant.TTL_INFINITE;
import static org.apache.iotdb.commons.schema.SchemaConstant.ALL_MATCH_SCOPE;
import static org.apache.iotdb.commons.schema.SchemaConstant.ALL_RESULT_NODES;
+import static
org.apache.iotdb.commons.schema.column.ColumnHeaderConstant.NODE_TYPE_AI_NODE;
+import static
org.apache.iotdb.commons.schema.column.ColumnHeaderConstant.NODE_TYPE_CONFIG_NODE;
+import static
org.apache.iotdb.commons.schema.column.ColumnHeaderConstant.NODE_TYPE_DATA_NODE;
import static org.apache.iotdb.commons.schema.table.TsTable.TTL_PROPERTY;
import static
org.apache.iotdb.db.queryengine.plan.execution.config.TableConfigTaskVisitor.canShowDB;
import static
org.apache.iotdb.db.queryengine.plan.execution.config.TableConfigTaskVisitor.canShowTable;
@@ -147,6 +157,12 @@ public class InformationSchemaContentSupplierFactory {
return new ConfigurationsSupplier(dataTypes, userName);
case InformationSchema.KEYWORDS:
return new KeywordsSupplier(dataTypes);
+ case InformationSchema.NODES:
+ return new NodesSupplier(dataTypes, userName);
+ case InformationSchema.CONFIG_NODES:
+ return new ConfigNodesSupplier(dataTypes, userName);
+ case InformationSchema.DATA_NODES:
+ return new DataNodesSupplier(dataTypes, userName);
default:
throw new UnsupportedOperationException("Unknown table: " + tableName);
}
@@ -982,6 +998,172 @@ public class InformationSchemaContentSupplierFactory {
}
}
+ private static class NodesSupplier extends TsBlockSupplier {
+ private TShowClusterResp showClusterResp;
+ private Iterator<TConfigNodeLocation> configNodeIterator;
+ private Iterator<TDataNodeLocation> dataNodeIterator;
+ private Iterator<TAINodeLocation> aiNodeIterator;
+
+ private NodesSupplier(final List<TSDataType> dataTypes, final String
userName) {
+ super(dataTypes);
+ accessControl.checkUserIsAdmin(userName);
+ try (final ConfigNodeClient client =
+
ConfigNodeClientManager.getInstance().borrowClient(ConfigNodeInfo.CONFIG_REGION_ID))
{
+ showClusterResp = client.showCluster();
+ configNodeIterator = showClusterResp.getConfigNodeListIterator();
+ dataNodeIterator = showClusterResp.getDataNodeListIterator();
+ aiNodeIterator = showClusterResp.getAiNodeListIterator();
+ } catch (final Exception e) {
+ lastException = e;
+ }
+ }
+
+ @Override
+ protected void constructLine() {
+ if (configNodeIterator.hasNext()) {
+ final TConfigNodeLocation location = configNodeIterator.next();
+ buildNodeTsBlock(
+ location.getConfigNodeId(),
+ NODE_TYPE_CONFIG_NODE,
+ showClusterResp.getNodeStatus().get(location.getConfigNodeId()),
+ location.getInternalEndPoint().getIp(),
+ location.getInternalEndPoint().getPort(),
+
showClusterResp.getNodeVersionInfo().get(location.getConfigNodeId()));
+ return;
+ }
+ if (dataNodeIterator.hasNext()) {
+ final TDataNodeLocation location = dataNodeIterator.next();
+ buildNodeTsBlock(
+ location.getDataNodeId(),
+ NODE_TYPE_DATA_NODE,
+ showClusterResp.getNodeStatus().get(location.getDataNodeId()),
+ location.getInternalEndPoint().getIp(),
+ location.getInternalEndPoint().getPort(),
+
showClusterResp.getNodeVersionInfo().get(location.getDataNodeId()));
+ return;
+ }
+ if (aiNodeIterator.hasNext()) {
+ final TAINodeLocation location = aiNodeIterator.next();
+ buildNodeTsBlock(
+ location.getAiNodeId(),
+ NODE_TYPE_AI_NODE,
+ showClusterResp.getNodeStatus().get(location.getAiNodeId()),
+ location.getInternalEndPoint().getIp(),
+ location.getInternalEndPoint().getPort(),
+ showClusterResp.getNodeVersionInfo().get(location.getAiNodeId()));
+ }
+ }
+
+ private void buildNodeTsBlock(
+ int nodeId,
+ String nodeType,
+ String nodeStatus,
+ String internalAddress,
+ int internalPort,
+ TNodeVersionInfo versionInfo) {
+ columnBuilders[0].writeInt(nodeId);
+ columnBuilders[1].writeBinary(new Binary(nodeType,
TSFileConfig.STRING_CHARSET));
+ if (nodeStatus == null) {
+ columnBuilders[2].appendNull();
+ } else {
+ columnBuilders[2].writeBinary(new Binary(nodeStatus,
TSFileConfig.STRING_CHARSET));
+ }
+
+ if (internalAddress == null) {
+ columnBuilders[3].appendNull();
+ } else {
+ columnBuilders[3].writeBinary(new Binary(internalAddress,
TSFileConfig.STRING_CHARSET));
+ }
+ columnBuilders[4].writeInt(internalPort);
+ if (versionInfo == null || versionInfo.getVersion() == null) {
+ columnBuilders[5].appendNull();
+ } else {
+ columnBuilders[5].writeBinary(
+ new Binary(versionInfo.getVersion(), TSFileConfig.STRING_CHARSET));
+ }
+ if (versionInfo == null || versionInfo.getBuildInfo() == null) {
+ columnBuilders[6].appendNull();
+ } else {
+ columnBuilders[6].writeBinary(
+ new Binary(versionInfo.getBuildInfo(),
TSFileConfig.STRING_CHARSET));
+ }
+ resultBuilder.declarePosition();
+ }
+
+ @Override
+ public boolean hasNext() {
+ return configNodeIterator.hasNext() || dataNodeIterator.hasNext() ||
aiNodeIterator.hasNext();
+ }
+ }
+
+ private static class ConfigNodesSupplier extends TsBlockSupplier {
+ private Iterator<TConfigNodeInfo4InformationSchema> configNodeIterator;
+
+ private ConfigNodesSupplier(final List<TSDataType> dataTypes, final String
userName) {
+ super(dataTypes);
+ accessControl.checkUserIsAdmin(userName);
+ try (final ConfigNodeClient client =
+
ConfigNodeClientManager.getInstance().borrowClient(ConfigNodeInfo.CONFIG_REGION_ID))
{
+ configNodeIterator =
+
client.showConfigNodes4InformationSchema().getConfigNodesInfoListIterator();
+ } catch (final Exception e) {
+ lastException = e;
+ }
+ }
+
+ @Override
+ protected void constructLine() {
+ final TConfigNodeInfo4InformationSchema configNodeInfo4InformationSchema
=
+ configNodeIterator.next();
+
columnBuilders[0].writeInt(configNodeInfo4InformationSchema.getConfigNodeId());
+
columnBuilders[1].writeInt(configNodeInfo4InformationSchema.getConsensusPort());
+ columnBuilders[2].writeBinary(
+ new Binary(configNodeInfo4InformationSchema.getRoleType(),
TSFileConfig.STRING_CHARSET));
+ resultBuilder.declarePosition();
+ }
+
+ @Override
+ public boolean hasNext() {
+ return configNodeIterator.hasNext();
+ }
+ }
+
+ private static class DataNodesSupplier extends TsBlockSupplier {
+ private Iterator<TDataNodeInfo4InformationSchema> dataNodeIterator;
+
+ private DataNodesSupplier(final List<TSDataType> dataTypes, final String
userName) {
+ super(dataTypes);
+ accessControl.checkUserIsAdmin(userName);
+ try (final ConfigNodeClient client =
+
ConfigNodeClientManager.getInstance().borrowClient(ConfigNodeInfo.CONFIG_REGION_ID))
{
+ dataNodeIterator =
client.showDataNodes4InformationSchema().getDataNodesInfoListIterator();
+ } catch (final Exception e) {
+ lastException = e;
+ }
+ }
+
+ @Override
+ protected void constructLine() {
+ final TDataNodeInfo4InformationSchema dataNodeInfo4InformationSchema =
+ dataNodeIterator.next();
+
columnBuilders[0].writeInt(dataNodeInfo4InformationSchema.getDataNodeId());
+
columnBuilders[1].writeInt(dataNodeInfo4InformationSchema.getDataRegionNum());
+
columnBuilders[2].writeInt(dataNodeInfo4InformationSchema.getSchemaRegionNum());
+ columnBuilders[3].writeBinary(
+ new Binary(dataNodeInfo4InformationSchema.getRpcAddress(),
TSFileConfig.STRING_CHARSET));
+ columnBuilders[4].writeInt(dataNodeInfo4InformationSchema.getRpcPort());
+ columnBuilders[5].writeInt(dataNodeInfo4InformationSchema.getMppPort());
+
columnBuilders[6].writeInt(dataNodeInfo4InformationSchema.getDataConsensusPort());
+
columnBuilders[7].writeInt(dataNodeInfo4InformationSchema.getSchemaConsensusPort());
+ resultBuilder.declarePosition();
+ }
+
+ @Override
+ public boolean hasNext() {
+ return dataNodeIterator.hasNext();
+ }
+ }
+
private abstract static class TsBlockSupplier implements Iterator<TsBlock> {
protected final TsBlockBuilder resultBuilder;
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/optimizations/DataNodeLocationSupplierFactory.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/optimizations/DataNodeLocationSupplierFactory.java
index 15b216d7e93..ac0c1bb3266 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/optimizations/DataNodeLocationSupplierFactory.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/optimizations/DataNodeLocationSupplierFactory.java
@@ -103,6 +103,9 @@ public class DataNodeLocationSupplierFactory {
case InformationSchema.FUNCTIONS:
case InformationSchema.CONFIGURATIONS:
case InformationSchema.KEYWORDS:
+ case InformationSchema.NODES:
+ case InformationSchema.CONFIG_NODES:
+ case InformationSchema.DATA_NODES:
return
Collections.singletonList(DataNodeEndPoints.getLocalDataNodeLocation());
default:
throw new UnsupportedOperationException("Unknown table: " +
tableName);
diff --git
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/column/ColumnHeaderConstant.java
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/column/ColumnHeaderConstant.java
index a5b83958cb0..2cfe3f9b48f 100644
---
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/column/ColumnHeaderConstant.java
+++
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/column/ColumnHeaderConstant.java
@@ -254,6 +254,19 @@ public class ColumnHeaderConstant {
public static final String FUNCTION_TYPE_TABLE_MODEL = "function_type";
public static final String CLASS_NAME_UDF_TABLE_MODEL = "class_name(udf)";
+ public static final String NODE_ID_TABLE_MODEL = "node_id";
+ public static final String NODE_TYPE_TABLE_MODEL = "node_type";
+ public static final String INTERNAL_PORT_TABLE_MODEL = "internal_port";
+ public static final String BUILD_INFO_TABLE_MODEL = "build_info";
+
+ public static final String CONFIG_CONSENSUS_PORT_TABLE_MODEL =
"config_consensus_port";
+
+ public static final String DATA_REGION_NUM_TABLE_MODEL = "data_region_num";
+ public static final String SCHEMA_REGION_NUM_TABLE_MODEL =
"schema_region_num";
+ public static final String MPP_PORT_TABLE_MODEL = "mpp_port";
+ public static final String SCHEMA_CONSENSUS_PORT_TABLE_MODEL =
"schema_consensus_port";
+ public static final String DATA_CONSENSUS_PORT_TABLE_MODEL =
"data_consensus_port";
+
// column names for show space quota
public static final String QUOTA_TYPE = "QuotaType";
public static final String LIMIT = "Limit";
@@ -422,8 +435,8 @@ public class ColumnHeaderConstant {
ImmutableList.of(
new ColumnHeader(NODE_ID, TSDataType.INT32),
new ColumnHeader(STATUS, TSDataType.TEXT),
- new ColumnHeader(RPC_ADDRESS, TSDataType.TEXT),
- new ColumnHeader(RPC_PORT, TSDataType.INT32));
+ new ColumnHeader(INTERNAL_ADDRESS, TSDataType.TEXT),
+ new ColumnHeader(INTERNAL_PORT, TSDataType.INT32));
public static final List<ColumnHeader> showDataNodesColumnHeaders =
ImmutableList.of(
diff --git
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/table/InformationSchema.java
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/table/InformationSchema.java
index da4b17ecf72..3cb880e27bd 100644
---
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/table/InformationSchema.java
+++
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/table/InformationSchema.java
@@ -47,6 +47,9 @@ public class InformationSchema {
public static final String FUNCTIONS = "functions";
public static final String CONFIGURATIONS = "configurations";
public static final String KEYWORDS = "keywords";
+ public static final String NODES = "nodes";
+ public static final String CONFIG_NODES = "config_nodes";
+ public static final String DATA_NODES = "data_nodes";
static {
final TsTable queriesTable = new TsTable(QUERIES);
@@ -298,6 +301,64 @@ public class InformationSchema {
new AttributeColumnSchema(ColumnHeaderConstant.RESERVED,
TSDataType.INT32));
keywordsTable.removeColumnSchema(TsTable.TIME_COLUMN_NAME);
schemaTables.put(KEYWORDS, keywordsTable);
+
+ final TsTable nodesTable = new TsTable(NODES);
+ nodesTable.addColumnSchema(
+ new TagColumnSchema(ColumnHeaderConstant.NODE_ID_TABLE_MODEL,
TSDataType.INT32));
+ nodesTable.addColumnSchema(
+ new AttributeColumnSchema(ColumnHeaderConstant.NODE_TYPE_TABLE_MODEL,
TSDataType.STRING));
+ nodesTable.addColumnSchema(
+ new AttributeColumnSchema(
+ ColumnHeaderConstant.STATUS.toLowerCase(Locale.ENGLISH),
TSDataType.STRING));
+ nodesTable.addColumnSchema(
+ new AttributeColumnSchema(
+ ColumnHeaderConstant.INTERNAL_ADDRESS_TABLE_MODEL,
TSDataType.STRING));
+ nodesTable.addColumnSchema(
+ new AttributeColumnSchema(
+ ColumnHeaderConstant.INTERNAL_PORT_TABLE_MODEL, TSDataType.INT32));
+ nodesTable.addColumnSchema(
+ new AttributeColumnSchema(
+ ColumnHeaderConstant.VERSION.toLowerCase(Locale.ENGLISH),
TSDataType.STRING));
+ nodesTable.addColumnSchema(
+ new AttributeColumnSchema(ColumnHeaderConstant.BUILD_INFO_TABLE_MODEL,
TSDataType.STRING));
+ nodesTable.removeColumnSchema(TsTable.TIME_COLUMN_NAME);
+ schemaTables.put(NODES, nodesTable);
+
+ final TsTable configNodesTable = new TsTable(CONFIG_NODES);
+ configNodesTable.addColumnSchema(
+ new TagColumnSchema(ColumnHeaderConstant.NODE_ID_TABLE_MODEL,
TSDataType.INT32));
+ configNodesTable.addColumnSchema(
+ new AttributeColumnSchema(
+ ColumnHeaderConstant.CONFIG_CONSENSUS_PORT_TABLE_MODEL,
TSDataType.INT32));
+ configNodesTable.addColumnSchema(
+ new AttributeColumnSchema(
+ ColumnHeaderConstant.ROLE.toLowerCase(Locale.ENGLISH),
TSDataType.STRING));
+ configNodesTable.removeColumnSchema(TsTable.TIME_COLUMN_NAME);
+ schemaTables.put(CONFIG_NODES, configNodesTable);
+
+ final TsTable dataNodesTable = new TsTable(DATA_NODES);
+ dataNodesTable.addColumnSchema(
+ new TagColumnSchema(ColumnHeaderConstant.NODE_ID_TABLE_MODEL,
TSDataType.INT32));
+ dataNodesTable.addColumnSchema(
+ new AttributeColumnSchema(
+ ColumnHeaderConstant.DATA_REGION_NUM_TABLE_MODEL,
TSDataType.INT32));
+ dataNodesTable.addColumnSchema(
+ new AttributeColumnSchema(
+ ColumnHeaderConstant.SCHEMA_REGION_NUM_TABLE_MODEL,
TSDataType.INT32));
+ dataNodesTable.addColumnSchema(
+ new
AttributeColumnSchema(ColumnHeaderConstant.RPC_ADDRESS_TABLE_MODEL,
TSDataType.STRING));
+ dataNodesTable.addColumnSchema(
+ new AttributeColumnSchema(ColumnHeaderConstant.RPC_PORT_TABLE_MODEL,
TSDataType.INT32));
+ dataNodesTable.addColumnSchema(
+ new AttributeColumnSchema(ColumnHeaderConstant.MPP_PORT_TABLE_MODEL,
TSDataType.INT32));
+ dataNodesTable.addColumnSchema(
+ new AttributeColumnSchema(
+ ColumnHeaderConstant.DATA_CONSENSUS_PORT_TABLE_MODEL,
TSDataType.INT32));
+ dataNodesTable.addColumnSchema(
+ new AttributeColumnSchema(
+ ColumnHeaderConstant.SCHEMA_CONSENSUS_PORT_TABLE_MODEL,
TSDataType.INT32));
+ dataNodesTable.removeColumnSchema(TsTable.TIME_COLUMN_NAME);
+ schemaTables.put(DATA_NODES, dataNodesTable);
}
public static Map<String, TsTable> getSchemaTables() {
diff --git a/iotdb-protocol/thrift-confignode/src/main/thrift/confignode.thrift
b/iotdb-protocol/thrift-confignode/src/main/thrift/confignode.thrift
index 3315d5e7bf9..3f4c42d058a 100644
--- a/iotdb-protocol/thrift-confignode/src/main/thrift/confignode.thrift
+++ b/iotdb-protocol/thrift-confignode/src/main/thrift/confignode.thrift
@@ -602,6 +602,18 @@ struct TShowVariablesResp {
2: optional TClusterParameters clusterParameters
}
+// Show confignodes
+struct TDataNodeInfo4InformationSchema {
+ 1: required i32 dataNodeId
+ 2: required i32 dataRegionNum
+ 3: required i32 schemaRegionNum
+ 4: required string rpcAddress
+ 5: required i32 rpcPort
+ 6: required i32 mppPort
+ 7: required i32 dataConsensusPort
+ 8: required i32 schemaConsensusPort
+}
+
// Show datanodes
struct TDataNodeInfo {
1: required i32 dataNodeId
@@ -613,13 +625,18 @@ struct TDataNodeInfo {
7: optional i32 cpuCoreNum
}
-struct TAINodeInfo{
+struct TAINodeInfo {
1: required i32 aiNodeId
2: required string status
3: required string internalAddress
4: required i32 internalPort
}
+struct TShowDataNodes4InformationSchemaResp {
+ 1: required common.TSStatus status
+ 2: optional list<TDataNodeInfo4InformationSchema> dataNodesInfoList
+}
+
struct TShowDataNodesResp {
1: required common.TSStatus status
2: optional list<TDataNodeInfo> dataNodesInfoList
@@ -644,6 +661,18 @@ struct TShowConfigNodesResp {
2: optional list<TConfigNodeInfo> configNodesInfoList
}
+// Show confignodes for information schema
+struct TConfigNodeInfo4InformationSchema {
+ 1: required i32 configNodeId
+ 2: required i32 consensusPort
+ 5: required string roleType
+}
+
+struct TShowConfigNodes4InformationSchemaResp {
+ 1: required common.TSStatus status
+ 2: optional list<TConfigNodeInfo4InformationSchema> configNodesInfoList
+}
+
// Show Database
struct TDatabaseInfo {
1: required string name
@@ -1715,9 +1744,15 @@ service IConfigNodeRPCService {
/** Show cluster DataNodes' information */
TShowDataNodesResp showDataNodes()
+ /** Show cluster DataNodes' information for information schema */
+ TShowDataNodes4InformationSchemaResp showDataNodes4InformationSchema()
+
/** Show cluster ConfigNodes' information */
TShowConfigNodesResp showConfigNodes()
+ /** Show cluster ConfigNodes' information for information schema */
+ TShowConfigNodes4InformationSchemaResp showConfigNodes4InformationSchema()
+
/** Show cluster Databases' information */
TShowDatabaseResp showDatabase(TGetDatabaseReq req)