From ccc466a58ded6cd928fbcacfd9dd92b99941e3b0 Mon Sep 17 00:00:00 2001 From: yaphet <4414314+darionyaphet@users.noreply.github.com> Date: Wed, 24 Nov 2021 20:34:25 +0800 Subject: [PATCH] Remove group relevant component (#3330) * Remove group relevant component * fix test case --- src/clients/meta/MetaClient.cpp | 96 ------ src/clients/meta/MetaClient.h | 12 - src/graph/executor/CMakeLists.txt | 1 - src/graph/executor/Executor.cpp | 19 -- src/graph/executor/admin/GroupExecutor.cpp | 129 -------- src/graph/executor/admin/GroupExecutor.h | 65 ---- src/graph/planner/plan/Admin.h | 142 -------- src/graph/planner/plan/PlanNode.cpp | 12 - src/graph/planner/plan/PlanNode.h | 6 - src/graph/service/PermissionCheck.cpp | 6 - src/graph/validator/MaintainValidator.cpp | 68 ---- src/graph/validator/MaintainValidator.h | 74 ----- src/graph/validator/Validator.cpp | 12 - src/interface/meta.thrift | 50 --- src/meta/CMakeLists.txt | 5 - src/meta/MetaServiceHandler.cpp | 39 --- src/meta/MetaServiceHandler.h | 14 - .../processors/zone/AddGroupProcessor.cpp | 126 -------- src/meta/processors/zone/AddGroupProcessor.h | 31 -- .../processors/zone/DropGroupProcessor.cpp | 65 ---- src/meta/processors/zone/DropGroupProcessor.h | 31 -- .../processors/zone/GetGroupProcessor.cpp | 46 --- src/meta/processors/zone/GetGroupProcessor.h | 29 -- .../processors/zone/ListGroupsProcessor.cpp | 41 --- .../processors/zone/ListGroupsProcessor.h | 29 -- .../processors/zone/UpdateGroupProcessor.cpp | 155 --------- .../processors/zone/UpdateGroupProcessor.h | 42 --- src/meta/test/GroupZoneTest.cpp | 302 ------------------ src/meta/test/MetaClientTest.cpp | 183 ----------- src/meta/test/ProcessorTest.cpp | 296 ----------------- src/parser/MaintainSentences.cpp | 30 -- src/parser/MaintainSentences.h | 94 ------ src/parser/Sentence.h | 6 - src/parser/parser.yy | 55 ---- src/parser/test/ParserTest.cpp | 35 -- tests/maintain/test_zone.py | 33 -- 36 files changed, 2379 deletions(-) delete mode 100644 src/graph/executor/admin/GroupExecutor.cpp delete mode 100644 src/graph/executor/admin/GroupExecutor.h delete mode 100644 src/meta/processors/zone/AddGroupProcessor.cpp delete mode 100644 src/meta/processors/zone/AddGroupProcessor.h delete mode 100644 src/meta/processors/zone/DropGroupProcessor.cpp delete mode 100644 src/meta/processors/zone/DropGroupProcessor.h delete mode 100644 src/meta/processors/zone/GetGroupProcessor.cpp delete mode 100644 src/meta/processors/zone/GetGroupProcessor.h delete mode 100644 src/meta/processors/zone/ListGroupsProcessor.cpp delete mode 100644 src/meta/processors/zone/ListGroupsProcessor.h delete mode 100644 src/meta/processors/zone/UpdateGroupProcessor.cpp delete mode 100644 src/meta/processors/zone/UpdateGroupProcessor.h diff --git a/src/clients/meta/MetaClient.cpp b/src/clients/meta/MetaClient.cpp index 21880d788ae..7576b0f9649 100644 --- a/src/clients/meta/MetaClient.cpp +++ b/src/clients/meta/MetaClient.cpp @@ -3116,102 +3116,6 @@ folly::Future>> MetaClient::listZones() { return future; } -folly::Future> MetaClient::addGroup(std::string groupName, - std::vector zoneNames) { - cpp2::AddGroupReq req; - req.set_group_name(std::move(groupName)); - req.set_zone_names(std::move(zoneNames)); - - folly::Promise> promise; - auto future = promise.getFuture(); - getResponse( - std::move(req), - [](auto client, auto request) { return client->future_addGroup(request); }, - [](cpp2::ExecResp&& resp) -> bool { - return resp.get_code() == nebula::cpp2::ErrorCode::SUCCEEDED; - }, - std::move(promise)); - return future; -} - -folly::Future> MetaClient::dropGroup(std::string groupName) { - cpp2::DropGroupReq req; - req.set_group_name(std::move(groupName)); - - folly::Promise> promise; - auto future = promise.getFuture(); - getResponse( - std::move(req), - [](auto client, auto request) { return client->future_dropGroup(request); }, - [](cpp2::ExecResp&& resp) -> bool { - return resp.get_code() == nebula::cpp2::ErrorCode::SUCCEEDED; - }, - std::move(promise)); - return future; -} - -folly::Future> MetaClient::addZoneIntoGroup(std::string zoneName, - std::string groupName) { - cpp2::AddZoneIntoGroupReq req; - req.set_zone_name(zoneName); - req.set_group_name(groupName); - - folly::Promise> promise; - auto future = promise.getFuture(); - getResponse( - std::move(req), - [](auto client, auto request) { return client->future_addZoneIntoGroup(request); }, - [](cpp2::ExecResp&& resp) -> bool { - return resp.get_code() == nebula::cpp2::ErrorCode::SUCCEEDED; - }, - std::move(promise)); - return future; -} - -folly::Future> MetaClient::dropZoneFromGroup(std::string zoneName, - std::string groupName) { - cpp2::DropZoneFromGroupReq req; - req.set_zone_name(zoneName); - req.set_group_name(groupName); - - folly::Promise> promise; - auto future = promise.getFuture(); - getResponse( - std::move(req), - [](auto client, auto request) { return client->future_dropZoneFromGroup(request); }, - [](cpp2::ExecResp&& resp) -> bool { - return resp.get_code() == nebula::cpp2::ErrorCode::SUCCEEDED; - }, - std::move(promise)); - return future; -} - -folly::Future>> MetaClient::getGroup(std::string groupName) { - cpp2::GetGroupReq req; - req.set_group_name(std::move(groupName)); - - folly::Promise>> promise; - auto future = promise.getFuture(); - getResponse( - std::move(req), - [](auto client, auto request) { return client->future_getGroup(request); }, - [](cpp2::GetGroupResp&& resp) -> decltype(auto) { return resp.get_zone_names(); }, - std::move(promise)); - return future; -} - -folly::Future>> MetaClient::listGroups() { - cpp2::ListGroupsReq req; - folly::Promise>> promise; - auto future = promise.getFuture(); - getResponse( - std::move(req), - [](auto client, auto request) { return client->future_listGroups(request); }, - [](cpp2::ListGroupsResp&& resp) -> decltype(auto) { return resp.get_groups(); }, - std::move(promise)); - return future; -} - folly::Future> MetaClient::getStats(GraphSpaceID spaceId) { cpp2::GetStatsReq req; req.set_space_id(spaceId); diff --git a/src/clients/meta/MetaClient.h b/src/clients/meta/MetaClient.h index 4e19f2e79ee..0bb794c6178 100644 --- a/src/clients/meta/MetaClient.h +++ b/src/clients/meta/MetaClient.h @@ -607,18 +607,6 @@ class MetaClient { folly::Future>> listZones(); - folly::Future> addGroup(std::string groupName, std::vector zoneNames); - - folly::Future> dropGroup(std::string groupName); - - folly::Future> addZoneIntoGroup(std::string zoneName, std::string groupName); - - folly::Future> dropZoneFromGroup(std::string zoneName, std::string groupName); - - folly::Future>> getGroup(std::string groupName); - - folly::Future>> listGroups(); - Status refreshCache(); folly::Future> getStats(GraphSpaceID spaceId); diff --git a/src/graph/executor/CMakeLists.txt b/src/graph/executor/CMakeLists.txt index 261f9128113..b7270c16ff9 100644 --- a/src/graph/executor/CMakeLists.txt +++ b/src/graph/executor/CMakeLists.txt @@ -64,7 +64,6 @@ nebula_add_library( admin/DownloadExecutor.cpp admin/IngestExecutor.cpp admin/ConfigExecutor.cpp - admin/GroupExecutor.cpp admin/ZoneExecutor.cpp admin/ShowTSClientsExecutor.cpp admin/SignInTSServiceExecutor.cpp diff --git a/src/graph/executor/Executor.cpp b/src/graph/executor/Executor.cpp index 93115ba4fc8..27a6985e620 100644 --- a/src/graph/executor/Executor.cpp +++ b/src/graph/executor/Executor.cpp @@ -23,7 +23,6 @@ #include "graph/executor/admin/DownloadExecutor.h" #include "graph/executor/admin/DropUserExecutor.h" #include "graph/executor/admin/GrantRoleExecutor.h" -#include "graph/executor/admin/GroupExecutor.h" #include "graph/executor/admin/IngestExecutor.h" #include "graph/executor/admin/KillQueryExecutor.h" #include "graph/executor/admin/ListRolesExecutor.h" @@ -431,24 +430,6 @@ Executor *Executor::makeExecutor(QueryContext *qctx, const PlanNode *node) { case PlanNode::Kind::kSubgraph: { return pool->add(new SubgraphExecutor(node, qctx)); } - case PlanNode::Kind::kAddGroup: { - return pool->add(new AddGroupExecutor(node, qctx)); - } - case PlanNode::Kind::kDropGroup: { - return pool->add(new DropGroupExecutor(node, qctx)); - } - case PlanNode::Kind::kDescribeGroup: { - return pool->add(new DescribeGroupExecutor(node, qctx)); - } - case PlanNode::Kind::kAddZoneIntoGroup: { - return pool->add(new AddZoneIntoGroupExecutor(node, qctx)); - } - case PlanNode::Kind::kDropZoneFromGroup: { - return pool->add(new DropZoneFromGroupExecutor(node, qctx)); - } - case PlanNode::Kind::kShowGroups: { - return pool->add(new ListGroupsExecutor(node, qctx)); - } case PlanNode::Kind::kAddZone: { return pool->add(new AddZoneExecutor(node, qctx)); } diff --git a/src/graph/executor/admin/GroupExecutor.cpp b/src/graph/executor/admin/GroupExecutor.cpp deleted file mode 100644 index 462690f8f27..00000000000 --- a/src/graph/executor/admin/GroupExecutor.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/* Copyright (c) 2020 vesoft inc. All rights reserved. - * - * This source code is licensed under Apache 2.0 License. - */ - -#include "graph/executor/admin/GroupExecutor.h" - -#include "common/time/ScopedTimer.h" -#include "graph/planner/plan/Admin.h" - -namespace nebula { -namespace graph { - -folly::Future AddGroupExecutor::execute() { - SCOPED_TIMER(&execTime_); - auto *agNode = asNode(node()); - return qctx() - ->getMetaClient() - ->addGroup(agNode->groupName(), agNode->zoneNames()) - .via(runner()) - .thenValue([](StatusOr resp) { - if (!resp.ok()) { - LOG(ERROR) << "Add Group Failed: " << resp.status(); - return resp.status(); - } - return Status::OK(); - }); -} - -folly::Future DropGroupExecutor::execute() { - SCOPED_TIMER(&execTime_); - auto *dgNode = asNode(node()); - return qctx() - ->getMetaClient() - ->dropGroup(dgNode->groupName()) - .via(runner()) - .thenValue([](StatusOr resp) { - if (!resp.ok()) { - LOG(ERROR) << "Drop Group Failed: " << resp.status(); - return resp.status(); - } - return Status::OK(); - }); -} - -folly::Future DescribeGroupExecutor::execute() { - SCOPED_TIMER(&execTime_); - auto *dgNode = asNode(node()); - return qctx() - ->getMetaClient() - ->getGroup(dgNode->groupName()) - .via(runner()) - .thenValue([this](StatusOr> resp) { - if (!resp.ok()) { - LOG(ERROR) << "Describe Group Failed: " << resp.status(); - return resp.status(); - } - - auto zones = std::move(resp).value(); - DataSet dataSet({"Zone"}); - for (auto &zone : zones) { - Row row({zone}); - dataSet.rows.emplace_back(std::move(row)); - } - return finish(ResultBuilder() - .value(Value(std::move(dataSet))) - .iter(Iterator::Kind::kDefault) - .build()); - }); -} - -folly::Future AddZoneIntoGroupExecutor::execute() { - SCOPED_TIMER(&execTime_); - auto *azNode = asNode(node()); - return qctx() - ->getMetaClient() - ->addZoneIntoGroup(azNode->zoneName(), azNode->groupName()) - .via(runner()) - .thenValue([](StatusOr resp) { - if (!resp.ok()) { - LOG(ERROR) << "Add Zone Into Group Failed: " << resp.status(); - return resp.status(); - } - return Status::OK(); - }); -} - -folly::Future DropZoneFromGroupExecutor::execute() { - SCOPED_TIMER(&execTime_); - auto *dzNode = asNode(node()); - return qctx() - ->getMetaClient() - ->dropZoneFromGroup(dzNode->zoneName(), dzNode->groupName()) - .via(runner()) - .thenValue([](StatusOr resp) { - if (!resp.ok()) { - LOG(ERROR) << "Drop Zone From Group Failed: " << resp.status(); - return resp.status(); - } - return Status::OK(); - }); -} - -folly::Future ListGroupsExecutor::execute() { - SCOPED_TIMER(&execTime_); - return qctx()->getMetaClient()->listGroups().via(runner()).thenValue( - [this](StatusOr> resp) { - if (!resp.ok()) { - LOG(ERROR) << "List Groups Failed: " << resp.status(); - return resp.status(); - } - - auto groups = std::move(resp).value(); - DataSet dataSet({"Name", "Zone"}); - for (auto &group : groups) { - for (auto &zone : group.get_zone_names()) { - Row row({*group.group_name_ref(), zone}); - dataSet.rows.emplace_back(std::move(row)); - } - } - return finish(ResultBuilder() - .value(Value(std::move(dataSet))) - .iter(Iterator::Kind::kDefault) - .build()); - }); -} - -} // namespace graph -} // namespace nebula diff --git a/src/graph/executor/admin/GroupExecutor.h b/src/graph/executor/admin/GroupExecutor.h deleted file mode 100644 index 0cb38a3fd7f..00000000000 --- a/src/graph/executor/admin/GroupExecutor.h +++ /dev/null @@ -1,65 +0,0 @@ -/* Copyright (c) 2020 vesoft inc. All rights reserved. - * - * This source code is licensed under Apache 2.0 License. - */ - -#ifndef GRAPH_EXECUTOR_ADMIN_GROUPEXECUTOR_H_ -#define GRAPH_EXECUTOR_ADMIN_GROUPEXECUTOR_H_ - -#include "graph/executor/Executor.h" - -namespace nebula { -namespace graph { - -class AddGroupExecutor final : public Executor { - public: - AddGroupExecutor(const PlanNode *node, QueryContext *qctx) - : Executor("AddGroupExecutor", node, qctx) {} - - folly::Future execute() override; -}; - -class DropGroupExecutor final : public Executor { - public: - DropGroupExecutor(const PlanNode *node, QueryContext *qctx) - : Executor("DropGroupExecutor", node, qctx) {} - - folly::Future execute() override; -}; - -class DescribeGroupExecutor final : public Executor { - public: - DescribeGroupExecutor(const PlanNode *node, QueryContext *qctx) - : Executor("DescribeGroupExecutor", node, qctx) {} - - folly::Future execute() override; -}; - -class AddZoneIntoGroupExecutor final : public Executor { - public: - AddZoneIntoGroupExecutor(const PlanNode *node, QueryContext *qctx) - : Executor("AddZoneIntoGroupExecutor", node, qctx) {} - - folly::Future execute() override; -}; - -class DropZoneFromGroupExecutor final : public Executor { - public: - DropZoneFromGroupExecutor(const PlanNode *node, QueryContext *qctx) - : Executor("DropZoneFromGroupExecutor", node, qctx) {} - - folly::Future execute() override; -}; - -class ListGroupsExecutor final : public Executor { - public: - ListGroupsExecutor(const PlanNode *node, QueryContext *qctx) - : Executor("ListGroupsExecutor", node, qctx) {} - - folly::Future execute() override; -}; - -} // namespace graph -} // namespace nebula - -#endif // GRAPH_EXECUTOR_ADMIN_GROUPEXECUTOR_H_ diff --git a/src/graph/planner/plan/Admin.h b/src/graph/planner/plan/Admin.h index a49ea464c53..998fdea1fea 100644 --- a/src/graph/planner/plan/Admin.h +++ b/src/graph/planner/plan/Admin.h @@ -755,82 +755,6 @@ class ShowCollation final : public SingleDependencyNode { : SingleDependencyNode(qctx, Kind::kShowCollation, input) {} }; -class AddGroup final : public SingleDependencyNode { - public: - static AddGroup* make(QueryContext* qctx, - PlanNode* input, - std::string groupName, - std::vector zoneNames) { - return qctx->objPool()->add( - new AddGroup(qctx, input, std::move(groupName), std::move(zoneNames))); - } - - const std::string& groupName() const { return groupName_; } - - const std::vector& zoneNames() const { return zoneNames_; } - - private: - AddGroup(QueryContext* qctx, - PlanNode* input, - std::string groupName, - std::vector zoneNames) - : SingleDependencyNode(qctx, Kind::kAddGroup, input) { - groupName_ = std::move(groupName); - zoneNames_ = std::move(zoneNames); - } - - private: - std::string groupName_; - std::vector zoneNames_; -}; - -class DropGroup final : public SingleDependencyNode { - public: - static DropGroup* make(QueryContext* qctx, PlanNode* input, std::string groupName) { - return qctx->objPool()->add(new DropGroup(qctx, input, std::move(groupName))); - } - - const std::string& groupName() const { return groupName_; } - - private: - DropGroup(QueryContext* qctx, PlanNode* input, std::string groupName) - : SingleDependencyNode(qctx, Kind::kDropGroup, input) { - groupName_ = std::move(groupName); - } - - private: - std::string groupName_; -}; - -class DescribeGroup final : public SingleDependencyNode { - public: - static DescribeGroup* make(QueryContext* qctx, PlanNode* input, std::string groupName) { - return qctx->objPool()->add(new DescribeGroup(qctx, input, std::move(groupName))); - } - - const std::string& groupName() const { return groupName_; } - - private: - DescribeGroup(QueryContext* qctx, PlanNode* input, std::string groupName) - : SingleDependencyNode(qctx, Kind::kDescribeGroup, input) { - groupName_ = std::move(groupName); - } - - private: - std::string groupName_; -}; - -class ListGroups final : public SingleDependencyNode { - public: - static ListGroups* make(QueryContext* qctx, PlanNode* input) { - return qctx->objPool()->add(new ListGroups(qctx, input)); - } - - private: - ListGroups(QueryContext* qctx, PlanNode* input) - : SingleDependencyNode(qctx, Kind::kShowGroups, input) {} -}; - class AddHostIntoZone final : public SingleDependencyNode { public: static AddHostIntoZone* make(QueryContext* qctx, @@ -981,72 +905,6 @@ class ListZones final : public SingleDependencyNode { : SingleDependencyNode(qctx, Kind::kShowZones, input) {} }; -class AddZoneIntoGroup final : public SingleDependencyNode { - public: - static AddZoneIntoGroup* make(QueryContext* qctx, - PlanNode* input, - std::string groupName, - std::string zoneName) { - return qctx->objPool()->add( - new AddZoneIntoGroup(qctx, input, std::move(zoneName), std::move(groupName))); - } - - const std::string& zoneName() const { return zoneName_; } - - const std::string& groupName() const { return groupName_; } - - private: - AddZoneIntoGroup(QueryContext* qctx, PlanNode* input, std::string zoneName, std::string groupName) - : SingleDependencyNode(qctx, Kind::kAddZoneIntoGroup, input) { - zoneName_ = std::move(zoneName); - groupName_ = std::move(groupName); - } - - private: - std::string zoneName_; - std::string groupName_; -}; - -class DropZoneFromGroup final : public SingleDependencyNode { - public: - static DropZoneFromGroup* make(QueryContext* qctx, - PlanNode* input, - std::string groupName, - std::string zoneName) { - return qctx->objPool()->add( - new DropZoneFromGroup(qctx, input, std::move(zoneName), std::move(groupName))); - } - - const std::string& zoneName() const { return zoneName_; } - - const std::string& groupName() const { return groupName_; } - - private: - DropZoneFromGroup(QueryContext* qctx, - PlanNode* input, - std::string zoneName, - std::string groupName) - : SingleDependencyNode(qctx, Kind::kDropZoneFromGroup, input) { - zoneName_ = std::move(zoneName); - groupName_ = std::move(groupName); - } - - private: - std::string zoneName_; - std::string groupName_; -}; - -class ShowGroups final : public SingleDependencyNode { - public: - static ShowGroups* make(QueryContext* qctx, PlanNode* input) { - return qctx->objPool()->add(new ShowGroups(qctx, input)); - } - - private: - ShowGroups(QueryContext* qctx, PlanNode* input) - : SingleDependencyNode(qctx, Kind::kShowGroups, input) {} -}; - class ShowZones final : public SingleDependencyNode { public: static ShowZones* make(QueryContext* qctx, PlanNode* input) { diff --git a/src/graph/planner/plan/PlanNode.cpp b/src/graph/planner/plan/PlanNode.cpp index f9d1bcfc4a2..388c08afab5 100644 --- a/src/graph/planner/plan/PlanNode.cpp +++ b/src/graph/planner/plan/PlanNode.cpp @@ -231,28 +231,16 @@ const char* PlanNode::toString(PlanNode::Kind kind) { case Kind::kSubgraph: return "Subgraph"; // Group and Zone - case Kind::kAddGroup: - return "AddGroup"; - case Kind::kDropGroup: - return "DropGroup"; case Kind::kAddZone: return "AddZone"; case Kind::kDropZone: return "DropZone"; - case Kind::kDescribeGroup: - return "DescribeGroup"; - case Kind::kAddZoneIntoGroup: - return "AddZoneIntoGroup"; - case Kind::kDropZoneFromGroup: - return "DropZoneFromGroup"; case Kind::kDescribeZone: return "DescribeZone"; case Kind::kAddHostIntoZone: return "AddHostIntoZone"; case Kind::kDropHostFromZone: return "DropHostFromZone"; - case Kind::kShowGroups: - return "ShowGroups"; case Kind::kShowZones: return "ShowZones"; case Kind::kAddListener: diff --git a/src/graph/planner/plan/PlanNode.h b/src/graph/planner/plan/PlanNode.h index ed50f0a9c51..a5fdc3b5918 100644 --- a/src/graph/planner/plan/PlanNode.h +++ b/src/graph/planner/plan/PlanNode.h @@ -145,13 +145,7 @@ class PlanNode { kShowMetaLeader, // zone related - kShowGroups, kShowZones, - kAddGroup, - kDropGroup, - kDescribeGroup, - kAddZoneIntoGroup, - kDropZoneFromGroup, kAddZone, kDropZone, kDescribeZone, diff --git a/src/graph/service/PermissionCheck.cpp b/src/graph/service/PermissionCheck.cpp index 626d7ec4a04..c0752634f3e 100644 --- a/src/graph/service/PermissionCheck.cpp +++ b/src/graph/service/PermissionCheck.cpp @@ -55,12 +55,6 @@ Status PermissionCheck::permissionCheck(ClientSession *session, case Sentence::Kind::kDropSpace: case Sentence::Kind::kCreateSnapshot: case Sentence::Kind::kDropSnapshot: - case Sentence::Kind::kAddGroup: - case Sentence::Kind::kDropGroup: - case Sentence::Kind::kDescribeGroup: - case Sentence::Kind::kListGroups: - case Sentence::Kind::kAddZoneIntoGroup: - case Sentence::Kind::kDropZoneFromGroup: case Sentence::Kind::kAddZone: case Sentence::Kind::kDropZone: case Sentence::Kind::kDescribeZone: diff --git a/src/graph/validator/MaintainValidator.cpp b/src/graph/validator/MaintainValidator.cpp index 73483e092ac..609479c1348 100644 --- a/src/graph/validator/MaintainValidator.cpp +++ b/src/graph/validator/MaintainValidator.cpp @@ -460,74 +460,6 @@ Status ShowEdgeIndexStatusValidator::toPlan() { return Status::OK(); } -Status AddGroupValidator::validateImpl() { - auto sentence = static_cast(sentence_); - if (*sentence->groupName() == "default") { - return Status::SemanticError("Group default conflict"); - } - return Status::OK(); -} - -Status AddGroupValidator::toPlan() { - auto sentence = static_cast(sentence_); - auto *doNode = - AddGroup::make(qctx_, nullptr, *sentence->groupName(), sentence->zoneNames()->zoneNames()); - root_ = doNode; - tail_ = root_; - return Status::OK(); -} - -Status DropGroupValidator::validateImpl() { return Status::OK(); } - -Status DropGroupValidator::toPlan() { - auto sentence = static_cast(sentence_); - auto *doNode = DropGroup::make(qctx_, nullptr, *sentence->groupName()); - root_ = doNode; - tail_ = root_; - return Status::OK(); -} - -Status DescribeGroupValidator::validateImpl() { return Status::OK(); } - -Status DescribeGroupValidator::toPlan() { - auto sentence = static_cast(sentence_); - auto *doNode = DescribeGroup::make(qctx_, nullptr, *sentence->groupName()); - root_ = doNode; - tail_ = root_; - return Status::OK(); -} - -Status ListGroupsValidator::validateImpl() { return Status::OK(); } - -Status ListGroupsValidator::toPlan() { - auto *doNode = ListGroups::make(qctx_, nullptr); - root_ = doNode; - tail_ = root_; - return Status::OK(); -} - -Status AddZoneIntoGroupValidator::validateImpl() { return Status::OK(); } - -Status AddZoneIntoGroupValidator::toPlan() { - auto sentence = static_cast(sentence_); - auto *doNode = - AddZoneIntoGroup::make(qctx_, nullptr, *sentence->groupName(), *sentence->zoneName()); - root_ = doNode; - tail_ = root_; - return Status::OK(); -} - -Status DropZoneFromGroupValidator::validateImpl() { return Status::OK(); } - -Status DropZoneFromGroupValidator::toPlan() { - auto sentence = static_cast(sentence_); - auto *doNode = - DropZoneFromGroup::make(qctx_, nullptr, *sentence->groupName(), *sentence->zoneName()); - root_ = doNode; - tail_ = root_; - return Status::OK(); -} - Status AddZoneValidator::validateImpl() { return Status::OK(); } Status AddZoneValidator::toPlan() { diff --git a/src/graph/validator/MaintainValidator.h b/src/graph/validator/MaintainValidator.h index 095f4266d4a..865994424ad 100644 --- a/src/graph/validator/MaintainValidator.h +++ b/src/graph/validator/MaintainValidator.h @@ -310,80 +310,6 @@ class ShowEdgeIndexStatusValidator final : public Validator { Status toPlan() override; }; -class AddGroupValidator final : public Validator { - public: - AddGroupValidator(Sentence* sentence, QueryContext* context) : Validator(sentence, context) { - setNoSpaceRequired(); - } - - private: - Status validateImpl() override; - - Status toPlan() override; -}; - -class DropGroupValidator final : public Validator { - public: - DropGroupValidator(Sentence* sentence, QueryContext* context) : Validator(sentence, context) { - setNoSpaceRequired(); - } - - private: - Status validateImpl() override; - - Status toPlan() override; -}; - -class DescribeGroupValidator final : public Validator { - public: - DescribeGroupValidator(Sentence* sentence, QueryContext* context) : Validator(sentence, context) { - setNoSpaceRequired(); - } - - private: - Status validateImpl() override; - - Status toPlan() override; -}; - -class ListGroupsValidator final : public Validator { - public: - ListGroupsValidator(Sentence* sentence, QueryContext* context) : Validator(sentence, context) { - setNoSpaceRequired(); - } - - private: - Status validateImpl() override; - - Status toPlan() override; -}; - -class AddZoneIntoGroupValidator final : public Validator { - public: - AddZoneIntoGroupValidator(Sentence* sentence, QueryContext* context) - : Validator(sentence, context) { - setNoSpaceRequired(); - } - - private: - Status validateImpl() override; - - Status toPlan() override; -}; - -class DropZoneFromGroupValidator final : public Validator { - public: - DropZoneFromGroupValidator(Sentence* sentence, QueryContext* context) - : Validator(sentence, context) { - setNoSpaceRequired(); - } - - private: - Status validateImpl() override; - - Status toPlan() override; -}; - class AddZoneValidator final : public Validator { public: AddZoneValidator(Sentence* sentence, QueryContext* context) : Validator(sentence, context) { diff --git a/src/graph/validator/Validator.cpp b/src/graph/validator/Validator.cpp index 6c2aba0cfb2..f7e2cb79816 100644 --- a/src/graph/validator/Validator.cpp +++ b/src/graph/validator/Validator.cpp @@ -200,18 +200,6 @@ std::unique_ptr Validator::makeValidator(Sentence* sentence, QueryCon return std::make_unique(sentence, context); case Sentence::Kind::kLookup: return std::make_unique(sentence, context); - case Sentence::Kind::kAddGroup: - return std::make_unique(sentence, context); - case Sentence::Kind::kDropGroup: - return std::make_unique(sentence, context); - case Sentence::Kind::kDescribeGroup: - return std::make_unique(sentence, context); - case Sentence::Kind::kListGroups: - return std::make_unique(sentence, context); - case Sentence::Kind::kAddZoneIntoGroup: - return std::make_unique(sentence, context); - case Sentence::Kind::kDropZoneFromGroup: - return std::make_unique(sentence, context); case Sentence::Kind::kAddZone: return std::make_unique(sentence, context); case Sentence::Kind::kDropZone: diff --git a/src/interface/meta.thrift b/src/interface/meta.thrift index 166d738623c..50afb2462fc 100644 --- a/src/interface/meta.thrift +++ b/src/interface/meta.thrift @@ -853,49 +853,6 @@ struct ListZonesResp { 3: list zones, } -struct AddGroupReq { - 1: binary group_name, - 2: list zone_names, -} - -struct DropGroupReq { - 1: binary group_name, -} - -struct AddZoneIntoGroupReq { - 1: binary zone_name, - 2: binary group_name, -} - -struct DropZoneFromGroupReq { - 1: binary zone_name, - 2: binary group_name, -} - -struct GetGroupReq { - 1: binary group_name, -} - -struct GetGroupResp { - 1: common.ErrorCode code, - 2: common.HostAddr leader, - 3: list zone_names, -} - -struct ListGroupsReq { -} - -struct Group { - 1: binary group_name, - 2: list zone_names, -} - -struct ListGroupsResp { - 1: common.ErrorCode code, - 2: common.HostAddr leader, - 3: list groups, -} - enum ListenerType { UNKNOWN = 0x00, ELASTICSEARCH = 0x01, @@ -1226,13 +1183,6 @@ service MetaService { GetZoneResp getZone(1: GetZoneReq req); ListZonesResp listZones(1: ListZonesReq req); - ExecResp addGroup(1: AddGroupReq req); - ExecResp dropGroup(1: DropGroupReq req); - ExecResp addZoneIntoGroup(1: AddZoneIntoGroupReq req); - ExecResp dropZoneFromGroup(1: DropZoneFromGroupReq req); - GetGroupResp getGroup(1: GetGroupReq req); - ListGroupsResp listGroups(1: ListGroupsReq req); - CreateBackupResp createBackup(1: CreateBackupReq req); ExecResp restoreMeta(1: RestoreMetaReq req); ExecResp addListener(1: AddListenerReq req); diff --git a/src/meta/CMakeLists.txt b/src/meta/CMakeLists.txt index f5ecbe7bcd8..a02e1bd3073 100644 --- a/src/meta/CMakeLists.txt +++ b/src/meta/CMakeLists.txt @@ -85,11 +85,6 @@ nebula_add_library( processors/zone/GetZoneProcessor.cpp processors/zone/ListZonesProcessor.cpp processors/zone/UpdateZoneProcessor.cpp - processors/zone/AddGroupProcessor.cpp - processors/zone/DropGroupProcessor.cpp - processors/zone/GetGroupProcessor.cpp - processors/zone/ListGroupsProcessor.cpp - processors/zone/UpdateGroupProcessor.cpp processors/listener/ListenerProcessor.cpp processors/session/SessionManagerProcessor.cpp ) diff --git a/src/meta/MetaServiceHandler.cpp b/src/meta/MetaServiceHandler.cpp index 4e58544af0b..58a26b8c038 100644 --- a/src/meta/MetaServiceHandler.cpp +++ b/src/meta/MetaServiceHandler.cpp @@ -61,15 +61,10 @@ #include "meta/processors/schema/ListTagsProcessor.h" #include "meta/processors/session/SessionManagerProcessor.h" #include "meta/processors/user/AuthenticationProcessor.h" -#include "meta/processors/zone/AddGroupProcessor.h" #include "meta/processors/zone/AddZoneProcessor.h" -#include "meta/processors/zone/DropGroupProcessor.h" #include "meta/processors/zone/DropZoneProcessor.h" -#include "meta/processors/zone/GetGroupProcessor.h" #include "meta/processors/zone/GetZoneProcessor.h" -#include "meta/processors/zone/ListGroupsProcessor.h" #include "meta/processors/zone/ListZonesProcessor.h" -#include "meta/processors/zone/UpdateGroupProcessor.h" #include "meta/processors/zone/UpdateZoneProcessor.h" #define RETURN_FUTURE(processor) \ @@ -455,40 +450,6 @@ folly::Future MetaServiceHandler::future_dropHostFromZone( RETURN_FUTURE(processor); } -folly::Future MetaServiceHandler::future_addGroup(const cpp2::AddGroupReq& req) { - auto* processor = AddGroupProcessor::instance(kvstore_); - RETURN_FUTURE(processor); -} - -folly::Future MetaServiceHandler::future_dropGroup(const cpp2::DropGroupReq& req) { - auto* processor = DropGroupProcessor::instance(kvstore_); - RETURN_FUTURE(processor); -} - -folly::Future MetaServiceHandler::future_getGroup( - const cpp2::GetGroupReq& req) { - auto* processor = GetGroupProcessor::instance(kvstore_); - RETURN_FUTURE(processor); -} - -folly::Future MetaServiceHandler::future_listGroups( - const cpp2::ListGroupsReq& req) { - auto* processor = ListGroupsProcessor::instance(kvstore_); - RETURN_FUTURE(processor); -} - -folly::Future MetaServiceHandler::future_addZoneIntoGroup( - const cpp2::AddZoneIntoGroupReq& req) { - auto* processor = AddZoneIntoGroupProcessor::instance(kvstore_); - RETURN_FUTURE(processor); -} - -folly::Future MetaServiceHandler::future_dropZoneFromGroup( - const cpp2::DropZoneFromGroupReq& req) { - auto* processor = DropZoneFromGroupProcessor::instance(kvstore_); - RETURN_FUTURE(processor); -} - folly::Future MetaServiceHandler::future_addListener( const cpp2::AddListenerReq& req) { auto* processor = AddListenerProcessor::instance(kvstore_); diff --git a/src/meta/MetaServiceHandler.h b/src/meta/MetaServiceHandler.h index 2ea463e7c89..1a66097c08c 100644 --- a/src/meta/MetaServiceHandler.h +++ b/src/meta/MetaServiceHandler.h @@ -190,20 +190,6 @@ class MetaServiceHandler final : public cpp2::MetaServiceSvIf { folly::Future future_dropHostFromZone( const cpp2::DropHostFromZoneReq& req) override; - folly::Future future_addGroup(const cpp2::AddGroupReq& req) override; - - folly::Future future_dropGroup(const cpp2::DropGroupReq& req) override; - - folly::Future future_getGroup(const cpp2::GetGroupReq& req) override; - - folly::Future future_listGroups(const cpp2::ListGroupsReq& req) override; - - folly::Future future_addZoneIntoGroup( - const cpp2::AddZoneIntoGroupReq& req) override; - - folly::Future future_dropZoneFromGroup( - const cpp2::DropZoneFromGroupReq& req) override; - // listener folly::Future future_addListener(const cpp2::AddListenerReq& req) override; diff --git a/src/meta/processors/zone/AddGroupProcessor.cpp b/src/meta/processors/zone/AddGroupProcessor.cpp deleted file mode 100644 index 316ca7a3a37..00000000000 --- a/src/meta/processors/zone/AddGroupProcessor.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/* Copyright (c) 2020 vesoft inc. All rights reserved. - * - * This source code is licensed under Apache 2.0 License. - */ - -#include "meta/processors/zone/AddGroupProcessor.h" - -namespace nebula { -namespace meta { - -void AddGroupProcessor::process(const cpp2::AddGroupReq& req) { - folly::SharedMutex::WriteHolder wHolder(LockUtils::groupLock()); - auto groupName = req.get_group_name(); - auto zoneNames = req.get_zone_names(); - if (zoneNames.empty()) { - LOG(ERROR) << "The zone names should not be empty."; - handleErrorCode(nebula::cpp2::ErrorCode::E_INVALID_PARM); - onFinished(); - return; - } - - std::set zoneSet(zoneNames.begin(), zoneNames.end()); - if (zoneNames.size() != zoneSet.size()) { - LOG(ERROR) << "Conflict zone found in the group."; - handleErrorCode(nebula::cpp2::ErrorCode::E_CONFLICT); - onFinished(); - return; - } - - // check the zone existed - const auto& prefix = MetaKeyUtils::zonePrefix(); - auto iterRet = doPrefix(prefix); - if (!nebula::ok(iterRet)) { - auto retCode = nebula::error(iterRet); - LOG(ERROR) << "Get zones failed: " << apache::thrift::util::enumNameSafe(retCode); - handleErrorCode(retCode); - onFinished(); - return; - } - - auto iter = nebula::value(iterRet).get(); - std::vector zones; - while (iter->valid()) { - auto zoneName = MetaKeyUtils::parseZoneName(iter->key()); - zones.emplace_back(std::move(zoneName)); - iter->next(); - } - - for (auto name = zoneNames.begin(); name != zoneNames.end(); name++) { - if (std::find(zones.begin(), zones.end(), *name) == zones.end()) { - LOG(ERROR) << "Zone: " << *name << " not existed"; - handleErrorCode(nebula::cpp2::ErrorCode::E_ZONE_NOT_FOUND); - onFinished(); - return; - } - } - - auto retCode = checkGroupRedundancy(zoneNames); - if (retCode != nebula::cpp2::ErrorCode::SUCCEEDED) { - handleErrorCode(retCode); - onFinished(); - return; - } - - auto groupRet = getGroupId(groupName); - if (nebula::ok(groupRet)) { - LOG(ERROR) << "Group " << groupName << " already existed"; - handleErrorCode(nebula::cpp2::ErrorCode::E_EXISTED); - onFinished(); - return; - } else { - retCode = nebula::error(groupRet); - if (retCode != nebula::cpp2::ErrorCode::E_GROUP_NOT_FOUND) { - LOG(ERROR) << "Create Group failed, group name " << groupName - << " error: " << apache::thrift::util::enumNameSafe(retCode); - handleErrorCode(retCode); - onFinished(); - return; - } - } - - auto groupIdRet = autoIncrementId(); - if (!nebula::ok(groupIdRet)) { - LOG(ERROR) << "Create Group failed"; - handleErrorCode(nebula::error(groupIdRet)); - onFinished(); - return; - } - - std::vector data; - auto groupId = nebula::value(groupIdRet); - data.emplace_back(MetaKeyUtils::indexGroupKey(groupName), - std::string(reinterpret_cast(&groupId), sizeof(GroupID))); - data.emplace_back(MetaKeyUtils::groupKey(groupName), MetaKeyUtils::groupVal(zoneNames)); - - LOG(INFO) << "Create Group: " << groupName; - doSyncPutAndUpdate(std::move(data)); -} - -nebula::cpp2::ErrorCode AddGroupProcessor::checkGroupRedundancy(std::vector zones) { - const auto& prefix = MetaKeyUtils::groupPrefix(); - auto iterRet = doPrefix(prefix); - if (!nebula::ok(iterRet)) { - auto retCode = nebula::error(iterRet); - LOG(ERROR) << "Get groups failed, error: " << apache::thrift::util::enumNameSafe(retCode); - return retCode; - } - auto iter = nebula::value(iterRet).get(); - - std::sort(zones.begin(), zones.end()); - while (iter->valid()) { - auto groupName = MetaKeyUtils::parseGroupName(iter->key()); - auto zoneNames = MetaKeyUtils::parseZoneNames(iter->val()); - std::sort(zoneNames.begin(), zoneNames.end()); - if (zones == zoneNames) { - LOG(ERROR) << "Group " << groupName - << " have created, although the zones order maybe not the same"; - return nebula::cpp2::ErrorCode::E_EXISTED; - } - iter->next(); - } - return nebula::cpp2::ErrorCode::SUCCEEDED; -} - -} // namespace meta -} // namespace nebula diff --git a/src/meta/processors/zone/AddGroupProcessor.h b/src/meta/processors/zone/AddGroupProcessor.h deleted file mode 100644 index 868331f8f5c..00000000000 --- a/src/meta/processors/zone/AddGroupProcessor.h +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright (c) 2020 vesoft inc. All rights reserved. - * - * This source code is licensed under Apache 2.0 License. - */ - -#ifndef META_ADDGROUPPROCESSOR_H -#define META_ADDGROUPPROCESSOR_H - -#include "meta/processors/BaseProcessor.h" - -namespace nebula { -namespace meta { - -class AddGroupProcessor : public BaseProcessor { - public: - static AddGroupProcessor* instance(kvstore::KVStore* kvstore) { - return new AddGroupProcessor(kvstore); - } - - void process(const cpp2::AddGroupReq& req); - - private: - explicit AddGroupProcessor(kvstore::KVStore* kvstore) : BaseProcessor(kvstore) {} - - nebula::cpp2::ErrorCode checkGroupRedundancy(std::vector zones); -}; - -} // namespace meta -} // namespace nebula - -#endif // META_ADDGROUPPROCESSOR_H diff --git a/src/meta/processors/zone/DropGroupProcessor.cpp b/src/meta/processors/zone/DropGroupProcessor.cpp deleted file mode 100644 index 50f40385fa4..00000000000 --- a/src/meta/processors/zone/DropGroupProcessor.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* Copyright (c) 2020 vesoft inc. All rights reserved. - * - * This source code is licensed under Apache 2.0 License. - */ - -#include "meta/processors/zone/DropGroupProcessor.h" - -namespace nebula { -namespace meta { - -void DropGroupProcessor::process(const cpp2::DropGroupReq& req) { - folly::SharedMutex::WriteHolder wHolder(LockUtils::groupLock()); - auto groupName = req.get_group_name(); - auto groupIdRet = getGroupId(groupName); - if (!nebula::ok(groupIdRet)) { - auto retCode = nebula::error(groupIdRet); - if (retCode == nebula::cpp2::ErrorCode::E_GROUP_NOT_FOUND) { - LOG(ERROR) << "Drop Group Failed, Group " << groupName << " not found."; - } else { - LOG(ERROR) << "Drop Group Failed, error: " << apache::thrift::util::enumNameSafe(retCode); - } - handleErrorCode(retCode); - onFinished(); - return; - } - - // If any space rely on this group, it should not be dropped. - auto retCode = checkSpaceDependency(groupName); - if (retCode != nebula::cpp2::ErrorCode::SUCCEEDED) { - handleErrorCode(retCode); - onFinished(); - return; - } - - std::vector keys; - keys.emplace_back(MetaKeyUtils::indexGroupKey(groupName)); - keys.emplace_back(MetaKeyUtils::groupKey(groupName)); - LOG(INFO) << "Drop Group: " << groupName; - doSyncMultiRemoveAndUpdate(std::move(keys)); -} - -nebula::cpp2::ErrorCode DropGroupProcessor::checkSpaceDependency(const std::string& groupName) { - const auto& prefix = MetaKeyUtils::spacePrefix(); - auto iterRet = doPrefix(prefix); - if (!nebula::ok(iterRet)) { - auto retCode = nebula::error(iterRet); - LOG(ERROR) << "List spaces failed, error: " << apache::thrift::util::enumNameSafe(retCode); - return retCode; - } - auto iter = nebula::value(iterRet).get(); - - while (iter->valid()) { - auto properties = MetaKeyUtils::parseSpace(iter->val()); - if (properties.group_name_ref().has_value() && *properties.group_name_ref() == groupName) { - LOG(ERROR) << "Space " << properties.get_space_name() << " is bind to the group " - << groupName; - return nebula::cpp2::ErrorCode::E_NOT_DROP; - } - iter->next(); - } - return nebula::cpp2::ErrorCode::SUCCEEDED; -} - -} // namespace meta -} // namespace nebula diff --git a/src/meta/processors/zone/DropGroupProcessor.h b/src/meta/processors/zone/DropGroupProcessor.h deleted file mode 100644 index 975aee33b61..00000000000 --- a/src/meta/processors/zone/DropGroupProcessor.h +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright (c) 2020 vesoft inc. All rights reserved. - * - * This source code is licensed under Apache 2.0 License. - */ - -#ifndef META_DROPGROUPPROCESSOR_H -#define META_DROPGROUPPROCESSOR_H - -#include "meta/processors/BaseProcessor.h" - -namespace nebula { -namespace meta { - -class DropGroupProcessor : public BaseProcessor { - public: - static DropGroupProcessor* instance(kvstore::KVStore* kvstore) { - return new DropGroupProcessor(kvstore); - } - - void process(const cpp2::DropGroupReq& req); - - private: - explicit DropGroupProcessor(kvstore::KVStore* kvstore) : BaseProcessor(kvstore) {} - - nebula::cpp2::ErrorCode checkSpaceDependency(const std::string& groupName); -}; - -} // namespace meta -} // namespace nebula - -#endif // META_DROPGROUPPROCESSOR_H diff --git a/src/meta/processors/zone/GetGroupProcessor.cpp b/src/meta/processors/zone/GetGroupProcessor.cpp deleted file mode 100644 index 24fcde38317..00000000000 --- a/src/meta/processors/zone/GetGroupProcessor.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (c) 2020 vesoft inc. All rights reserved. - * - * This source code is licensed under Apache 2.0 License. - */ - -#include "meta/processors/zone/GetGroupProcessor.h" - -namespace nebula { -namespace meta { - -void GetGroupProcessor::process(const cpp2::GetGroupReq& req) { - folly::SharedMutex::ReadHolder rHolder(LockUtils::groupLock()); - auto& groupName = req.get_group_name(); - auto groupIdRet = getGroupId(groupName); - if (!nebula::ok(groupIdRet)) { - auto retCode = nebula::error(groupIdRet); - if (retCode == nebula::cpp2::ErrorCode::E_GROUP_NOT_FOUND) { - LOG(ERROR) << "Get Group Failed, Group " << groupName << " not found."; - } else { - LOG(ERROR) << "Get Group Failed, error: " << apache::thrift::util::enumNameSafe(retCode); - } - handleErrorCode(retCode); - onFinished(); - return; - } - - auto groupKey = MetaKeyUtils::groupKey(groupName); - auto groupValueRet = doGet(std::move(groupKey)); - if (!nebula::ok(groupValueRet)) { - auto retCode = nebula::error(groupValueRet); - LOG(ERROR) << "Get group " << groupName << " failed, error " - << apache::thrift::util::enumNameSafe(retCode); - handleErrorCode(retCode); - onFinished(); - return; - } - - auto zoneNames = MetaKeyUtils::parseZoneNames(std::move(nebula::value(groupValueRet))); - LOG(INFO) << "Get Group: " << groupName << " zone size: " << zoneNames.size(); - resp_.set_zone_names(std::move(zoneNames)); - handleErrorCode(nebula::cpp2::ErrorCode::SUCCEEDED); - onFinished(); -} - -} // namespace meta -} // namespace nebula diff --git a/src/meta/processors/zone/GetGroupProcessor.h b/src/meta/processors/zone/GetGroupProcessor.h deleted file mode 100644 index 2129d1923c9..00000000000 --- a/src/meta/processors/zone/GetGroupProcessor.h +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright (c) 2020 vesoft inc. All rights reserved. - * - * This source code is licensed under Apache 2.0 License. - */ - -#ifndef META_GETGROUPPROCESSOR_H -#define META_GETGROUPPROCESSOR_H - -#include "meta/processors/BaseProcessor.h" - -namespace nebula { -namespace meta { - -class GetGroupProcessor : public BaseProcessor { - public: - static GetGroupProcessor* instance(kvstore::KVStore* kvstore) { - return new GetGroupProcessor(kvstore); - } - - void process(const cpp2::GetGroupReq& req); - - private: - explicit GetGroupProcessor(kvstore::KVStore* kvstore) - : BaseProcessor(kvstore) {} -}; - -} // namespace meta -} // namespace nebula -#endif // META_GETGROUPPROCESSOR_H diff --git a/src/meta/processors/zone/ListGroupsProcessor.cpp b/src/meta/processors/zone/ListGroupsProcessor.cpp deleted file mode 100644 index 17bbfad38c7..00000000000 --- a/src/meta/processors/zone/ListGroupsProcessor.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (c) 2020 vesoft inc. All rights reserved. - * - * This source code is licensed under Apache 2.0 License. - */ - -#include "meta/processors/zone/ListGroupsProcessor.h" - -namespace nebula { -namespace meta { - -void ListGroupsProcessor::process(const cpp2::ListGroupsReq&) { - folly::SharedMutex::ReadHolder rHolder(LockUtils::groupLock()); - const auto& prefix = MetaKeyUtils::groupPrefix(); - auto iterRet = doPrefix(prefix); - if (!nebula::ok(iterRet)) { - auto retCode = nebula::error(iterRet); - LOG(ERROR) << "List groups failed, error: " << apache::thrift::util::enumNameSafe(retCode); - handleErrorCode(retCode); - onFinished(); - return; - } - auto iter = nebula::value(iterRet).get(); - - std::vector groups; - while (iter->valid()) { - auto groupName = MetaKeyUtils::parseGroupName(iter->key()); - auto zoneNames = MetaKeyUtils::parseZoneNames(iter->val()); - cpp2::Group group; - group.set_group_name(std::move(groupName)); - group.set_zone_names(std::move(zoneNames)); - groups.emplace_back(std::move(group)); - iter->next(); - } - - handleErrorCode(nebula::cpp2::ErrorCode::SUCCEEDED); - resp_.set_groups(std::move(groups)); - onFinished(); -} - -} // namespace meta -} // namespace nebula diff --git a/src/meta/processors/zone/ListGroupsProcessor.h b/src/meta/processors/zone/ListGroupsProcessor.h deleted file mode 100644 index 77bf00f293d..00000000000 --- a/src/meta/processors/zone/ListGroupsProcessor.h +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright (c) 2020 vesoft inc. All rights reserved. - * - * This source code is licensed under Apache 2.0 License. - */ - -#ifndef META_LISTGROUPSPROCESSOR_H -#define META_LISTGROUPSPROCESSOR_H - -#include "meta/processors/BaseProcessor.h" - -namespace nebula { -namespace meta { - -class ListGroupsProcessor : public BaseProcessor { - public: - static ListGroupsProcessor* instance(kvstore::KVStore* kvstore) { - return new ListGroupsProcessor(kvstore); - } - - void process(const cpp2::ListGroupsReq& req); - - private: - explicit ListGroupsProcessor(kvstore::KVStore* kvstore) - : BaseProcessor(kvstore) {} -}; - -} // namespace meta -} // namespace nebula -#endif // META_LISTGROUPSPROCESSOR_H diff --git a/src/meta/processors/zone/UpdateGroupProcessor.cpp b/src/meta/processors/zone/UpdateGroupProcessor.cpp deleted file mode 100644 index 5b3db6a6b83..00000000000 --- a/src/meta/processors/zone/UpdateGroupProcessor.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/* Copyright (c) 2020 vesoft inc. All rights reserved. - * - * This source code is licensed under Apache 2.0 License. - */ - -#include "meta/processors/zone/UpdateGroupProcessor.h" - -namespace nebula { -namespace meta { - -void AddZoneIntoGroupProcessor::process(const cpp2::AddZoneIntoGroupReq& req) { - folly::SharedMutex::ReadHolder rHolder(LockUtils::groupLock()); - auto groupName = req.get_group_name(); - auto groupIdRet = getGroupId(groupName); - if (!nebula::ok(groupIdRet)) { - auto retCode = nebula::error(groupIdRet); - LOG(ERROR) << "Get Group failed, group " << groupName - << " error: " << apache::thrift::util::enumNameSafe(retCode); - handleErrorCode(retCode); - onFinished(); - return; - } - - auto groupKey = MetaKeyUtils::groupKey(groupName); - auto groupValueRet = doGet(std::move(groupKey)); - if (!nebula::ok(groupValueRet)) { - auto retCode = nebula::error(groupValueRet); - if (retCode == nebula::cpp2::ErrorCode::E_KEY_NOT_FOUND) { - retCode = nebula::cpp2::ErrorCode::E_GROUP_NOT_FOUND; - } - LOG(ERROR) << "Get group " << groupName << " failed, error " - << apache::thrift::util::enumNameSafe(retCode); - handleErrorCode(retCode); - onFinished(); - return; - } - - auto zoneName = req.get_zone_name(); - auto zoneNames = MetaKeyUtils::parseZoneNames(std::move(nebula::value(groupValueRet))); - auto iter = std::find(zoneNames.begin(), zoneNames.end(), zoneName); - if (iter != zoneNames.end()) { - LOG(ERROR) << "Zone " << zoneName << " already exist in the group " << groupName; - handleErrorCode(nebula::cpp2::ErrorCode::E_EXISTED); - onFinished(); - return; - } - - const auto& zonePrefix = MetaKeyUtils::zonePrefix(); - auto iterRet = doPrefix(zonePrefix); - if (!nebula::ok(iterRet)) { - auto retCode = nebula::error(iterRet); - LOG(ERROR) << "Get zones failed, error: " << apache::thrift::util::enumNameSafe(retCode); - handleErrorCode(retCode); - onFinished(); - return; - } - auto zoneIter = nebula::value(iterRet).get(); - - bool found = false; - while (zoneIter->valid()) { - auto name = MetaKeyUtils::parseZoneName(zoneIter->key()); - if (name == zoneName) { - found = true; - break; - } - zoneIter->next(); - } - - if (!found) { - LOG(ERROR) << "Zone " << zoneName << " not found"; - handleErrorCode(nebula::cpp2::ErrorCode::E_ZONE_NOT_FOUND); - onFinished(); - return; - } - - zoneNames.emplace_back(zoneName); - std::vector data; - data.emplace_back(std::move(groupKey), MetaKeyUtils::groupVal(zoneNames)); - LOG(INFO) << "Add Zone " << zoneName << " Into Group " << groupName; - doSyncPutAndUpdate(std::move(data)); -} - -void DropZoneFromGroupProcessor::process(const cpp2::DropZoneFromGroupReq& req) { - folly::SharedMutex::ReadHolder rHolder(LockUtils::groupLock()); - auto groupName = req.get_group_name(); - auto groupIdRet = getGroupId(groupName); - if (!nebula::ok(groupIdRet)) { - auto retCode = nebula::error(groupIdRet); - LOG(ERROR) << " Get Group " << groupName - << " failed, error: " << apache::thrift::util::enumNameSafe(retCode); - handleErrorCode(retCode); - onFinished(); - return; - } - - auto groupKey = MetaKeyUtils::groupKey(groupName); - auto groupValueRet = doGet(groupKey); - if (!nebula::ok(groupValueRet)) { - auto retCode = nebula::error(groupValueRet); - if (retCode == nebula::cpp2::ErrorCode::E_KEY_NOT_FOUND) { - retCode = nebula::cpp2::ErrorCode::E_GROUP_NOT_FOUND; - } - LOG(ERROR) << "Get group " << groupName - << " failed, error: " << apache::thrift::util::enumNameSafe(retCode); - handleErrorCode(retCode); - onFinished(); - return; - } - - auto zoneName = req.get_zone_name(); - auto zoneNames = MetaKeyUtils::parseZoneNames(std::move(nebula::value(groupValueRet))); - auto iter = std::find(zoneNames.begin(), zoneNames.end(), zoneName); - if (iter == zoneNames.end()) { - LOG(ERROR) << "Zone " << zoneName << " not exist in the group " << groupName; - handleErrorCode(nebula::cpp2::ErrorCode::E_ZONE_NOT_FOUND); - onFinished(); - return; - } - - const auto& spacePrefix = MetaKeyUtils::spacePrefix(); - auto spaceRet = doPrefix(spacePrefix); - if (!nebula::ok(spaceRet)) { - auto retCode = nebula::error(spaceRet); - LOG(ERROR) << "List spaces failed, error " << apache::thrift::util::enumNameSafe(retCode); - handleErrorCode(retCode); - onFinished(); - return; - } - - nebula::cpp2::ErrorCode spaceCode = nebula::cpp2::ErrorCode::SUCCEEDED; - auto spaceIter = nebula::value(spaceRet).get(); - while (spaceIter->valid()) { - auto properties = MetaKeyUtils::parseSpace(spaceIter->val()); - if (properties.group_name_ref().has_value() && *properties.group_name_ref() == groupName) { - LOG(ERROR) << "Space is bind to the group " << *properties.group_name_ref(); - spaceCode = nebula::cpp2::ErrorCode::E_CONFLICT; - } - spaceIter->next(); - } - - if (spaceCode != nebula::cpp2::ErrorCode::SUCCEEDED) { - handleErrorCode(spaceCode); - onFinished(); - return; - } - - zoneNames.erase(iter); - std::vector data; - data.emplace_back(std::move(groupKey), MetaKeyUtils::groupVal(zoneNames)); - LOG(INFO) << "Drop Zone " << zoneName << " From Group " << groupName; - doSyncPutAndUpdate(std::move(data)); -} - -} // namespace meta -} // namespace nebula diff --git a/src/meta/processors/zone/UpdateGroupProcessor.h b/src/meta/processors/zone/UpdateGroupProcessor.h deleted file mode 100644 index a0367f8a898..00000000000 --- a/src/meta/processors/zone/UpdateGroupProcessor.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (c) 2020 vesoft inc. All rights reserved. - * - * This source code is licensed under Apache 2.0 License. - */ - -#ifndef META_UPDATEGROUPPROCESSOR_H -#define META_UPDATEGROUPPROCESSOR_H - -#include "meta/processors/BaseProcessor.h" - -namespace nebula { -namespace meta { - -class AddZoneIntoGroupProcessor : public BaseProcessor { - public: - static AddZoneIntoGroupProcessor* instance(kvstore::KVStore* kvstore) { - return new AddZoneIntoGroupProcessor(kvstore); - } - - void process(const cpp2::AddZoneIntoGroupReq& req); - - private: - explicit AddZoneIntoGroupProcessor(kvstore::KVStore* kvstore) - : BaseProcessor(kvstore) {} -}; - -class DropZoneFromGroupProcessor : public BaseProcessor { - public: - static DropZoneFromGroupProcessor* instance(kvstore::KVStore* kvstore) { - return new DropZoneFromGroupProcessor(kvstore); - } - - void process(const cpp2::DropZoneFromGroupReq& req); - - private: - explicit DropZoneFromGroupProcessor(kvstore::KVStore* kvstore) - : BaseProcessor(kvstore) {} -}; - -} // namespace meta -} // namespace nebula -#endif // META_UPDATEGROUPPROCESSOR_H diff --git a/src/meta/test/GroupZoneTest.cpp b/src/meta/test/GroupZoneTest.cpp index 10af4a722b2..564cb1f7955 100644 --- a/src/meta/test/GroupZoneTest.cpp +++ b/src/meta/test/GroupZoneTest.cpp @@ -9,15 +9,10 @@ #include "common/fs/TempDir.h" #include "meta/processors/parts/CreateSpaceProcessor.h" #include "meta/processors/parts/DropSpaceProcessor.h" -#include "meta/processors/zone/AddGroupProcessor.h" #include "meta/processors/zone/AddZoneProcessor.h" -#include "meta/processors/zone/DropGroupProcessor.h" #include "meta/processors/zone/DropZoneProcessor.h" -#include "meta/processors/zone/GetGroupProcessor.h" #include "meta/processors/zone/GetZoneProcessor.h" -#include "meta/processors/zone/ListGroupsProcessor.h" #include "meta/processors/zone/ListZonesProcessor.h" -#include "meta/processors/zone/UpdateGroupProcessor.h" #include "meta/processors/zone/UpdateZoneProcessor.h" #include "meta/test/TestUtils.h" @@ -280,54 +275,6 @@ TEST(GroupAndZoneTest, GroupAndZoneTest) { auto resp = std::move(f).get(); ASSERT_EQ(nebula::cpp2::ErrorCode::E_KEY_NOT_FOUND, resp.get_code()); } -// Add Group -{ - cpp2::AddGroupReq req; - req.set_group_name("group_0"); - std::vector zones = {"zone_0", "zone_1", "zone_2"}; - req.set_zone_names(std::move(zones)); - auto* processor = AddGroupProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, resp.get_code()); -} -{ - cpp2::SpaceDesc properties; - properties.set_space_name("space"); - properties.set_partition_num(12); - properties.set_replica_factor(3); - properties.set_group_name("group_0"); - cpp2::CreateSpaceReq req; - req.set_properties(std::move(properties)); - auto* processor = CreateSpaceProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, resp.get_code()); -} -// Drop host from zone -{ - cpp2::DropHostFromZoneReq req; - req.set_zone_name("zone_0"); - HostAddr node{"12", 12}; - req.set_node(std::move(node)); - auto* processor = DropHostFromZoneProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::E_CONFLICT, resp.get_code()); -} -{ - cpp2::DropSpaceReq req; - req.set_space_name("space"); - req.set_if_exists(false); - auto* processor = DropSpaceProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, resp.get_code()); -} { cpp2::DropHostFromZoneReq req; req.set_zone_name("zone_0"); @@ -339,255 +286,6 @@ TEST(GroupAndZoneTest, GroupAndZoneTest) { auto resp = std::move(f).get(); ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, resp.get_code()); } -// Add Group which zone not exist -{ - LOG(INFO) << "Add Group which zone not exist"; - cpp2::AddGroupReq req; - req.set_group_name("group_zone_not_exist"); - std::vector zones = {"zone_0", "zone_1", "zone_4"}; - req.set_zone_names(std::move(zones)); - auto* processor = AddGroupProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::E_ZONE_NOT_FOUND, resp.get_code()); -} -// Group already existed -{ - cpp2::AddGroupReq req; - req.set_group_name("group_1"); - std::vector zones = {"zone_0", "zone_1", "zone_2"}; - req.set_zone_names(std::move(zones)); - auto* processor = AddGroupProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::E_EXISTED, resp.get_code()); -} -// Group already existed although the order is different -{ - cpp2::AddGroupReq req; - req.set_group_name("group_1"); - std::vector zones = {"zone_2", "zone_1", "zone_0"}; - req.set_zone_names(std::move(zones)); - auto* processor = AddGroupProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::E_EXISTED, resp.get_code()); -} -// Add Group with empty zone name list -{ - cpp2::AddGroupReq req; - req.set_group_name("group_0"); - std::vector zones = {}; - req.set_zone_names(std::move(zones)); - auto* processor = AddGroupProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::E_INVALID_PARM, resp.get_code()); -} -// Add Group with duplicate zone name -{ - cpp2::AddGroupReq req; - req.set_group_name("group_0"); - std::vector zones = {"zone_0", "zone_0", "zone_2"}; - req.set_zone_names(std::move(zones)); - auto* processor = AddGroupProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::E_CONFLICT, resp.get_code()); -} -// Add Group name already existed -{ - cpp2::AddGroupReq req; - req.set_group_name("group_0"); - std::vector zones = {"zone_0", "zone_1"}; - req.set_zone_names(std::move(zones)); - auto* processor = AddGroupProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::E_EXISTED, resp.get_code()); -} -{ - cpp2::AddGroupReq req; - req.set_group_name("group_1"); - std::vector zones = {"zone_0", "zone_1"}; - req.set_zone_names(std::move(zones)); - auto* processor = AddGroupProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, resp.get_code()); -} -// Get Group -{ - cpp2::GetGroupReq req; - req.set_group_name("group_0"); - auto* processor = GetGroupProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, resp.get_code()); - ASSERT_EQ(3, resp.get_zone_names().size()); - std::vector zones = {"zone_0", "zone_1", "zone_2"}; - ASSERT_EQ(zones, resp.get_zone_names()); -} -// Get Group which is not exist -{ - cpp2::GetGroupReq req; - req.set_group_name("group_not_exist"); - auto* processor = GetGroupProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::E_GROUP_NOT_FOUND, resp.get_code()); -} -// List Groups -{ - cpp2::ListGroupsReq req; - auto* processor = ListGroupsProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, resp.get_code()); - ASSERT_EQ(2, resp.get_groups().size()); - ASSERT_EQ("group_0", resp.get_groups()[0].get_group_name()); - ASSERT_EQ("group_1", resp.get_groups()[1].get_group_name()); -} -{ - std::vector nodes; - for (int32_t i = 9; i < 12; i++) { - nodes.emplace_back(std::to_string(i), i); - } - cpp2::AddZoneReq req; - req.set_zone_name("zone_3"); - req.set_nodes(std::move(nodes)); - auto* processor = AddZoneProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, resp.get_code()); -} -// Add zone into group -{ - cpp2::AddZoneIntoGroupReq req; - req.set_group_name("group_0"); - req.set_zone_name("zone_3"); - auto* processor = AddZoneIntoGroupProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, resp.get_code()); -} -// Add zone into group which group not exist -{ - cpp2::AddZoneIntoGroupReq req; - req.set_group_name("group_not_exist"); - req.set_zone_name("zone_0"); - auto* processor = AddZoneIntoGroupProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::E_GROUP_NOT_FOUND, resp.get_code()); -} -// Add zone into group which zone already exist -{ - cpp2::AddZoneIntoGroupReq req; - req.set_group_name("group_0"); - req.set_zone_name("zone_0"); - auto* processor = AddZoneIntoGroupProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::E_EXISTED, resp.get_code()); -} -// Add zone into group which zone not exist -{ - cpp2::AddZoneIntoGroupReq req; - req.set_group_name("group_0"); - req.set_zone_name("zone_not_exist"); - auto* processor = AddZoneIntoGroupProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::E_ZONE_NOT_FOUND, resp.get_code()); -} -// Drop zone from group -{ - cpp2::DropZoneFromGroupReq req; - req.set_group_name("group_0"); - req.set_zone_name("zone_3"); - auto* processor = DropZoneFromGroupProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, resp.get_code()); -} -// Drop zone from group which group not exist -{ - cpp2::DropZoneFromGroupReq req; - req.set_group_name("group_not_exist"); - req.set_zone_name("zone_0"); - auto* processor = DropZoneFromGroupProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::E_GROUP_NOT_FOUND, resp.get_code()); -} -// Drop zone from group which zone not exist -{ - cpp2::DropZoneFromGroupReq req; - req.set_group_name("group_0"); - req.set_zone_name("zone_not_exist"); - auto* processor = DropZoneFromGroupProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::E_ZONE_NOT_FOUND, resp.get_code()); -} -// Drop Group -{ - cpp2::DropGroupReq req; - req.set_group_name("group_0"); - auto* processor = DropGroupProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, resp.get_code()); -} -// Drop Group which is not exist -{ - cpp2::DropGroupReq req; - req.set_group_name("group_0"); - auto* processor = DropGroupProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::E_GROUP_NOT_FOUND, resp.get_code()); -} -// Drop Zone belong to a group -{ - cpp2::DropZoneReq req; - req.set_zone_name("zone_0"); - auto* processor = DropZoneProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::E_NOT_DROP, resp.get_code()); -} -{ - cpp2::DropGroupReq req; - req.set_group_name("group_1"); - auto* processor = DropGroupProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, resp.get_code()); -} // Drop Zone { cpp2::DropZoneReq req; diff --git a/src/meta/test/MetaClientTest.cpp b/src/meta/test/MetaClientTest.cpp index a9e6d6f4723..1a8c6a9318f 100644 --- a/src/meta/test/MetaClientTest.cpp +++ b/src/meta/test/MetaClientTest.cpp @@ -397,22 +397,6 @@ TEST(MetaClientTest, SpaceWithGroupTest) { ASSERT_TRUE(result.ok()); ASSERT_EQ(5, result.value().size()); } -// Add Group -{ - std::vector zones = {"zone_0", "zone_1", "zone_2"}; - auto result = client->addGroup("group_0", std::move(zones)).get(); - ASSERT_TRUE(result.ok()); -} -{ - std::vector zones = {"zone_0", "zone_1", "zone_2", "zone_3", "zone_4"}; - auto result = client->addGroup("group_1", std::move(zones)).get(); - ASSERT_TRUE(result.ok()); -} -{ - auto result = client->listGroups().get(); - ASSERT_TRUE(result.ok()); - ASSERT_EQ(2, result.value().size()); -} } // namespace meta // Create Space without Group { @@ -426,79 +410,6 @@ TEST(MetaClientTest, SpaceWithGroupTest) { ret = client->createSpace(spaceDesc, true).get(); ASSERT_TRUE(ret.ok()) << ret.status(); } -// Create Space on group_0, replica factor is equal with zone size -{ - meta::cpp2::SpaceDesc spaceDesc; - spaceDesc.set_space_name("space_on_group_0_3"); - spaceDesc.set_partition_num(9); - spaceDesc.set_replica_factor(3); - spaceDesc.set_group_name("group_0"); - auto ret = client->createSpace(spaceDesc).get(); - ASSERT_TRUE(ret.ok()) << ret.status(); - - ret = client->createSpace(spaceDesc, true).get(); - ASSERT_TRUE(ret.ok()) << ret.status(); -} -// Drop Group should failed -{ - auto result = client->dropGroup("group_0").get(); - ASSERT_FALSE(result.ok()); -} -// Create Space on group_0, replica factor is less than zone size -{ - meta::cpp2::SpaceDesc spaceDesc; - spaceDesc.set_space_name("space_on_group_0_1"); - spaceDesc.set_partition_num(9); - spaceDesc.set_replica_factor(1); - spaceDesc.set_group_name("group_0"); - auto ret = client->createSpace(spaceDesc).get(); - ASSERT_TRUE(ret.ok()) << ret.status(); - - ret = client->createSpace(spaceDesc, true).get(); - ASSERT_TRUE(ret.ok()) << ret.status(); -} -// Create Space on group_0, replica factor is larger than zone size -{ - meta::cpp2::SpaceDesc spaceDesc; - spaceDesc.set_space_name("space_on_group_0_4"); - spaceDesc.set_partition_num(9); - spaceDesc.set_replica_factor(4); - spaceDesc.set_group_name("group_0"); - auto ret = client->createSpace(spaceDesc).get(); - ASSERT_FALSE(ret.ok()) << ret.status(); - - ret = client->createSpace(spaceDesc, true).get(); - ASSERT_FALSE(ret.ok()) << ret.status(); -} -{ - auto result = client->addZoneIntoGroup("zone_3", "group_0").get(); - ASSERT_TRUE(result.ok()); -} -{ - meta::cpp2::SpaceDesc spaceDesc; - spaceDesc.set_space_name("space_on_group_0_4"); - spaceDesc.set_partition_num(9); - spaceDesc.set_replica_factor(4); - spaceDesc.set_group_name("group_0"); - auto ret = client->createSpace(spaceDesc).get(); - ASSERT_TRUE(ret.ok()) << ret.status(); - - ret = client->createSpace(spaceDesc, true).get(); - ASSERT_TRUE(ret.ok()) << ret.status(); -} -// Create Space on a group which is not exist -{ - meta::cpp2::SpaceDesc spaceDesc; - spaceDesc.set_space_name("space_on_group_not_exist"); - spaceDesc.set_partition_num(9); - spaceDesc.set_replica_factor(4); - spaceDesc.set_group_name("group_not_exist"); - auto ret = client->createSpace(spaceDesc).get(); - ASSERT_FALSE(ret.ok()) << ret.status(); - - ret = client->createSpace(spaceDesc, true).get(); - ASSERT_FALSE(ret.ok()) << ret.status(); -} } // namespace nebula TEST(MetaClientTest, TagTest) { @@ -1317,100 +1228,6 @@ TEST(MetaClientTest, GroupAndZoneTest) { auto result = client->dropHostFromZone(node, "zone_0").get(); ASSERT_FALSE(result.ok()); } - // Add Group - { - std::vector zones = {"zone_0", "zone_1", "zone_2"}; - auto result = client->addGroup("group_0", std::move(zones)).get(); - ASSERT_TRUE(result.ok()); - } - // Add Group with empty zone name list - { - std::vector zones = {}; - auto result = client->addGroup("group_0", std::move(zones)).get(); - ASSERT_FALSE(result.ok()); - } - // Add Group with duplicate zone name - { - std::vector zones = {"zone_0", "zone_0", "zone_2"}; - auto result = client->addGroup("group_0", std::move(zones)).get(); - ASSERT_FALSE(result.ok()); - } - // Add Group already existed - { - std::vector zones = {"zone_0", "zone_1", "zone_2"}; - auto result = client->addGroup("group_0", std::move(zones)).get(); - ASSERT_FALSE(result.ok()); - } - { - std::vector zones = {"zone_1", "zone_2"}; - auto result = client->addGroup("group_1", std::move(zones)).get(); - ASSERT_TRUE(result.ok()); - } - // Get Group - { - auto result = client->getGroup("group_0").get(); - ASSERT_TRUE(result.ok()); - } - // Get Group which is not exist - { - auto result = client->getGroup("group_not_exist").get(); - ASSERT_FALSE(result.ok()); - } - // List Groups - { - auto result = client->listGroups().get(); - ASSERT_TRUE(result.ok()); - } - { - std::vector nodes = {{"9", 9}, {"10", 10}, {"11", 11}}; - auto result = client->addZone("zone_3", nodes).get(); - ASSERT_TRUE(result.ok()); - } - // Add zone into group - { - auto result = client->addZoneIntoGroup("zone_3", "group_0").get(); - ASSERT_TRUE(result.ok()); - } - // Add zone into group which group not exist - { - auto result = client->addZoneIntoGroup("zone_0", "group_not_exist").get(); - ASSERT_FALSE(result.ok()); - } - // Add zone into group which zone already exist - { - auto result = client->addZoneIntoGroup("zone_0", "group_0").get(); - ASSERT_FALSE(result.ok()); - } - // Add zone into group which zone not exist - { - auto result = client->addZoneIntoGroup("zone_not_exist", "group_0").get(); - ASSERT_FALSE(result.ok()); - } - // Drop zone from group - { - auto result = client->dropZoneFromGroup("zone_3", "group_0").get(); - ASSERT_TRUE(result.ok()); - } - // Drop zone from group which group not exist - { - auto result = client->dropZoneFromGroup("zone_0", "group_not_exist").get(); - ASSERT_FALSE(result.ok()); - } - // Drop zone from group which zone not exist - { - auto result = client->dropZoneFromGroup("zone_not_exist", "group_0").get(); - ASSERT_FALSE(result.ok()); - } - // Drop Group - { - auto result = client->dropGroup("group_0").get(); - ASSERT_TRUE(result.ok()); - } - // Drop Group which is not exist - { - auto result = client->dropGroup("group_0").get(); - ASSERT_FALSE(result.ok()); - } // Drop Zone { auto result = client->dropZone("zone_0").get(); diff --git a/src/meta/test/ProcessorTest.cpp b/src/meta/test/ProcessorTest.cpp index 49e252d53d4..f42f5d4a5d9 100644 --- a/src/meta/test/ProcessorTest.cpp +++ b/src/meta/test/ProcessorTest.cpp @@ -30,12 +30,8 @@ #include "meta/processors/schema/ListEdgesProcessor.h" #include "meta/processors/schema/ListTagsProcessor.h" #include "meta/processors/session/SessionManagerProcessor.h" -#include "meta/processors/zone/AddGroupProcessor.h" #include "meta/processors/zone/AddZoneProcessor.h" -#include "meta/processors/zone/DropGroupProcessor.h" -#include "meta/processors/zone/ListGroupsProcessor.h" #include "meta/processors/zone/ListZonesProcessor.h" -#include "meta/processors/zone/UpdateGroupProcessor.h" #include "meta/processors/zone/UpdateZoneProcessor.h" #include "meta/test/TestUtils.h" @@ -467,298 +463,6 @@ TEST(ProcessorTest, SpaceTest) { } } -TEST(ProcessorTest, SpaceWithGroupTest) { - fs::TempDir rootPath("/tmp/SpaceWithGroupTest.XXXXXX"); - std::unique_ptr kv(MockCluster::initMetaKV(rootPath.path())); - std::vector addresses; - for (int32_t i = 0; i <= 10; i++) { - addresses.emplace_back(std::to_string(i), i); - } - TestUtils::createSomeHosts(kv.get(), std::move(addresses)); - - // Add Zones - {{std::vector nodes; - for (int32_t i = 0; i < 2; i++) { - nodes.emplace_back(std::to_string(i), i); - } - cpp2::AddZoneReq req; - req.set_zone_name("zone_0"); - req.set_nodes(std::move(nodes)); - auto* processor = AddZoneProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, resp.get_code()); -} -{ - std::vector nodes; - for (int32_t i = 2; i < 4; i++) { - nodes.emplace_back(std::to_string(i), i); - } - cpp2::AddZoneReq req; - req.set_zone_name("zone_1"); - req.set_nodes(std::move(nodes)); - auto* processor = AddZoneProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, resp.get_code()); -} -{ - std::vector nodes; - for (int32_t i = 4; i < 6; i++) { - nodes.emplace_back(std::to_string(i), i); - } - cpp2::AddZoneReq req; - req.set_zone_name("zone_2"); - req.set_nodes(std::move(nodes)); - auto* processor = AddZoneProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, resp.get_code()); -} -{ - std::vector nodes; - for (int32_t i = 6; i < 8; i++) { - nodes.emplace_back(std::to_string(i), i); - } - cpp2::AddZoneReq req; - req.set_zone_name("zone_3"); - req.set_nodes(std::move(nodes)); - auto* processor = AddZoneProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, resp.get_code()); -} -{ - std::vector nodes; - for (int32_t i = 8; i < 10; i++) { - nodes.emplace_back(std::to_string(i), i); - } - cpp2::AddZoneReq req; - req.set_zone_name("zone_4"); - req.set_nodes(std::move(nodes)); - auto* processor = AddZoneProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, resp.get_code()); -} -} // namespace meta -// List Zones -{ - cpp2::ListZonesReq req; - auto* processor = ListZonesProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, resp.get_code()); - ASSERT_EQ(5, resp.get_zones().size()); - ASSERT_EQ("zone_0", resp.get_zones()[0].get_zone_name()); - ASSERT_EQ("zone_1", resp.get_zones()[1].get_zone_name()); - ASSERT_EQ("zone_2", resp.get_zones()[2].get_zone_name()); - ASSERT_EQ("zone_3", resp.get_zones()[3].get_zone_name()); - ASSERT_EQ("zone_4", resp.get_zones()[4].get_zone_name()); -} - -// Add Group -{ - cpp2::AddGroupReq req; - req.set_group_name("group_0"); - std::vector zones = {"zone_0", "zone_1", "zone_2"}; - req.set_zone_names(std::move(zones)); - auto* processor = AddGroupProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, resp.get_code()); -} -{ - cpp2::AddGroupReq req; - req.set_group_name("group_1"); - std::vector zones = {"zone_0", "zone_1", "zone_2", "zone_3", "zone_4"}; - req.set_zone_names(std::move(zones)); - auto* processor = AddGroupProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, resp.get_code()); -} -// List Groups -{ - cpp2::ListGroupsReq req; - auto* processor = ListGroupsProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, resp.get_code()); - ASSERT_EQ(2, resp.get_groups().size()); - ASSERT_EQ("group_0", resp.get_groups()[0].get_group_name()); - ASSERT_EQ("group_1", resp.get_groups()[1].get_group_name()); -} - -// Create Space without Group -{ - cpp2::SpaceDesc properties; - properties.set_space_name("default_space"); - properties.set_partition_num(9); - properties.set_replica_factor(3); - cpp2::CreateSpaceReq req; - req.set_properties(std::move(properties)); - auto* processor = CreateSpaceProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, resp.get_code()); -} -// Create Space on group_0, replica factor is equal with zone size -{ - cpp2::SpaceDesc properties; - properties.set_space_name("space_on_group_0_3"); - properties.set_partition_num(9); - properties.set_replica_factor(3); - properties.set_group_name("group_0"); - cpp2::CreateSpaceReq req; - req.set_properties(std::move(properties)); - auto* processor = CreateSpaceProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, resp.get_code()); -} -// Drop Group should failed -{ - cpp2::DropGroupReq req; - req.set_group_name("group_0"); - auto* processor = DropGroupProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::E_NOT_DROP, resp.get_code()); -} -// Create Space on group_0, replica factor is less than zone size -{ - cpp2::SpaceDesc properties; - properties.set_space_name("space_on_group_0_1"); - properties.set_partition_num(9); - properties.set_replica_factor(1); - properties.set_group_name("group_0"); - cpp2::CreateSpaceReq req; - req.set_properties(std::move(properties)); - auto* processor = CreateSpaceProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, resp.get_code()); -} -// Create Space on group_0, replica factor is larger than zone size -{ - cpp2::SpaceDesc properties; - properties.set_space_name("space_on_group_0_4"); - properties.set_partition_num(9); - properties.set_replica_factor(4); - properties.set_group_name("group_0"); - cpp2::CreateSpaceReq req; - req.set_properties(std::move(properties)); - auto* processor = CreateSpaceProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::E_INVALID_PARM, resp.get_code()); -} -{ - cpp2::AddZoneIntoGroupReq req; - req.set_group_name("group_0"); - req.set_zone_name("zone_3"); - auto* processor = AddZoneIntoGroupProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, resp.get_code()); -} -{ - cpp2::SpaceDesc properties; - properties.set_space_name("space_on_group_0_4"); - properties.set_partition_num(9); - properties.set_replica_factor(4); - properties.set_group_name("group_0"); - cpp2::CreateSpaceReq req; - req.set_properties(std::move(properties)); - auto* processor = CreateSpaceProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, resp.get_code()); -} -// Create Space on a group which is not exist -{ - cpp2::SpaceDesc properties; - properties.set_space_name("space_on_group_not_exist"); - properties.set_partition_num(9); - properties.set_replica_factor(4); - properties.set_group_name("group_not_exist"); - cpp2::CreateSpaceReq req; - req.set_properties(std::move(properties)); - auto* processor = CreateSpaceProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::E_GROUP_NOT_FOUND, resp.get_code()); -} -// Create space on empty zone -{ - { - std::vector nodes = {HostAddr("10", 10)}; - cpp2::AddZoneReq req; - req.set_zone_name("zone_5"); - req.set_nodes(std::move(nodes)); - auto* processor = AddZoneProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, resp.get_code()); - } - { - cpp2::AddGroupReq req; - req.set_group_name("group_2"); - std::vector zones = {"zone_5"}; - req.set_zone_names(std::move(zones)); - auto* processor = AddGroupProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, resp.get_code()); - } - { - cpp2::DropHostFromZoneReq req; - req.set_zone_name("zone_5"); - HostAddr node{"10", 10}; - req.set_node(std::move(node)); - auto* processor = DropHostFromZoneProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, resp.get_code()); - } - { - cpp2::SpaceDesc properties; - properties.set_space_name("space_on_empty_hosts"); - properties.set_partition_num(1); - properties.set_replica_factor(1); - properties.set_group_name("group_2"); - cpp2::CreateSpaceReq req; - req.set_properties(std::move(properties)); - auto* processor = CreateSpaceProcessor::instance(kv.get()); - auto f = processor->getFuture(); - processor->process(req); - auto resp = std::move(f).get(); - ASSERT_EQ(nebula::cpp2::ErrorCode::E_INVALID_PARM, resp.get_code()); - } -} -} // namespace nebula - TEST(ProcessorTest, CreateTagTest) { fs::TempDir rootPath("/tmp/CreateTagTest.XXXXXX"); auto kv = MockCluster::initMetaKV(rootPath.path()); diff --git a/src/parser/MaintainSentences.cpp b/src/parser/MaintainSentences.cpp index 4b9d5d41028..1a90d068192 100644 --- a/src/parser/MaintainSentences.cpp +++ b/src/parser/MaintainSentences.cpp @@ -358,16 +358,6 @@ std::string ShowCreateEdgeIndexSentence::toString() const { return folly::stringPrintf("SHOW CREATE EDGE INDEX %s", indexName_.get()->c_str()); } -std::string AddGroupSentence::toString() const { - std::string buf; - buf.reserve(64); - buf += "ADD GROUP "; - buf += *groupName_; - buf += " "; - buf += zoneNames_->toString(); - return buf; -} - std::string AddZoneSentence::toString() const { std::string buf; buf.reserve(128); @@ -377,31 +367,16 @@ std::string AddZoneSentence::toString() const { return buf; } -std::string DropGroupSentence::toString() const { - return folly::stringPrintf("DROP GROUP %s", groupName_.get()->c_str()); -} - std::string DropZoneSentence::toString() const { return folly::stringPrintf("DROP ZONE %s", zoneName_.get()->c_str()); } -std::string DescribeGroupSentence::toString() const { - return folly::stringPrintf("DESCRIBE GROUP %s", groupName_.get()->c_str()); -} - std::string DescribeZoneSentence::toString() const { return folly::stringPrintf("DESCRIBE ZONE %s", zoneName_.get()->c_str()); } -std::string ListGroupsSentence::toString() const { return folly::stringPrintf("SHOW GROUPS"); } - std::string ListZonesSentence::toString() const { return folly::stringPrintf("SHOW ZONES"); } -std::string AddZoneIntoGroupSentence::toString() const { - return folly::stringPrintf( - "Add Zone %s Into Group %s", zoneName_.get()->c_str(), groupName_.get()->c_str()); -} - std::string AddHostIntoZoneSentence::toString() const { std::string buf; buf.reserve(64); @@ -412,11 +387,6 @@ std::string AddHostIntoZoneSentence::toString() const { return buf; } -std::string DropZoneFromGroupSentence::toString() const { - return folly::stringPrintf( - "Drop Zone %s From Group %s", zoneName_.get()->c_str(), groupName_.get()->c_str()); -} - std::string DropHostFromZoneSentence::toString() const { std::string buf; buf.reserve(64); diff --git a/src/parser/MaintainSentences.h b/src/parser/MaintainSentences.h index 6f7de95bb26..64a8363300c 100644 --- a/src/parser/MaintainSentences.h +++ b/src/parser/MaintainSentences.h @@ -784,25 +784,6 @@ class ZoneNameList final { std::vector> zones_; }; -class AddGroupSentence : public Sentence { - public: - explicit AddGroupSentence(std::string *groupName, ZoneNameList *zoneNames) { - groupName_.reset(groupName); - zoneNames_.reset(zoneNames); - kind_ = Kind::kAddGroup; - } - - std::string toString() const override; - - const std::string *groupName() const { return groupName_.get(); } - - const ZoneNameList *zoneNames() const { return zoneNames_.get(); } - - private: - std::unique_ptr groupName_; - std::unique_ptr zoneNames_; -}; - class AddZoneSentence : public Sentence { public: explicit AddZoneSentence(std::string *zoneName, HostList *hosts) { @@ -822,21 +803,6 @@ class AddZoneSentence : public Sentence { std::unique_ptr hosts_; }; -class DropGroupSentence : public Sentence { - public: - explicit DropGroupSentence(std::string *groupName) { - groupName_.reset(groupName); - kind_ = Kind::kDropGroup; - } - - std::string toString() const override; - - const std::string *groupName() const { return groupName_.get(); } - - private: - std::unique_ptr groupName_; -}; - class DropZoneSentence : public Sentence { public: explicit DropZoneSentence(std::string *zoneName) { @@ -852,21 +818,6 @@ class DropZoneSentence : public Sentence { std::unique_ptr zoneName_; }; -class DescribeGroupSentence : public Sentence { - public: - explicit DescribeGroupSentence(std::string *groupName) { - groupName_.reset(groupName); - kind_ = Kind::kDescribeGroup; - } - - std::string toString() const override; - - const std::string *groupName() const { return groupName_.get(); } - - private: - std::unique_ptr groupName_; -}; - class DescribeZoneSentence : public Sentence { public: explicit DescribeZoneSentence(std::string *zoneName) { @@ -882,13 +833,6 @@ class DescribeZoneSentence : public Sentence { std::unique_ptr zoneName_; }; -class ListGroupsSentence : public Sentence { - public: - ListGroupsSentence() { kind_ = Kind::kListGroups; } - - std::string toString() const override; -}; - class ListZonesSentence : public Sentence { public: ListZonesSentence() { kind_ = Kind::kListZones; } @@ -896,25 +840,6 @@ class ListZonesSentence : public Sentence { std::string toString() const override; }; -class AddZoneIntoGroupSentence : public Sentence { - public: - AddZoneIntoGroupSentence(std::string *zoneName, std::string *groupName) { - zoneName_.reset(zoneName); - groupName_.reset(groupName); - kind_ = Kind::kAddZoneIntoGroup; - } - - const std::string *zoneName() const { return zoneName_.get(); } - - const std::string *groupName() const { return groupName_.get(); } - - std::string toString() const override; - - private: - std::unique_ptr zoneName_; - std::unique_ptr groupName_; -}; - class AddHostIntoZoneSentence : public Sentence { public: explicit AddHostIntoZoneSentence(HostAddr *address, std::string *zoneName) { @@ -934,25 +859,6 @@ class AddHostIntoZoneSentence : public Sentence { std::unique_ptr address_; }; -class DropZoneFromGroupSentence : public Sentence { - public: - DropZoneFromGroupSentence(std::string *zoneName, std::string *groupName) { - zoneName_.reset(zoneName); - groupName_.reset(groupName); - kind_ = Kind::kDropZoneFromGroup; - } - - const std::string *zoneName() const { return zoneName_.get(); } - - const std::string *groupName() const { return groupName_.get(); } - - std::string toString() const override; - - private: - std::unique_ptr zoneName_; - std::unique_ptr groupName_; -}; - class DropHostFromZoneSentence : public Sentence { public: explicit DropHostFromZoneSentence(HostAddr *address, std::string *zoneName) { diff --git a/src/parser/Sentence.h b/src/parser/Sentence.h index f89801967ff..ade75177b17 100644 --- a/src/parser/Sentence.h +++ b/src/parser/Sentence.h @@ -111,12 +111,6 @@ class Sentence { kAdminJob, kAdminShowJobs, kGetSubgraph, - kAddGroup, - kDropGroup, - kDescribeGroup, - kListGroups, - kAddZoneIntoGroup, - kDropZoneFromGroup, kAddZone, kDropZone, kDescribeZone, diff --git a/src/parser/parser.yy b/src/parser/parser.yy index 0d2c2695029..a656f3aa0d3 100644 --- a/src/parser/parser.yy +++ b/src/parser/parser.yy @@ -120,7 +120,6 @@ static constexpr size_t kCommentLengthLimit = 256; nebula::GroupClause *group_clause; nebula::HostList *host_list; nebula::HostAddr *host_item; - nebula::ZoneNameList *zone_name_list; std::vector *integer_list; nebula::InBoundClause *in_bound_clause; nebula::OutBoundClause *out_bound_clause; @@ -333,7 +332,6 @@ static constexpr size_t kCommentLengthLimit = 256; %type column_spec %type column_spec_list %type column_name_list -%type zone_name_list %type role_type_clause %type acl_item_clause @@ -354,8 +352,6 @@ static constexpr size_t kCommentLengthLimit = 256; %type drop_tag_index_sentence drop_edge_index_sentence drop_fulltext_index_sentence %type describe_tag_index_sentence describe_edge_index_sentence %type rebuild_tag_index_sentence rebuild_edge_index_sentence rebuild_fulltext_index_sentence -%type add_group_sentence drop_group_sentence desc_group_sentence -%type add_zone_into_group_sentence drop_zone_from_group_sentence %type add_zone_sentence drop_zone_sentence desc_zone_sentence %type add_host_into_zone_sentence drop_host_from_zone_sentence %type create_snapshot_sentence drop_snapshot_sentence @@ -2632,38 +2628,6 @@ rebuild_fulltext_index_sentence meta::cpp2::AdminCmd::REBUILD_FULLTEXT_INDEX); } -add_group_sentence - : KW_ADD KW_GROUP name_label zone_name_list { - $$ = new AddGroupSentence($3, $4); - } - ; - -drop_group_sentence - : KW_DROP KW_GROUP name_label { - $$ = new DropGroupSentence($3); - } - ; - -desc_group_sentence - : KW_DESCRIBE KW_GROUP name_label { - $$ = new DescribeGroupSentence($3); - } - | KW_DESC KW_GROUP name_label { - $$ = new DescribeGroupSentence($3); - } - ; - -add_zone_into_group_sentence - : KW_ADD KW_ZONE name_label KW_INTO KW_GROUP name_label { - $$ = new AddZoneIntoGroupSentence($3, $6); - } - ; - -drop_zone_from_group_sentence - : KW_DROP KW_ZONE name_label KW_FROM KW_GROUP name_label { - $$ = new DropZoneFromGroupSentence($3, $6); - } - ; add_zone_sentence : KW_ADD KW_ZONE name_label host_list { @@ -3188,9 +3152,6 @@ show_sentence | KW_SHOW KW_COLLATION { $$ = new ShowCollationSentence(); } - | KW_SHOW KW_GROUPS { - $$ = new ListGroupsSentence(); - } | KW_SHOW KW_ZONES { $$ = new ListZonesSentence(); } @@ -3259,17 +3220,6 @@ show_config_item } ; -zone_name_list - : name_label { - $$ = new ZoneNameList(); - $$->addZone($1); - } - | zone_name_list COMMA name_label { - $$ = $1; - $$->addZone($3); - } - ; - create_space_sentence : KW_CREATE KW_SPACE opt_if_not_exists name_label { auto sentence = new CreateSpaceSentence($4, $3); @@ -3628,11 +3578,6 @@ maintain_sentence | rebuild_tag_index_sentence { $$ = $1; } | rebuild_edge_index_sentence { $$ = $1; } | rebuild_fulltext_index_sentence { $$ = $1; } - | add_group_sentence { $$ = $1; } - | drop_group_sentence { $$ = $1; } - | desc_group_sentence { $$ = $1; } - | add_zone_into_group_sentence { $$ = $1; } - | drop_zone_from_group_sentence { $$ = $1; } | add_zone_sentence { $$ = $1; } | drop_zone_sentence { $$ = $1; } | desc_zone_sentence { $$ = $1; } diff --git a/src/parser/test/ParserTest.cpp b/src/parser/test/ParserTest.cpp index 5267339a4c2..f1249614e67 100644 --- a/src/parser/test/ParserTest.cpp +++ b/src/parser/test/ParserTest.cpp @@ -2710,11 +2710,6 @@ TEST_F(ParserTest, MatchListSubscriptRange) { } TEST_F(ParserTest, Zone) { - { - std::string query = "SHOW GROUPS"; - auto result = parse(query); - ASSERT_TRUE(result.ok()) << result.status(); - } { std::string query = "SHOW ZONES"; auto result = parse(query); @@ -2750,36 +2745,6 @@ TEST_F(ParserTest, Zone) { auto result = parse(query); ASSERT_TRUE(result.ok()) << result.status(); } - { - std::string query = "ADD GROUP group_0 zone_0,zone_1,zone_2"; - auto result = parse(query); - ASSERT_TRUE(result.ok()) << result.status(); - } - { - std::string query = "ADD ZONE zone_3 INTO GROUP group_0"; - auto result = parse(query); - ASSERT_TRUE(result.ok()) << result.status(); - } - { - std::string query = "DROP ZONE zone_3 FROM GROUP group_0"; - auto result = parse(query); - ASSERT_TRUE(result.ok()) << result.status(); - } - { - std::string query = "DESC GROUP group_0"; - auto result = parse(query); - ASSERT_TRUE(result.ok()) << result.status(); - } - { - std::string query = "DESCRIBE GROUP group_0"; - auto result = parse(query); - ASSERT_TRUE(result.ok()) << result.status(); - } - { - std::string query = "DROP GROUP group_0"; - auto result = parse(query); - ASSERT_TRUE(result.ok()) << result.status(); - } } TEST_F(ParserTest, FullText) { diff --git a/tests/maintain/test_zone.py b/tests/maintain/test_zone.py index bfa504d6bc6..9e74d876af9 100644 --- a/tests/maintain/test_zone.py +++ b/tests/maintain/test_zone.py @@ -36,39 +36,6 @@ def test_zone(self): resp = self.client.execute('SHOW ZONES') self.check_resp_succeeded(resp) - # Add Group - resp = self.client.execute('ADD GROUP group_0 zone_0') - self.check_resp_succeeded(resp) - - resp = self.client.execute('ADD GROUP default zone_0') - self.check_resp_failed(resp) - - # Get Group - resp = self.client.execute('DESC GROUP group_0') - self.check_resp_succeeded(resp) - - resp = self.client.execute('DESCRIBE GROUP group_0') - self.check_resp_succeeded(resp) - - # Get Group which is not exist - resp = self.client.execute('DESC GROUP group_not_exist') - self.check_resp_failed(resp) - - resp = self.client.execute('DESCRIBE GROUP group_not_exist') - self.check_resp_failed(resp) - - # SHOW Groups - resp = self.client.execute('SHOW GROUPS') - self.check_resp_succeeded(resp) - - # Drop Group - resp = self.client.execute('DROP GROUP group_0') - self.check_resp_succeeded(resp) - - # Drop Group which is not exist - resp = self.client.execute('DROP GROUP group_0') - self.check_resp_failed(resp) - # Drop Zone resp = self.client.execute('DROP ZONE zone_0') self.check_resp_succeeded(resp)