diff --git a/src/clients/meta/MetaClient.cpp b/src/clients/meta/MetaClient.cpp index 3f17c569292..e66cf8fbf65 100644 --- a/src/clients/meta/MetaClient.cpp +++ b/src/clients/meta/MetaClient.cpp @@ -1217,9 +1217,9 @@ folly::Future> MetaClient::alterSpace(const std::string& spaceNam meta::cpp2::AlterSpaceOp op, const std::vector& paras) { cpp2::AlterSpaceReq req; - req.set_op(op); - req.set_space_name(spaceName); - req.set_paras(paras); + req.op_ref() = op; + req.space_name_ref() = spaceName; + req.paras_ref() = paras; folly::Promise> promise; auto future = promise.getFuture(); getResponse( diff --git a/src/graph/planner/plan/Admin.h b/src/graph/planner/plan/Admin.h index 9a0d04fa969..5c7a1fe92a6 100644 --- a/src/graph/planner/plan/Admin.h +++ b/src/graph/planner/plan/Admin.h @@ -225,11 +225,17 @@ class AlterSpace final : public SingleDependencyNode { const std::vector& paras) { return qctx->objPool()->add(new AlterSpace(qctx, input, spaceName, op, paras)); } - const std::string& getSpaceName() const { return spaceName_; } + const std::string& getSpaceName() const { + return spaceName_; + } - meta::cpp2::AlterSpaceOp getAlterSpaceOp() const { return op_; } + meta::cpp2::AlterSpaceOp getAlterSpaceOp() const { + return op_; + } - const std::vector& getParas() const { return paras_; } + const std::vector& getParas() const { + return paras_; + } private: AlterSpace(QueryContext* qctx, diff --git a/src/graph/validator/AdminValidator.cpp b/src/graph/validator/AdminValidator.cpp index ff2f578e438..5afcdb2a925 100644 --- a/src/graph/validator/AdminValidator.cpp +++ b/src/graph/validator/AdminValidator.cpp @@ -163,7 +163,9 @@ Status CreateSpaceAsValidator::toPlan() { return Status::OK(); } -Status AlterSpaceValidator::validateImpl() { return Status::OK(); } +Status AlterSpaceValidator::validateImpl() { + return Status::OK(); +} Status AlterSpaceValidator::toPlan() { auto sentence = static_cast(sentence_); @@ -174,7 +176,9 @@ Status AlterSpaceValidator::toPlan() { return Status::OK(); } -Status DescSpaceValidator::validateImpl() { return Status::OK(); } +Status DescSpaceValidator::validateImpl() { + return Status::OK(); +} Status DescSpaceValidator::toPlan() { auto sentence = static_cast(sentence_); diff --git a/src/meta/processors/job/BalanceJobExecutor.h b/src/meta/processors/job/BalanceJobExecutor.h index 639b6a6f41c..216641b1f2b 100644 --- a/src/meta/processors/job/BalanceJobExecutor.h +++ b/src/meta/processors/job/BalanceJobExecutor.h @@ -26,7 +26,9 @@ struct Host { struct Zone { Zone() = default; explicit Zone(const std::string name) : zoneName_(name) {} - bool hasHost(const HostAddr& ha) { return hosts_.find(ha) != hosts_.end(); } + bool hasHost(const HostAddr& ha) { + return hosts_.find(ha) != hosts_.end(); + } int32_t calPartNum(); bool partExist(PartitionID partId); @@ -65,7 +67,9 @@ class BalanceJobExecutor : public MetaJobExecutor { protected: nebula::cpp2::ErrorCode save(const std::string& k, const std::string& v); - virtual Status buildBalancePlan() { return Status::OK(); } + virtual Status buildBalancePlan() { + return Status::OK(); + } protected: std::unique_ptr plan_; diff --git a/src/meta/processors/job/MetaJobExecutor.cpp b/src/meta/processors/job/MetaJobExecutor.cpp index dc3cc4e8d7d..643aaa20921 100644 --- a/src/meta/processors/job/MetaJobExecutor.cpp +++ b/src/meta/processors/job/MetaJobExecutor.cpp @@ -12,10 +12,14 @@ DECLARE_uint32(expired_time_factor); namespace nebula { namespace meta { -bool MetaJobExecutor::check() { return true; } +bool MetaJobExecutor::check() { + return true; +} // Prepare the Job info from the arguments. -nebula::cpp2::ErrorCode MetaJobExecutor::prepare() { return nebula::cpp2::ErrorCode::SUCCEEDED; } +nebula::cpp2::ErrorCode MetaJobExecutor::prepare() { + return nebula::cpp2::ErrorCode::SUCCEEDED; +} // The skeleton to run the job. // You should rewrite the executeInternal to trigger the calling. @@ -31,15 +35,25 @@ nebula::cpp2::ErrorCode MetaJobExecutor::execute() { } // Stop the job when the user cancel it. -nebula::cpp2::ErrorCode MetaJobExecutor::stop() { return nebula::cpp2::ErrorCode::SUCCEEDED; } +nebula::cpp2::ErrorCode MetaJobExecutor::stop() { + return nebula::cpp2::ErrorCode::SUCCEEDED; +} -nebula::cpp2::ErrorCode MetaJobExecutor::finish(bool) { return nebula::cpp2::ErrorCode::SUCCEEDED; } +nebula::cpp2::ErrorCode MetaJobExecutor::finish(bool) { + return nebula::cpp2::ErrorCode::SUCCEEDED; +} -void MetaJobExecutor::setSpaceId(GraphSpaceID spaceId) { space_ = spaceId; } +void MetaJobExecutor::setSpaceId(GraphSpaceID spaceId) { + space_ = spaceId; +} -bool MetaJobExecutor::isMetaJob() { return true; } +bool MetaJobExecutor::isMetaJob() { + return true; +} -nebula::cpp2::ErrorCode MetaJobExecutor::recovery() { return nebula::cpp2::ErrorCode::SUCCEEDED; } +nebula::cpp2::ErrorCode MetaJobExecutor::recovery() { + return nebula::cpp2::ErrorCode::SUCCEEDED; +} void MetaJobExecutor::setFinishCallBack( std::function func) { @@ -50,7 +64,9 @@ nebula::cpp2::ErrorCode MetaJobExecutor::saveSpecialTaskStatus(const cpp2::Repor return nebula::cpp2::ErrorCode::SUCCEEDED; } -folly::Future MetaJobExecutor::executeInternal() { return Status::OK(); } +folly::Future MetaJobExecutor::executeInternal() { + return Status::OK(); +} } // namespace meta } // namespace nebula diff --git a/src/meta/processors/job/StorageJobExecutor.h b/src/meta/processors/job/StorageJobExecutor.h index 9bb9c5bf07e..c5eb0d32170 100644 --- a/src/meta/processors/job/StorageJobExecutor.h +++ b/src/meta/processors/job/StorageJobExecutor.h @@ -33,10 +33,14 @@ class StorageJobExecutor : public JobExecutor { virtual ~StorageJobExecutor() = default; // Check the arguments about the job. - bool check() override { return true; } + bool check() override { + return true; + } // Prepare the Job info from the arguments. - nebula::cpp2::ErrorCode prepare() override { return nebula::cpp2::ErrorCode::SUCCEEDED; } + nebula::cpp2::ErrorCode prepare() override { + return nebula::cpp2::ErrorCode::SUCCEEDED; + } // The skeleton to run the job. // You should rewrite the executeInternal to trigger the calling. @@ -45,19 +49,29 @@ class StorageJobExecutor : public JobExecutor { void interruptExecution(JobID jobId); // Stop the job when the user cancel it. - nebula::cpp2::ErrorCode stop() override { return nebula::cpp2::ErrorCode::SUCCEEDED; } + nebula::cpp2::ErrorCode stop() override { + return nebula::cpp2::ErrorCode::SUCCEEDED; + } - nebula::cpp2::ErrorCode finish(bool) override { return nebula::cpp2::ErrorCode::SUCCEEDED; } + nebula::cpp2::ErrorCode finish(bool) override { + return nebula::cpp2::ErrorCode::SUCCEEDED; + } - void setSpaceId(GraphSpaceID spaceId) override { space_ = spaceId; } + void setSpaceId(GraphSpaceID spaceId) override { + space_ = spaceId; + } nebula::cpp2::ErrorCode saveSpecialTaskStatus(const cpp2::ReportTaskReq&) override { return nebula::cpp2::ErrorCode::SUCCEEDED; } - bool isMetaJob() override { return false; } + bool isMetaJob() override { + return false; + } - nebula::cpp2::ErrorCode recovery() override { return nebula::cpp2::ErrorCode::SUCCEEDED; } + nebula::cpp2::ErrorCode recovery() override { + return nebula::cpp2::ErrorCode::SUCCEEDED; + } protected: ErrOrHosts getTargetHost(GraphSpaceID space); diff --git a/src/meta/processors/job/ZoneBalanceJobExecutor.cpp b/src/meta/processors/job/ZoneBalanceJobExecutor.cpp index 4059b5b18be..0d1833247ce 100644 --- a/src/meta/processors/job/ZoneBalanceJobExecutor.cpp +++ b/src/meta/processors/job/ZoneBalanceJobExecutor.cpp @@ -73,7 +73,7 @@ nebula::cpp2::ErrorCode ZoneBalanceJobExecutor::updateMeta() { for (auto& zoneMapEntry : spaceInfo_.zones_) { zones.emplace_back(zoneMapEntry.first); } - properties.set_zone_names(std::move(zones)); + properties.zone_names_ref() = std::move(zones); std::vector data; data.emplace_back(MetaKeyUtils::spaceKey(spaceInfo_.spaceId_), MetaKeyUtils::spaceVal(properties)); diff --git a/src/meta/processors/parts/AlterSpaceProcessor.cpp b/src/meta/processors/parts/AlterSpaceProcessor.cpp index 090df5f93fe..bcfb3b5972b 100644 --- a/src/meta/processors/parts/AlterSpaceProcessor.cpp +++ b/src/meta/processors/parts/AlterSpaceProcessor.cpp @@ -65,7 +65,7 @@ nebula::cpp2::ErrorCode AlterSpaceProcessor::addZones(const std::string& spaceNa } newZones.emplace_back(z); } - properties.set_zone_names(newZones); + properties.zone_names_ref() = newZones; std::vector data; data.emplace_back(MetaKeyUtils::spaceKey(spaceId), MetaKeyUtils::spaceVal(properties)); folly::Baton baton; diff --git a/src/meta/test/BalancerTest.cpp b/src/meta/test/BalancerTest.cpp index 8edb86eb22c..340e8f3260e 100644 --- a/src/meta/test/BalancerTest.cpp +++ b/src/meta/test/BalancerTest.cpp @@ -1285,7 +1285,7 @@ TEST(BalanceTest, LeaderBalanceWithLargerZoneTest) { } } -TEST(BalanceTest, DISABLED_LeaderBalanceWithComplexZoneTest) { +TEST(BalanceTest, LeaderBalanceWithComplexZoneTest) { fs::TempDir rootPath("/tmp/LeaderBalanceWithComplexZoneTest.XXXXXX"); auto store = MockCluster::initMetaKV(rootPath.path()); auto* kv = dynamic_cast(store.get()); diff --git a/src/meta/test/GetStatsTest.cpp b/src/meta/test/GetStatsTest.cpp index 8cb7a3e1454..aa6ce2e3da4 100644 --- a/src/meta/test/GetStatsTest.cpp +++ b/src/meta/test/GetStatsTest.cpp @@ -62,11 +62,11 @@ struct JobCallBack { req.task_id_ref() = taskId_; cpp2::StatsItem item; - item.set_tag_vertices({{"t1", n_}, {"t2", n_}}); - item.set_edges({{"e1", n_}, {"e2", n_}}); - item.set_space_vertices(2 * n_); - item.set_space_edges(2 * n_); - req.set_stats(item); + item.tag_vertices_ref() = {{"t1", n_}, {"t2", n_}}; + item.edges_ref() = {{"e1", n_}, {"e2", n_}}; + item.space_vertices_ref() = 2 * n_; + item.space_edges_ref() = 2 * n_; + req.stats_ref() = item; jobMgr_->muJobFinished_.unlock(); jobMgr_->reportTaskFinish(req); return folly::Future(Status::OK()); diff --git a/src/meta/test/ProcessorTest.cpp b/src/meta/test/ProcessorTest.cpp index 08ea71d77aa..01d01de8f0b 100644 --- a/src/meta/test/ProcessorTest.cpp +++ b/src/meta/test/ProcessorTest.cpp @@ -3653,9 +3653,9 @@ TEST(ProcessorTest, AlterSpaceTest) { { AlterSpaceProcessor* processor = AlterSpaceProcessor::instance(kv); meta::cpp2::AlterSpaceReq req; - req.set_space_name("test_space"); - req.set_op(meta::cpp2::AlterSpaceOp::ADD_ZONE); - req.set_paras({"12"}); + req.space_name_ref() = "test_space"; + req.op_ref() = meta::cpp2::AlterSpaceOp::ADD_ZONE; + req.paras_ref() = {"12"}; auto f = processor->getFuture(); processor->process(req); auto resp = std::move(f).get(); @@ -3664,9 +3664,9 @@ TEST(ProcessorTest, AlterSpaceTest) { { AlterSpaceProcessor* processor = AlterSpaceProcessor::instance(kv); meta::cpp2::AlterSpaceReq req; - req.set_space_name("aaa"); - req.set_op(meta::cpp2::AlterSpaceOp::ADD_ZONE); - req.set_paras({"9"}); + req.space_name_ref() = "aaa"; + req.op_ref() = meta::cpp2::AlterSpaceOp::ADD_ZONE; + req.paras_ref() = {"9"}; auto f = processor->getFuture(); processor->process(req); auto resp = std::move(f).get(); @@ -3675,9 +3675,9 @@ TEST(ProcessorTest, AlterSpaceTest) { { AlterSpaceProcessor* processor = AlterSpaceProcessor::instance(kv); meta::cpp2::AlterSpaceReq req; - req.set_space_name("test_space"); - req.set_op(meta::cpp2::AlterSpaceOp::ADD_ZONE); - req.set_paras({"8"}); + req.space_name_ref() = "test_space"; + req.op_ref() = meta::cpp2::AlterSpaceOp::ADD_ZONE; + req.paras_ref() = {"8"}; auto f = processor->getFuture(); processor->process(req); auto resp = std::move(f).get(); @@ -3686,9 +3686,9 @@ TEST(ProcessorTest, AlterSpaceTest) { { AlterSpaceProcessor* processor = AlterSpaceProcessor::instance(kv); meta::cpp2::AlterSpaceReq req; - req.set_space_name("test_space"); - req.set_op(meta::cpp2::AlterSpaceOp::ADD_ZONE); - req.set_paras({"9", "10", "11"}); + req.space_name_ref() = "test_space"; + req.op_ref() = meta::cpp2::AlterSpaceOp::ADD_ZONE; + req.paras_ref() = {"9", "10", "11"}; auto f = processor->getFuture(); processor->process(req); auto resp = std::move(f).get(); diff --git a/src/meta/test/TestUtils.h b/src/meta/test/TestUtils.h index 7c09ab0646d..ba95e4bcbf7 100644 --- a/src/meta/test/TestUtils.h +++ b/src/meta/test/TestUtils.h @@ -215,9 +215,9 @@ class TestUtils { int32_t zoneNum, int32_t totalHost) { cpp2::SpaceDesc properties; - properties.set_space_name("test_space"); - properties.set_partition_num(partitionNum); - properties.set_replica_factor(replica); + properties.space_name_ref() = "test_space"; + properties.partition_num_ref() = partitionNum; + properties.replica_factor_ref() = replica; auto spaceVal = MetaKeyUtils::spaceVal(properties); std::vector data; data.emplace_back(MetaKeyUtils::indexSpaceKey("test_space"), @@ -230,7 +230,7 @@ class TestUtils { zonePartNum[std::to_string(i + 1)] = 0; zoneNames.push_back(std::to_string(i + 1)); } - properties.set_zone_names(zoneNames); + properties.zone_names_ref() = zoneNames; data.emplace_back(MetaKeyUtils::spaceKey(id), MetaKeyUtils::spaceVal(properties)); std::vector allHosts; for (int32_t i = 0; i < totalHost; i++) { diff --git a/src/parser/AdminSentences.h b/src/parser/AdminSentences.h index e91ca21e2ce..723d7a1b522 100644 --- a/src/parser/AdminSentences.h +++ b/src/parser/AdminSentences.h @@ -445,13 +445,21 @@ class AlterSpaceSentence final : public Sentence { : op_(op), spaceName_(spaceName) { kind_ = Kind::kAlterSpace; } - void addPara(const std::string& para) { paras_.push_back(para); } + void addPara(const std::string& para) { + paras_.push_back(para); + } - std::string spaceName() const { return *spaceName_; } + std::string spaceName() const { + return *spaceName_; + } - const std::vector& paras() const { return paras_; } + const std::vector& paras() const { + return paras_; + } - meta::cpp2::AlterSpaceOp alterSpaceOp() const { return op_; } + meta::cpp2::AlterSpaceOp alterSpaceOp() const { + return op_; + } std::string toString() const override; diff --git a/src/parser/test/ParserTest.cpp b/src/parser/test/ParserTest.cpp index 27004ab8a7b..7c7eedd17ed 100644 --- a/src/parser/test/ParserTest.cpp +++ b/src/parser/test/ParserTest.cpp @@ -2016,22 +2016,22 @@ TEST_F(ParserTest, BalanceOperation) { ASSERT_TRUE(result.ok()) << result.status(); } { - std::string query = "BALANCE DATA"; + std::string query = "BALANCE IN ZONE"; auto result = parse(query); ASSERT_TRUE(result.ok()) << result.status(); } { - std::string query = "BALANCE DATA 1234567890"; + std::string query = "BALANCE ACROSS ZONE"; auto result = parse(query); ASSERT_TRUE(result.ok()) << result.status(); } { - std::string query = "BALANCE DATA REMOVE 192.168.0.1:50000,192.168.0.1:50001"; + std::string query = "BALANCE IN ZONE REMOVE 192.168.0.1:50000,192.168.0.1:50001"; auto result = parse(query); ASSERT_TRUE(result.ok()) << result.status(); } { - std::string query = "BALANCE DATA REMOVE 192.168.0.1:50000,\"localhost\":50001"; + std::string query = "BALANCE IN ZONE REMOVE 192.168.0.1:50000,\"localhost\":50001"; auto result = parse(query); ASSERT_TRUE(result.ok()) << result.status(); }