add showAvailableUrls
diff --git a/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4 b/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4 index 475a40d..c92989c 100644 --- a/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4 +++ b/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
@@ -61,7 +61,7 @@ // CQ | createContinuousQuery | dropContinuousQuery | showContinuousQueries // Cluster - | showVariables | showCluster | showRegions | showDataNodes | showConfigNodes | showClusterId + | showVariables | showCluster | showRegions | showDataNodes | showAvailableUrls | showConfigNodes | showClusterId | getRegionId | getTimeSlotList | countTimeSlotList | getSeriesSlotList | migrateRegion | reconstructRegion | extendRegion | removeRegion | removeDataNode | removeConfigNode | removeAINode | verifyConnection @@ -486,6 +486,11 @@ : SHOW DATANODES ; +// ---- Show Available Urls +showAvailableUrls + : SHOW AVAILABLE URLS + ; + // ---- Show Config Nodes showConfigNodes : SHOW CONFIGNODES
diff --git a/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4 b/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4 index 0054bf7..6a6d1e1 100644 --- a/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4 +++ b/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4
@@ -246,6 +246,14 @@ : D A T A N O D E S ; +AVAILABLE + : A V A I L A B L E + ; + +URLS + : U R L S + ; + DATASET : D A T A S E T ;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/common/header/DatasetHeaderFactory.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/common/header/DatasetHeaderFactory.java index c69dee7..4bc8a37 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/common/header/DatasetHeaderFactory.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/common/header/DatasetHeaderFactory.java
@@ -129,6 +129,10 @@ return new DatasetHeader(ColumnHeaderConstant.showDataNodesColumnHeaders, true); } + public static DatasetHeader getShowAvailableUrlsHeader() { + return new DatasetHeader(ColumnHeaderConstant.showAvailableUrlsColumnHeaders, true); + } + public static DatasetHeader getShowConfigNodesHeader() { return new DatasetHeader(ColumnHeaderConstant.showConfigNodesColumnHeaders, true); }
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/Coordinator.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/Coordinator.java index e9f952f..a7cf842 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/Coordinator.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/Coordinator.java
@@ -94,6 +94,7 @@ import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.SetSystemStatus; import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.SetTableComment; import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowAINodes; +import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowAvailableUrls; import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowCluster; import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowClusterId; import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowConfigNodes; @@ -432,6 +433,7 @@ || statement instanceof ShowCluster || statement instanceof ShowRegions || statement instanceof ShowDataNodes + || statement instanceof ShowAvailableUrls || statement instanceof ShowConfigNodes || statement instanceof ShowAINodes || statement instanceof Flush
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TableConfigTaskVisitor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TableConfigTaskVisitor.java index 6974d32..1e316bf 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TableConfigTaskVisitor.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TableConfigTaskVisitor.java
@@ -49,6 +49,7 @@ import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.RemoveAINodeTask; import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.RemoveConfigNodeTask; import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.RemoveDataNodeTask; +import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.ShowAvailableUrlsTask; import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.ShowClusterIdTask; import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.ShowClusterTask; import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.ShowFunctionsTask; @@ -175,6 +176,7 @@ import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.SetSystemStatus; import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.SetTableComment; import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowAINodes; +import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowAvailableUrls; import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowCluster; import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowClusterId; import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowConfigNodes; @@ -462,6 +464,13 @@ } @Override + protected IConfigTask visitShowAvailableUrls( + final ShowAvailableUrls showAvailableUrls, final MPPQueryContext context) { + context.setQueryType(QueryType.READ); + return new ShowAvailableUrlsTask(); + } + + @Override protected IConfigTask visitShowConfigNodes( final ShowConfigNodes showConfigNodesStatement, final MPPQueryContext context) { context.setQueryType(QueryType.READ);
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TreeConfigTaskVisitor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TreeConfigTaskVisitor.java index b2ea4a2..e74053f 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TreeConfigTaskVisitor.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TreeConfigTaskVisitor.java
@@ -48,6 +48,7 @@ import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.RemoveDataNodeTask; import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.SetTTLTask; import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.ShowAINodesTask; +import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.ShowAvailableUrlsTask; import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.ShowClusterDetailsTask; import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.ShowClusterIdTask; import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.ShowClusterTask; @@ -134,6 +135,7 @@ import org.apache.iotdb.db.queryengine.plan.statement.metadata.RemoveConfigNodeStatement; import org.apache.iotdb.db.queryengine.plan.statement.metadata.RemoveDataNodeStatement; import org.apache.iotdb.db.queryengine.plan.statement.metadata.SetTTLStatement; +import org.apache.iotdb.db.queryengine.plan.statement.metadata.ShowAvailableUrlsStatement; import org.apache.iotdb.db.queryengine.plan.statement.metadata.ShowClusterIdStatement; import org.apache.iotdb.db.queryengine.plan.statement.metadata.ShowClusterStatement; import org.apache.iotdb.db.queryengine.plan.statement.metadata.ShowConfigNodesStatement; @@ -522,6 +524,12 @@ } @Override + public IConfigTask visitShowAvailableUrls( + ShowAvailableUrlsStatement showAvailableUrlsStatement, MPPQueryContext context) { + return new ShowAvailableUrlsTask(); + } + + @Override public IConfigTask visitShowConfigNodes( ShowConfigNodesStatement showConfigNodesStatement, MPPQueryContext context) { return new ShowConfigNodesTask();
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java index 4b3771c..e3970b7 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java
@@ -189,6 +189,7 @@ import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.GetSeriesSlotListTask; import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.GetTimeSlotListTask; import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.ShowAINodesTask; +import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.ShowAvailableUrlsTask; import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.ShowClusterDetailsTask; import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.ShowClusterIdTask; import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.ShowClusterTask; @@ -1690,6 +1691,26 @@ } @Override + public SettableFuture<ConfigTaskResult> showAvailableUrls() { + final SettableFuture<ConfigTaskResult> future = SettableFuture.create(); + TShowDataNodesResp showDataNodesResp = new TShowDataNodesResp(); + try (final ConfigNodeClient client = + CONFIG_NODE_CLIENT_MANAGER.borrowClient(ConfigNodeInfo.CONFIG_REGION_ID)) { + showDataNodesResp = client.showDataNodes(); + if (showDataNodesResp.getStatus().getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) { + future.setException( + new IoTDBException( + showDataNodesResp.getStatus().message, showDataNodesResp.getStatus().code)); + return future; + } + } catch (final ClientManagerException | TException e) { + future.setException(e); + } + ShowAvailableUrlsTask.buildTsBlock(showDataNodesResp, future); + return future; + } + + @Override public SettableFuture<ConfigTaskResult> showConfigNodes() { final SettableFuture<ConfigTaskResult> future = SettableFuture.create(); TShowConfigNodesResp showConfigNodesResp = new TShowConfigNodesResp();
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/IConfigTaskExecutor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/IConfigTaskExecutor.java index 781d704..4bb758f 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/IConfigTaskExecutor.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/IConfigTaskExecutor.java
@@ -182,6 +182,8 @@ SettableFuture<ConfigTaskResult> showDataNodes(); + SettableFuture<ConfigTaskResult> showAvailableUrls(); + SettableFuture<ConfigTaskResult> showConfigNodes(); SettableFuture<ConfigTaskResult> showAINodes();
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/metadata/ShowAvailableUrlsTask.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/metadata/ShowAvailableUrlsTask.java new file mode 100644 index 0000000..9cdcf0d --- /dev/null +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/metadata/ShowAvailableUrlsTask.java
@@ -0,0 +1,75 @@ +/* + * 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.queryengine.plan.execution.config.metadata; + +import org.apache.iotdb.commons.schema.column.ColumnHeader; +import org.apache.iotdb.commons.schema.column.ColumnHeaderConstant; +import org.apache.iotdb.confignode.rpc.thrift.TDataNodeInfo; +import org.apache.iotdb.confignode.rpc.thrift.TShowDataNodesResp; +import org.apache.iotdb.db.queryengine.common.header.DatasetHeader; +import org.apache.iotdb.db.queryengine.common.header.DatasetHeaderFactory; +import org.apache.iotdb.db.queryengine.plan.execution.config.ConfigTaskResult; +import org.apache.iotdb.db.queryengine.plan.execution.config.IConfigTask; +import org.apache.iotdb.db.queryengine.plan.execution.config.executor.IConfigTaskExecutor; +import org.apache.iotdb.rpc.TSStatusCode; + +import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.SettableFuture; +import org.apache.tsfile.enums.TSDataType; +import org.apache.tsfile.read.common.block.TsBlockBuilder; +import org.apache.tsfile.utils.BytesUtils; + +import java.util.List; +import java.util.stream.Collectors; + +public class ShowAvailableUrlsTask implements IConfigTask { + + @Override + public ListenableFuture<ConfigTaskResult> execute(IConfigTaskExecutor configTaskExecutor) + throws InterruptedException { + return configTaskExecutor.showAvailableUrls(); + } + + public static void buildTsBlock( + TShowDataNodesResp showDataNodesResp, SettableFuture<ConfigTaskResult> future) { + List<TSDataType> outputDataTypes = + ColumnHeaderConstant.showAvailableUrlsColumnHeaders.stream() + .map(ColumnHeader::getColumnType) + .collect(Collectors.toList()); + TsBlockBuilder builder = new TsBlockBuilder(outputDataTypes); + if (showDataNodesResp.getDataNodesInfoList() != null) { + for (TDataNodeInfo dataNodeInfo : showDataNodesResp.getDataNodesInfoList()) { + builder.getTimeColumnBuilder().writeLong(0L); + builder.getColumnBuilder(0).writeInt(dataNodeInfo.getDataNodeId()); + builder + .getColumnBuilder(1) + .writeBinary( + BytesUtils.valueOf( + dataNodeInfo.getStatus() == null ? "" : dataNodeInfo.getStatus())); + + builder.getColumnBuilder(2).writeBinary(BytesUtils.valueOf(dataNodeInfo.getRpcAddresss())); + builder.getColumnBuilder(3).writeInt(dataNodeInfo.getRpcPort()); + builder.declarePosition(); + } + } + DatasetHeader datasetHeader = DatasetHeaderFactory.getShowAvailableUrlsHeader(); + future.set(new ConfigTaskResult(TSStatusCode.SUCCESS_STATUS, builder.build(), datasetHeader)); + } +}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java index 8b9f65d..77fd34d 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java
@@ -168,6 +168,7 @@ import org.apache.iotdb.db.queryengine.plan.statement.metadata.RemoveConfigNodeStatement; import org.apache.iotdb.db.queryengine.plan.statement.metadata.RemoveDataNodeStatement; import org.apache.iotdb.db.queryengine.plan.statement.metadata.SetTTLStatement; +import org.apache.iotdb.db.queryengine.plan.statement.metadata.ShowAvailableUrlsStatement; import org.apache.iotdb.db.queryengine.plan.statement.metadata.ShowChildNodesStatement; import org.apache.iotdb.db.queryengine.plan.statement.metadata.ShowChildPathsStatement; import org.apache.iotdb.db.queryengine.plan.statement.metadata.ShowClusterIdStatement; @@ -3631,6 +3632,11 @@ return new ShowDataNodesStatement(); } + @Override + public Statement visitShowAvailableUrls(IoTDBSqlParser.ShowAvailableUrlsContext ctx) { + return new ShowAvailableUrlsStatement(); + } + // show confignodes @Override
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/AstVisitor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/AstVisitor.java index f4ceb11..46f85b3 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/AstVisitor.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/AstVisitor.java
@@ -393,6 +393,10 @@ return visitStatement(node, context); } + protected R visitShowAvailableUrls(ShowAvailableUrls node, C context) { + return visitStatement(node, context); + } + protected R visitShowConfigNodes(ShowConfigNodes node, C context) { return visitStatement(node, context); }
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/ShowAvailableUrls.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/ShowAvailableUrls.java new file mode 100644 index 0000000..2117cdf --- /dev/null +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/ShowAvailableUrls.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.db.queryengine.plan.relational.sql.ast; + +import com.google.common.collect.ImmutableList; + +import java.util.List; + +import static com.google.common.base.MoreObjects.toStringHelper; + +public class ShowAvailableUrls extends Statement { + + public ShowAvailableUrls() { + super(null); + } + + @Override + public <R, C> R accept(AstVisitor<R, C> visitor, C context) { + return visitor.visitShowAvailableUrls(this, context); + } + + @Override + public List<Node> getChildren() { + return ImmutableList.of(); + } + + @Override + public int hashCode() { + return 0; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + return (obj != null) && (getClass() == obj.getClass()); + } + + @Override + public String toString() { + return toStringHelper(this).toString(); + } +}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/parser/AstBuilder.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/parser/AstBuilder.java index 5d7333e..4cd5ecf 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/parser/AstBuilder.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/parser/AstBuilder.java
@@ -174,6 +174,7 @@ import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.SetSystemStatus; import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.SetTableComment; import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowAINodes; +import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowAvailableUrls; import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowCluster; import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowClusterId; import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowConfigNodes; @@ -1378,6 +1379,12 @@ } @Override + public Node visitShowAvailableUrlsStatement( + RelationalSqlParser.ShowAvailableUrlsStatementContext ctx) { + return new ShowAvailableUrls(); + } + + @Override public Node visitShowConfigNodesStatement( RelationalSqlParser.ShowConfigNodesStatementContext ctx) { return new ShowConfigNodes();
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/StatementType.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/StatementType.java index 748241d..4bc10b2 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/StatementType.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/StatementType.java
@@ -187,5 +187,6 @@ SET_CONFIGURATION, - FAST_LAST_QUERY + FAST_LAST_QUERY, + SHOW_CONFIGURATION, }
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/StatementVisitor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/StatementVisitor.java index 3fb12232..a1ebac3 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/StatementVisitor.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/StatementVisitor.java
@@ -59,6 +59,7 @@ import org.apache.iotdb.db.queryengine.plan.statement.metadata.RemoveConfigNodeStatement; import org.apache.iotdb.db.queryengine.plan.statement.metadata.RemoveDataNodeStatement; import org.apache.iotdb.db.queryengine.plan.statement.metadata.SetTTLStatement; +import org.apache.iotdb.db.queryengine.plan.statement.metadata.ShowAvailableUrlsStatement; import org.apache.iotdb.db.queryengine.plan.statement.metadata.ShowChildNodesStatement; import org.apache.iotdb.db.queryengine.plan.statement.metadata.ShowChildPathsStatement; import org.apache.iotdb.db.queryengine.plan.statement.metadata.ShowClusterIdStatement; @@ -475,6 +476,11 @@ return visitStatement(showDataNodesStatement, context); } + public R visitShowAvailableUrls( + ShowAvailableUrlsStatement showAvailableUrlsStatement, C context) { + return visitStatement(showAvailableUrlsStatement, context); + } + public R visitShowConfigNodes(ShowConfigNodesStatement showConfigNodesStatement, C context) { return visitStatement(showConfigNodesStatement, context); }
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/metadata/ShowAvailableUrlsStatement.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/metadata/ShowAvailableUrlsStatement.java new file mode 100644 index 0000000..cbdf8cb --- /dev/null +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/metadata/ShowAvailableUrlsStatement.java
@@ -0,0 +1,55 @@ +/* + * 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.queryengine.plan.statement.metadata; + +import org.apache.iotdb.common.rpc.thrift.TSStatus; +import org.apache.iotdb.db.queryengine.plan.analyze.QueryType; +import org.apache.iotdb.db.queryengine.plan.statement.IConfigStatement; +import org.apache.iotdb.db.queryengine.plan.statement.StatementType; +import org.apache.iotdb.db.queryengine.plan.statement.StatementVisitor; +import org.apache.iotdb.rpc.RpcUtils; + +public class ShowAvailableUrlsStatement extends ShowStatement implements IConfigStatement { + + public ShowAvailableUrlsStatement() { + super(); + this.statementType = StatementType.SHOW; + } + + @Override + public TSStatus checkPermissionBeforeProcess(String userName) { + return RpcUtils.SUCCESS_STATUS; + } + + @Override + public TSStatus checkSeparatedAdminPermissionBeforeProcess(String userName) { + return RpcUtils.SUCCESS_STATUS; + } + + @Override + public QueryType getQueryType() { + return QueryType.READ; + } + + @Override + public <R, C> R accept(StatementVisitor<R, C> visitor, C context) { + return visitor.visitShowAvailableUrls(this, context); + } +}
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 567df04..5214f2b 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
@@ -456,6 +456,13 @@ new ColumnHeader(DATA_REGION_NUM, TSDataType.INT32), new ColumnHeader(SCHEMA_REGION_NUM, TSDataType.INT32)); + public static final List<ColumnHeader> showAvailableUrlsColumnHeaders = + 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)); + public static final List<ColumnHeader> showConfigNodesColumnHeaders = ImmutableList.of( new ColumnHeader(NODE_ID, TSDataType.INT32),
diff --git a/iotdb-core/relational-grammar/src/main/antlr4/org/apache/iotdb/db/relational/grammar/sql/RelationalSql.g4 b/iotdb-core/relational-grammar/src/main/antlr4/org/apache/iotdb/db/relational/grammar/sql/RelationalSql.g4 index f7f5517..e96f24e 100644 --- a/iotdb-core/relational-grammar/src/main/antlr4/org/apache/iotdb/db/relational/grammar/sql/RelationalSql.g4 +++ b/iotdb-core/relational-grammar/src/main/antlr4/org/apache/iotdb/db/relational/grammar/sql/RelationalSql.g4
@@ -113,6 +113,7 @@ | showClusterStatement | showRegionsStatement | showDataNodesStatement + | showAvailableUrlsStatement | showConfigNodesStatement | showAINodesStatement | showClusterIdStatement @@ -541,6 +542,10 @@ : SHOW DATANODES ; +showAvailableUrlsStatement + : SHOW AVAILABLE URLS + ; + showConfigNodesStatement : SHOW CONFIGNODES ; @@ -1454,6 +1459,8 @@ DATABASES: 'DATABASES'; DATANODE: 'DATANODE'; DATANODES: 'DATANODES'; +AVAILABLE: 'AVAILABLE'; +URLS: 'URLS'; DATASET: 'DATASET'; DATE: 'DATE'; DATE_BIN: 'DATE_BIN';