From fef0770fe4cd6a14716b3eebf4e9026a1ef795dc Mon Sep 17 00:00:00 2001 From: jakevin <30525741+jackwener@users.noreply.github.com> Date: Fri, 11 Feb 2022 14:08:44 +0800 Subject: [PATCH] Add http port for show (#3808) * add http port * fix review * fix * fix --- src/graph/executor/admin/ShowHostsExecutor.cpp | 2 ++ src/graph/executor/admin/ShowHostsExecutor.h | 2 ++ src/graph/executor/test/CMakeLists.txt | 1 + src/graph/validator/MatchValidator.cpp | 10 +++++----- tests/admin/test_show_hosts.py | 2 ++ tests/tck/features/admin/Hosts.feature | 4 ++-- tests/tck/features/parser/Example.feature | 4 ++-- 7 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/graph/executor/admin/ShowHostsExecutor.cpp b/src/graph/executor/admin/ShowHostsExecutor.cpp index f02a8acabed..1b317949447 100644 --- a/src/graph/executor/admin/ShowHostsExecutor.cpp +++ b/src/graph/executor/admin/ShowHostsExecutor.cpp @@ -27,6 +27,7 @@ folly::Future ShowHostsExecutor::showHosts() { auto makeTraditionalResult = [&](const std::vector &hostVec) -> DataSet { DataSet v({"Host", "Port", + "HTTP port", "Status", "Leader count", "Leader distribution", @@ -40,6 +41,7 @@ folly::Future ShowHostsExecutor::showHosts() { for (const auto &host : hostVec) { nebula::Row r({host.get_hostAddr().host, host.get_hostAddr().port, + FLAGS_ws_http_port, apache::thrift::util::enumNameSafe(host.get_status())}); int64_t leaderCount = 0; for (const auto &spaceEntry : host.get_leader_parts()) { diff --git a/src/graph/executor/admin/ShowHostsExecutor.h b/src/graph/executor/admin/ShowHostsExecutor.h index 3e53f4c118a..5ef27542f61 100644 --- a/src/graph/executor/admin/ShowHostsExecutor.h +++ b/src/graph/executor/admin/ShowHostsExecutor.h @@ -8,6 +8,8 @@ #include "graph/executor/Executor.h" +DECLARE_int32(ws_http_port); + namespace nebula { namespace graph { diff --git a/src/graph/executor/test/CMakeLists.txt b/src/graph/executor/test/CMakeLists.txt index 1952728188d..8aa3220c152 100644 --- a/src/graph/executor/test/CMakeLists.txt +++ b/src/graph/executor/test/CMakeLists.txt @@ -3,6 +3,7 @@ # This source code is licensed under Apache 2.0 License. SET(EXEC_QUERY_TEST_OBJS + $ $ $ $ diff --git a/src/graph/validator/MatchValidator.cpp b/src/graph/validator/MatchValidator.cpp index b079c3e7709..3cb3471beb0 100644 --- a/src/graph/validator/MatchValidator.cpp +++ b/src/graph/validator/MatchValidator.cpp @@ -30,11 +30,11 @@ Status MatchValidator::validateImpl() { retClauseCtx->yield = std::move(retYieldCtx); cypherCtx_->queryParts.emplace_back(); - for (size_t i = 0; i < clauses.size(); ++i) { - auto kind = clauses[i]->kind(); + for (auto &clause : clauses) { + auto kind = clause->kind(); switch (kind) { case ReadingClause::Kind::kMatch: { - auto *matchClause = static_cast(clauses[i].get()); + auto *matchClause = static_cast(clause.get()); auto matchClauseCtx = getContext(); matchClauseCtx->isOptional = matchClause->isOptional(); @@ -64,7 +64,7 @@ Status MatchValidator::validateImpl() { break; } case ReadingClause::Kind::kUnwind: { - auto *unwindClause = static_cast(clauses[i].get()); + auto *unwindClause = static_cast(clause.get()); auto unwindClauseCtx = getContext(); unwindClauseCtx->aliasesAvailable = aliasesAvailable; NG_RETURN_IF_ERROR(validateUnwind(unwindClause, *unwindClauseCtx)); @@ -79,7 +79,7 @@ Status MatchValidator::validateImpl() { break; } case ReadingClause::Kind::kWith: { - auto *withClause = static_cast(clauses[i].get()); + auto *withClause = static_cast(clause.get()); auto withClauseCtx = getContext(); auto withYieldCtx = getContext(); withClauseCtx->yield = std::move(withYieldCtx); diff --git a/tests/admin/test_show_hosts.py b/tests/admin/test_show_hosts.py index 49fe6e465e7..f4b6846d8dd 100644 --- a/tests/admin/test_show_hosts.py +++ b/tests/admin/test_show_hosts.py @@ -23,12 +23,14 @@ def test_show_hosts(self): query = "SHOW HOSTS"; expected_column_names = ['Host', 'Port', + 'HTTP port', 'Status', 'Leader count', 'Leader distribution', 'Partition distribution', 'Version'] expected_result_format = [[re.compile(r'\S+'), + re.compile(r'\d+'), re.compile(r'\d+'), re.compile(r'ONLINE|OFFLINE'), re.compile(r'\d+'), diff --git a/tests/tck/features/admin/Hosts.feature b/tests/tck/features/admin/Hosts.feature index ec604f5f552..8a067cfb43e 100644 --- a/tests/tck/features/admin/Hosts.feature +++ b/tests/tck/features/admin/Hosts.feature @@ -9,8 +9,8 @@ Feature: Admin hosts SHOW HOSTS; """ Then the result should contain: - | Host | Port | Status | Leader count | Leader distribution | Partition distribution | Version | - | /\w+/ | /\d+/ | "ONLINE" | /\d+/ | /.*/ | /.*/ | /.*/ | + | Host | Port | HTTP port | Status | Leader count | Leader distribution | Partition distribution | Version | + | /\w+/ | /\d+/ | /\d+/ | "ONLINE" | /\d+/ | /.*/ | /.*/ | /.*/ | When executing query: """ SHOW HOSTS GRAPH; diff --git a/tests/tck/features/parser/Example.feature b/tests/tck/features/parser/Example.feature index 43e4d866206..0880a474a74 100644 --- a/tests/tck/features/parser/Example.feature +++ b/tests/tck/features/parser/Example.feature @@ -24,8 +24,8 @@ Feature: Feature examples SHOW HOSTS """ Then the result should contain: - | Host | Port | Status | Leader count | Leader distribution | Partition distribution | Version | - | /\w+/ | /\d+/ | "ONLINE" | /\d+/ | /.*/ | /.*/ | /.*/ | + | Host | Port | HTTP port | Status | Leader count | Leader distribution | Partition distribution | Version | + | /\w+/ | /\d+/ | /\d+/ | "ONLINE" | /\d+/ | /.*/ | /.*/ | /.*/ | When executing query: """ SHOW HOSTS