This is an automated email from the ASF dual-hosted git repository.
caogaofei pushed a commit to branch beyyes/feature/show_datanodes
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/beyyes/feature/show_datanodes
by this push:
new 87ca286765 add basic SHOW CLUSTER sql and statement implementation in
IoTDB MPP mode
87ca286765 is described below
commit 87ca286765858202adf9913b3d8a71878199cdb5
Author: Beyyes <[email protected]>
AuthorDate: Sat May 28 15:48:57 2022 +0800
add basic SHOW CLUSTER sql and statement implementation in IoTDB MPP mode
---
.../org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4 | 7 +-
.../antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4 | 4 +
.../thrift/ConfigNodeRPCServiceProcessor.java | 18 ++++
.../thrift/ConfigNodeRPCServiceProcessorTest.java | 29 ++++++
.../apache/iotdb/db/client/ConfigNodeClient.java | 17 ++++
.../iotdb/db/mpp/common/header/HeaderConstant.java | 24 +++++
.../apache/iotdb/db/mpp/plan/analyze/Analyzer.java | 9 ++
.../plan/execution/config/ConfigTaskVisitor.java | 6 ++
.../mpp/plan/execution/config/ShowClusterTask.java | 108 +++++++++++++++++++++
.../iotdb/db/mpp/plan/parser/ASTVisitor.java | 7 ++
.../db/mpp/plan/statement/StatementVisitor.java | 5 +
.../statement/metadata/ShowClusterStatement.java | 1 +
.../src/main/thrift/confignode.thrift | 10 ++
13 files changed, 244 insertions(+), 1 deletion(-)
diff --git a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
index f513a4da7a..3ed03fe025 100644
--- a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
+++ b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
@@ -43,7 +43,7 @@ ddlStatement
| dropFunction | dropTrigger | dropContinuousQuery | dropSchemaTemplate
| setTTL | unsetTTL | startTrigger | stopTrigger | setSchemaTemplate |
unsetSchemaTemplate
| showStorageGroup | showDevices | showTimeseries | showChildPaths |
showChildNodes
- | showFunctions | showTriggers | showContinuousQueries | showTTL |
showAllTTL
+ | showFunctions | showTriggers | showContinuousQueries | showTTL |
showAllTTL | showCluster
| showSchemaTemplates | showNodesInSchemaTemplate
| showPathsUsingSchemaTemplate | showPathsSetSchemaTemplate
| countStorageGroup | countDevices | countTimeseries | countNodes
@@ -295,6 +295,11 @@ showAllTTL
: SHOW ALL TTL
;
+// Show Cluster
+showCluster
+ : SHOW CLUSTER
+ ;
+
// Show Schema Template
showSchemaTemplates
: SHOW SCHEMA? TEMPLATES
diff --git a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4
b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4
index fc114ebe63..110cbc65a0 100644
--- a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4
+++ b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4
@@ -117,6 +117,10 @@ CLEAR
: C L E A R
;
+CLUSTER
+ : C L U S T E R
+ ;
+
COMPRESSION
: C O M P R E S S I O N
;
diff --git
a/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java
b/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java
index 3b20df5131..a62363f623 100644
---
a/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java
+++
b/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java
@@ -19,6 +19,8 @@
package org.apache.iotdb.confignode.service.thrift;
import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation;
+import org.apache.iotdb.common.rpc.thrift.TDataNodeInfo;
+import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation;
import org.apache.iotdb.common.rpc.thrift.TSStatus;
import org.apache.iotdb.commons.auth.AuthException;
import org.apache.iotdb.commons.conf.CommonDescriptor;
@@ -54,6 +56,7 @@ import
org.apache.iotdb.confignode.rpc.thrift.NodeManagementType;
import org.apache.iotdb.confignode.rpc.thrift.TAuthorizerReq;
import org.apache.iotdb.confignode.rpc.thrift.TAuthorizerResp;
import org.apache.iotdb.confignode.rpc.thrift.TCheckUserPrivilegesReq;
+import org.apache.iotdb.confignode.rpc.thrift.TClusterNodeInfos;
import org.apache.iotdb.confignode.rpc.thrift.TConfigNodeRegisterReq;
import org.apache.iotdb.confignode.rpc.thrift.TConfigNodeRegisterResp;
import org.apache.iotdb.confignode.rpc.thrift.TCountStorageGroupResp;
@@ -79,6 +82,7 @@ import
org.apache.iotdb.confignode.rpc.thrift.TStorageGroupSchemaResp;
import org.apache.iotdb.db.mpp.common.schematree.PathPatternTree;
import org.apache.iotdb.db.qp.logical.sys.AuthorOperator;
+import org.apache.iotdb.rpc.TSStatusCode;
import org.apache.thrift.TException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -88,6 +92,7 @@ import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.stream.Collectors;
/** ConfigNodeRPCServer exposes the interface that interacts with the DataNode
*/
public class ConfigNodeRPCServiceProcessor implements ConfigIService.Iface {
@@ -135,6 +140,19 @@ public class ConfigNodeRPCServiceProcessor implements
ConfigIService.Iface {
return resp;
}
+ @Override
+ public TClusterNodeInfos getAllClusterNodeInfos() throws TException {
+ List<TConfigNodeLocation> configNodeLocations =
+ configManager.getNodeManager().getOnlineConfigNodes();
+ List<TDataNodeLocation> dataNodeInfoLocations =
+ configManager.getNodeManager().getOnlineDataNodes(-1).stream().
+ map(TDataNodeInfo::getLocation).collect(Collectors.toList());
+
+ return new TClusterNodeInfos(
+ new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode()),
+ configNodeLocations, dataNodeInfoLocations);
+ }
+
@Override
public TSStatus setStorageGroup(TSetStorageGroupReq req) throws TException {
TStorageGroupSchema storageGroupSchema = req.getStorageGroup();
diff --git
a/confignode/src/test/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessorTest.java
b/confignode/src/test/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessorTest.java
index a3d02b596d..134b8cdbee 100644
---
a/confignode/src/test/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessorTest.java
+++
b/confignode/src/test/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessorTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.iotdb.confignode.service.thrift;
+import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation;
import org.apache.iotdb.common.rpc.thrift.TConsensusGroupType;
import org.apache.iotdb.common.rpc.thrift.TDataNodeInfo;
import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation;
@@ -42,6 +43,7 @@ import
org.apache.iotdb.confignode.rpc.thrift.NodeManagementType;
import org.apache.iotdb.confignode.rpc.thrift.TAuthorizerReq;
import org.apache.iotdb.confignode.rpc.thrift.TAuthorizerResp;
import org.apache.iotdb.confignode.rpc.thrift.TCheckUserPrivilegesReq;
+import org.apache.iotdb.confignode.rpc.thrift.TClusterNodeInfos;
import org.apache.iotdb.confignode.rpc.thrift.TCountStorageGroupResp;
import org.apache.iotdb.confignode.rpc.thrift.TDataNodeInfoResp;
import org.apache.iotdb.confignode.rpc.thrift.TDataNodeRegisterReq;
@@ -61,6 +63,7 @@ import org.apache.iotdb.confignode.rpc.thrift.TSetTTLReq;
import org.apache.iotdb.confignode.rpc.thrift.TSetTimePartitionIntervalReq;
import org.apache.iotdb.confignode.rpc.thrift.TStorageGroupSchema;
import org.apache.iotdb.confignode.rpc.thrift.TStorageGroupSchemaResp;
+import org.apache.iotdb.db.client.ConfigNodeInfo;
import org.apache.iotdb.db.mpp.common.schematree.PathPatternTree;
import org.apache.iotdb.db.qp.logical.sys.AuthorOperator;
import org.apache.iotdb.rpc.TSStatusCode;
@@ -203,6 +206,32 @@ public class ConfigNodeRPCServiceProcessorTest {
Assert.assertEquals(dataNodeLocation, infoMap.get(1).getLocation());
}
+ @Test
+ public void getAllClusterNodeInfosTest() throws TException {
+ registerDataNodes();
+
+ TClusterNodeInfos clusterNodes = processor.getAllClusterNodeInfos();
+
+ List<TConfigNodeLocation> configNodeInfos =
clusterNodes.getConfigNodeList();
+ Assert.assertEquals(1, configNodeInfos.size());
+ TConfigNodeLocation configNodeLocation = new TConfigNodeLocation(
+ new TEndPoint("0.0.0.0", 22277),
+ new TEndPoint("0.0.0.0", 22278));
+ Assert.assertEquals(configNodeLocation, configNodeInfos.get(0));
+
+ List<TDataNodeLocation> dataNodeInfos = clusterNodes.getDataNodeList();
+ Assert.assertEquals(3, dataNodeInfos.size());
+ TDataNodeLocation dataNodeLocation = new TDataNodeLocation();
+ for (int i = 0; i < 3; i++) {
+ dataNodeLocation.setDataNodeId(i);
+ dataNodeLocation.setExternalEndPoint(new TEndPoint("0.0.0.0", 6667 + i));
+ dataNodeLocation.setInternalEndPoint(new TEndPoint("0.0.0.0", 9003 + i));
+ dataNodeLocation.setDataBlockManagerEndPoint(new TEndPoint("0.0.0.0",
8777 + i));
+ dataNodeLocation.setConsensusEndPoint(new TEndPoint("0.0.0.0", 40010 +
i));
+ Assert.assertEquals(dataNodeLocation, dataNodeInfos.get(i));
+ }
+ }
+
@Test
public void testSetAndQueryStorageGroup() throws TException {
TSStatus status;
diff --git
a/server/src/main/java/org/apache/iotdb/db/client/ConfigNodeClient.java
b/server/src/main/java/org/apache/iotdb/db/client/ConfigNodeClient.java
index f1a9f40bda..704ecf7781 100644
--- a/server/src/main/java/org/apache/iotdb/db/client/ConfigNodeClient.java
+++ b/server/src/main/java/org/apache/iotdb/db/client/ConfigNodeClient.java
@@ -33,6 +33,7 @@ import org.apache.iotdb.confignode.rpc.thrift.ConfigIService;
import org.apache.iotdb.confignode.rpc.thrift.TAuthorizerReq;
import org.apache.iotdb.confignode.rpc.thrift.TAuthorizerResp;
import org.apache.iotdb.confignode.rpc.thrift.TCheckUserPrivilegesReq;
+import org.apache.iotdb.confignode.rpc.thrift.TClusterNodeInfos;
import org.apache.iotdb.confignode.rpc.thrift.TConfigNodeRegisterReq;
import org.apache.iotdb.confignode.rpc.thrift.TConfigNodeRegisterResp;
import org.apache.iotdb.confignode.rpc.thrift.TCountStorageGroupResp;
@@ -262,6 +263,22 @@ public class ConfigNodeClient implements
ConfigIService.Iface, SyncThriftClient,
throw new TException(MSG_RECONNECTION_FAIL);
}
+ @Override
+ public TClusterNodeInfos getAllClusterNodeInfos() throws TException {
+ for (int i = 0; i < RETRY_NUM; i++) {
+ try {
+ TClusterNodeInfos resp = client.getAllClusterNodeInfos();
+ if (!updateConfigNodeLeader(resp.status)) {
+ return resp;
+ }
+ } catch (TException e) {
+ configLeader = null;
+ }
+ reconnect();
+ }
+ throw new TException(MSG_RECONNECTION_FAIL);
+ }
+
@Override
public TSStatus setStorageGroup(TSetStorageGroupReq req) throws TException {
for (int i = 0; i < RETRY_NUM; i++) {
diff --git
a/server/src/main/java/org/apache/iotdb/db/mpp/common/header/HeaderConstant.java
b/server/src/main/java/org/apache/iotdb/db/mpp/common/header/HeaderConstant.java
index 875bb50428..eed325b7fb 100644
---
a/server/src/main/java/org/apache/iotdb/db/mpp/common/header/HeaderConstant.java
+++
b/server/src/main/java/org/apache/iotdb/db/mpp/common/header/HeaderConstant.java
@@ -55,6 +55,13 @@ public class HeaderConstant {
public static final String COLUMN_COUNT_TIMESERIES = "count(timeseries)";
public static final String COLUMN_COUNT_STORAGE_GROUP = "count(storage
group)";
+ // column names for show cluster statement
+ public static final String COLUMN_NODE_ID = "NodeID";
+ public static final String COLUMN_NODE_TYPE = "NodeType";
+ public static final String COLUMN_STATUS = "Status";
+ public static final String COLUMN_HOST_ADDRESS = "HostAdress";
+ public static final String COLUMN_PORT = "Port";
+
// dataset header for schema statement
public static final DatasetHeader showTimeSeriesHeader;
public static final DatasetHeader showDevicesHeader;
@@ -71,6 +78,9 @@ public class HeaderConstant {
public static final DatasetHeader countTimeSeriesHeader;
public static final DatasetHeader countLevelTimeSeriesHeader;
+ // dataset header for show cluster statement
+ public static final DatasetHeader showClusterHeader;
+
static {
countStorageGroupHeader =
new DatasetHeader(
@@ -145,4 +155,18 @@ public class HeaderConstant {
new DatasetHeader(
Arrays.asList(new ColumnHeader(COLUMN_CHILDNODES,
TSDataType.TEXT)), true);
}
+
+ static {
+ showClusterHeader =
+ new DatasetHeader(
+ Arrays.asList(
+ new ColumnHeader(COLUMN_NODE_ID, TSDataType.INT32),
+ new ColumnHeader(COLUMN_NODE_TYPE, TSDataType.TEXT),
+ new ColumnHeader(COLUMN_STATUS, TSDataType.TEXT),
+ new ColumnHeader(COLUMN_HOST_ADDRESS, TSDataType.TEXT),
+ new ColumnHeader(COLUMN_PORT, TSDataType.INT32)),
+ true);
+ }
+
+
}
diff --git
a/server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/Analyzer.java
b/server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/Analyzer.java
index ee187b3c4e..cb67e57412 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/Analyzer.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/Analyzer.java
@@ -67,6 +67,7 @@ import
org.apache.iotdb.db.mpp.plan.statement.metadata.DeleteTimeSeriesStatement
import org.apache.iotdb.db.mpp.plan.statement.metadata.SchemaFetchStatement;
import org.apache.iotdb.db.mpp.plan.statement.metadata.ShowChildNodesStatement;
import org.apache.iotdb.db.mpp.plan.statement.metadata.ShowChildPathsStatement;
+import org.apache.iotdb.db.mpp.plan.statement.metadata.ShowClusterStatement;
import org.apache.iotdb.db.mpp.plan.statement.metadata.ShowDevicesStatement;
import
org.apache.iotdb.db.mpp.plan.statement.metadata.ShowStorageGroupStatement;
import org.apache.iotdb.db.mpp.plan.statement.metadata.ShowTTLStatement;
@@ -1137,6 +1138,14 @@ public class Analyzer {
return analysis;
}
+ @Override
+ public Analysis visitShowCluster(ShowClusterStatement
showClusterStatement, MPPQueryContext context) {
+ Analysis analysis = new Analysis();
+ analysis.setStatement(showClusterStatement);
+ analysis.setRespDatasetHeader(HeaderConstant.showClusterHeader);
+ return analysis;
+ }
+
@Override
public Analysis visitCountStorageGroup(
CountStorageGroupStatement countStorageGroupStatement, MPPQueryContext
context) {
diff --git
a/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/config/ConfigTaskVisitor.java
b/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/config/ConfigTaskVisitor.java
index 671edfb68b..a5a6091e4d 100644
---
a/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/config/ConfigTaskVisitor.java
+++
b/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/config/ConfigTaskVisitor.java
@@ -26,6 +26,7 @@ import
org.apache.iotdb.db.mpp.plan.statement.metadata.CountStorageGroupStatemen
import
org.apache.iotdb.db.mpp.plan.statement.metadata.DeleteStorageGroupStatement;
import
org.apache.iotdb.db.mpp.plan.statement.metadata.SetStorageGroupStatement;
import org.apache.iotdb.db.mpp.plan.statement.metadata.SetTTLStatement;
+import org.apache.iotdb.db.mpp.plan.statement.metadata.ShowClusterStatement;
import
org.apache.iotdb.db.mpp.plan.statement.metadata.ShowStorageGroupStatement;
import org.apache.iotdb.db.mpp.plan.statement.metadata.ShowTTLStatement;
import org.apache.iotdb.db.mpp.plan.statement.metadata.UnSetTTLStatement;
@@ -83,6 +84,11 @@ public class ConfigTaskVisitor
return new ShowTTLTask(showTTLStatement);
}
+ @Override
+ public IConfigTask visitShowCluster(ShowClusterStatement
showClusterStatement, TaskContext context) {
+ return new ShowClusterTask(showClusterStatement);
+ }
+
@Override
public IConfigTask visitAuthor(AuthorStatement statement, TaskContext
context) {
return new AuthorizerConfigTask(statement);
diff --git
a/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/config/ShowClusterTask.java
b/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/config/ShowClusterTask.java
new file mode 100644
index 0000000000..8faa1298ef
--- /dev/null
+++
b/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/config/ShowClusterTask.java
@@ -0,0 +1,108 @@
+/*
+ * 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.db.mpp.plan.execution.config;
+
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.SettableFuture;
+import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation;
+import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation;
+import org.apache.iotdb.common.rpc.thrift.TEndPoint;
+import org.apache.iotdb.commons.client.IClientManager;
+import org.apache.iotdb.commons.consensus.PartitionRegionId;
+import org.apache.iotdb.confignode.rpc.thrift.TClusterNodeInfos;
+import org.apache.iotdb.confignode.rpc.thrift.TStorageGroupSchemaResp;
+import org.apache.iotdb.db.client.ConfigNodeClient;
+import org.apache.iotdb.db.client.ConfigNodeInfo;
+import org.apache.iotdb.db.conf.IoTDBConfig;
+import org.apache.iotdb.db.conf.IoTDBDescriptor;
+import org.apache.iotdb.db.localconfignode.LocalConfigNode;
+import org.apache.iotdb.db.mpp.common.header.DatasetHeader;
+import org.apache.iotdb.db.mpp.common.header.HeaderConstant;
+import org.apache.iotdb.db.mpp.plan.statement.metadata.ShowClusterStatement;
+import org.apache.iotdb.rpc.TSStatusCode;
+import org.apache.iotdb.tsfile.read.common.block.TsBlockBuilder;
+import org.apache.iotdb.tsfile.utils.Binary;
+import org.apache.thrift.TException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.List;
+
+public class ShowClusterTask implements IConfigTask {
+
+ private static final Logger LOGGER =
LoggerFactory.getLogger(ShowClusterTask.class);
+
+ private static final IoTDBConfig config =
IoTDBDescriptor.getInstance().getConfig();
+
+ private ShowClusterStatement showClusterStatement;
+
+ public ShowClusterTask(ShowClusterStatement showClusterStatement) {
+ this.showClusterStatement = showClusterStatement;
+ }
+
+ @Override
+ public ListenableFuture<ConfigTaskResult> execute(
+ IClientManager<PartitionRegionId, ConfigNodeClient> clientManager)
+ throws InterruptedException {
+ SettableFuture<ConfigTaskResult> future = SettableFuture.create();
+ TClusterNodeInfos clusterNodeInfos = new TClusterNodeInfos();
+
+ if (config.isClusterMode()) {
+ try (ConfigNodeClient client =
clientManager.borrowClient(ConfigNodeInfo.partitionRegionId)) {
+ clusterNodeInfos = client.getAllClusterNodeInfos();
+ } catch (TException | IOException e) {
+ LOGGER.error("Failed to connect to config node.");
+ future.setException(e);
+ }
+ } else {
+ // TODO how to get property in localConfigNode
+ LocalConfigNode localConfigNode = LocalConfigNode.getInstance();
+ config.getDataNodeId();
+ }
+
+ // build TSBlock
+ TsBlockBuilder builder =
+ new TsBlockBuilder(HeaderConstant.showClusterHeader.getRespDataTypes());
+ int configNodeId = 0;
+ for (TConfigNodeLocation nodeLocation :
clusterNodeInfos.getConfigNodeList()) {
+ builder.getTimeColumnBuilder().writeLong(0L);
+ builder.getColumnBuilder(0).writeInt(configNodeId++);
+ builder.getColumnBuilder(1).writeBinary(new Binary("ConfigNode"));
+ builder.getColumnBuilder(2).writeBinary(new Binary("Running"));
+ builder.getColumnBuilder(3).writeBinary(new
Binary(nodeLocation.getInternalEndPoint().getIp()));
+
builder.getColumnBuilder(4).writeInt(nodeLocation.getInternalEndPoint().getPort());
+ builder.declarePosition();
+ }
+ for (TDataNodeLocation nodeLocation : clusterNodeInfos.getDataNodeList()) {
+ builder.getTimeColumnBuilder().writeLong(0L);
+ builder.getColumnBuilder(0).writeInt(nodeLocation.getDataNodeId());
+ builder.getColumnBuilder(1).writeBinary(new Binary("DataNode"));
+ builder.getColumnBuilder(2).writeBinary(new Binary("Running"));
+ builder.getColumnBuilder(3).writeBinary(new
Binary(nodeLocation.getInternalEndPoint().getIp()));
+
builder.getColumnBuilder(4).writeInt(nodeLocation.getInternalEndPoint().getPort());
+ builder.declarePosition();
+ }
+
+ DatasetHeader datasetHeader = HeaderConstant.showClusterHeader;
+ future.set(new ConfigTaskResult(TSStatusCode.SUCCESS_STATUS,
builder.build(), datasetHeader));
+ return future;
+ }
+}
diff --git
a/server/src/main/java/org/apache/iotdb/db/mpp/plan/parser/ASTVisitor.java
b/server/src/main/java/org/apache/iotdb/db/mpp/plan/parser/ASTVisitor.java
index 74236f6a1c..f02c2a30a9 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/plan/parser/ASTVisitor.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/plan/parser/ASTVisitor.java
@@ -85,6 +85,7 @@ import
org.apache.iotdb.db.mpp.plan.statement.metadata.SetStorageGroupStatement;
import org.apache.iotdb.db.mpp.plan.statement.metadata.SetTTLStatement;
import org.apache.iotdb.db.mpp.plan.statement.metadata.ShowChildNodesStatement;
import org.apache.iotdb.db.mpp.plan.statement.metadata.ShowChildPathsStatement;
+import org.apache.iotdb.db.mpp.plan.statement.metadata.ShowClusterStatement;
import org.apache.iotdb.db.mpp.plan.statement.metadata.ShowDevicesStatement;
import
org.apache.iotdb.db.mpp.plan.statement.metadata.ShowStorageGroupStatement;
import org.apache.iotdb.db.mpp.plan.statement.metadata.ShowTTLStatement;
@@ -1520,6 +1521,12 @@ public class ASTVisitor extends
IoTDBSqlParserBaseVisitor<Statement> {
return showTTLStatement;
}
+ @Override
+ public Statement visitShowCluster(IoTDBSqlParser.ShowClusterContext ctx) {
+ ShowClusterStatement showClusterStatement = new ShowClusterStatement();
+ return showClusterStatement;
+ }
+
@Override
public Statement
visitDeleteStorageGroup(IoTDBSqlParser.DeleteStorageGroupContext ctx) {
DeleteStorageGroupStatement deleteStorageGroupStatement = new
DeleteStorageGroupStatement();
diff --git
a/server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/StatementVisitor.java
b/server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/StatementVisitor.java
index b8ceb59787..91d5cabc46 100644
---
a/server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/StatementVisitor.java
+++
b/server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/StatementVisitor.java
@@ -41,6 +41,7 @@ import
org.apache.iotdb.db.mpp.plan.statement.metadata.SetStorageGroupStatement;
import org.apache.iotdb.db.mpp.plan.statement.metadata.SetTTLStatement;
import org.apache.iotdb.db.mpp.plan.statement.metadata.ShowChildNodesStatement;
import org.apache.iotdb.db.mpp.plan.statement.metadata.ShowChildPathsStatement;
+import org.apache.iotdb.db.mpp.plan.statement.metadata.ShowClusterStatement;
import org.apache.iotdb.db.mpp.plan.statement.metadata.ShowDevicesStatement;
import
org.apache.iotdb.db.mpp.plan.statement.metadata.ShowStorageGroupStatement;
import org.apache.iotdb.db.mpp.plan.statement.metadata.ShowTTLStatement;
@@ -119,6 +120,10 @@ public abstract class StatementVisitor<R, C> {
return visitStatement(showTTLStatement, context);
}
+ public R visitShowCluster(ShowClusterStatement showClusterStatement, C
context) {
+ return visitStatement(showClusterStatement, context);
+ }
+
/** Data Manipulation Language (DML) */
// Select Statement
diff --git
a/server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/metadata/ShowClusterStatement.java
b/server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/metadata/ShowClusterStatement.java
new file mode 100644
index 0000000000..c4761f2adf
--- /dev/null
+++
b/server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/metadata/ShowClusterStatement.java
@@ -0,0 +1 @@
+package org.apache.iotdb.db.mpp.plan.statement.metadata;
import org.apache.iotdb.db.mpp.plan.analyze.QueryType;
import org.apache.iotdb.db.mpp.plan.statement.IConfigStatement;
import org.apache.iotdb.db.mpp.plan.statement.StatementVisitor;
public class ShowClusterStatement extends ShowStatement implements
IConfigStatement {
@Override
public QueryType getQueryType() {
return QueryType.READ;
}
@Override
public <R, C> R accept(StatementVisitor<R, C> visitor, C context) {
return visitor.visitShowCluster(this, context);
}
}
\ No newline at end of file
diff --git a/thrift-confignode/src/main/thrift/confignode.thrift
b/thrift-confignode/src/main/thrift/confignode.thrift
index 4b933e548f..92d0564712 100644
--- a/thrift-confignode/src/main/thrift/confignode.thrift
+++ b/thrift-confignode/src/main/thrift/confignode.thrift
@@ -193,6 +193,13 @@ struct TConfigNodeRegisterResp {
3: optional list<common.TConfigNodeLocation> configNodeList
}
+// Show cluster
+struct TClusterNodeInfos {
+ 1: required common.TSStatus status
+ 2: required list<common.TConfigNodeLocation> configNodeList
+ 3: required list<common.TDataNodeLocation> dataNodeList
+}
+
service ConfigIService {
/* DataNode */
@@ -201,6 +208,9 @@ service ConfigIService {
TDataNodeInfoResp getDataNodeInfo(i32 dataNodeId)
+ /* Show Cluster */
+ TClusterNodeInfos getAllClusterNodeInfos()
+
/* StorageGroup */
common.TSStatus setStorageGroup(TSetStorageGroupReq req)