From fee69703a724b936116b0ae8fd567f48333a5f44 Mon Sep 17 00:00:00 2001 From: Sherman Ye Date: Thu, 23 Dec 2021 09:23:50 +0800 Subject: [PATCH] Minor change --- src/clients/meta/MetaClient.cpp | 8 ++++---- src/common/base/Status.h | 2 +- src/meta/processors/admin/AgentHBProcessor.cpp | 12 ++++++------ .../processors/admin/ListClusterInfoProcessor.cpp | 6 +++--- src/meta/processors/admin/SnapShot.cpp | 2 +- src/meta/test/AgentHBProcessorTest.cpp | 14 +++++++------- src/meta/test/ListClusterInfoTest.cpp | 4 ++-- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/clients/meta/MetaClient.cpp b/src/clients/meta/MetaClient.cpp index 0140b553557..0e7c6ae3568 100644 --- a/src/clients/meta/MetaClient.cpp +++ b/src/clients/meta/MetaClient.cpp @@ -2455,12 +2455,12 @@ folly::Future> MetaClient::heartbeat() { if (!dirInfoReported_) { nebula::cpp2::DirInfo dirInfo; if (options_.role_ == cpp2::HostRole::GRAPH) { - dirInfo.set_root(options_.rootPath_); + dirInfo.root_ref() = options_.rootPath_; } else if (options_.role_ == cpp2::HostRole::STORAGE) { - dirInfo.set_root(options_.rootPath_); - dirInfo.set_data(options_.dataPaths_); + dirInfo.root_ref() = options_.rootPath_; + dirInfo.data_ref() = options_.dataPaths_; } - req.set_dir(dirInfo); + req.dir_ref() = dirInfo; } folly::Promise> promise; diff --git a/src/common/base/Status.h b/src/common/base/Status.h index 54c51a89c7d..2783cb7a70b 100644 --- a/src/common/base/Status.h +++ b/src/common/base/Status.h @@ -28,7 +28,7 @@ class Status final { ~Status() = default; Status(const Status &rhs) { - state_ = (!rhs.state_ ? nullptr : copyState(rhs.state_.get())); + state_ = (rhs.state_ == nullptr ? nullptr : copyState(rhs.state_.get())); } Status &operator=(const Status &rhs) { diff --git a/src/meta/processors/admin/AgentHBProcessor.cpp b/src/meta/processors/admin/AgentHBProcessor.cpp index ddd19906421..1df56fdab0e 100644 --- a/src/meta/processors/admin/AgentHBProcessor.cpp +++ b/src/meta/processors/admin/AgentHBProcessor.cpp @@ -91,9 +91,9 @@ void AgentHBProcessor::process(const cpp2::AgentHBReq& req) { } cpp2::ServiceInfo serviceInfo; - serviceInfo.set_addr(addr); - serviceInfo.set_dir(it->second); - serviceInfo.set_role(role); + serviceInfo.addr_ref() = addr; + serviceInfo.dir_ref() = it->second; + serviceInfo.role_ref() = role; serviceList.emplace_back(serviceInfo); } if (serviceList.size() != services.size() - 1) { @@ -120,13 +120,13 @@ void AgentHBProcessor::process(const cpp2::AgentHBReq& req) { auto metaAddr = Utils::getStoreAddrFromRaftAddr(raftAddr); if (metaAddr.host == agentAddr.host) { cpp2::ServiceInfo serviceInfo; - serviceInfo.set_addr(metaAddr); - serviceInfo.set_role(cpp2::HostRole::META); + serviceInfo.addr_ref() = metaAddr; + serviceInfo.role_ref() = cpp2::HostRole::META; serviceList.emplace_back(serviceInfo); } } - resp_.set_service_list(serviceList); + resp_.service_list_ref() = serviceList; } while (false); handleErrorCode(ret); diff --git a/src/meta/processors/admin/ListClusterInfoProcessor.cpp b/src/meta/processors/admin/ListClusterInfoProcessor.cpp index 3c1fa753813..ce5215e2f98 100644 --- a/src/meta/processors/admin/ListClusterInfoProcessor.cpp +++ b/src/meta/processors/admin/ListClusterInfoProcessor.cpp @@ -41,8 +41,8 @@ void ListClusterInfoProcessor::process(const cpp2::ListClusterInfoReq& req) { HostInfo info = HostInfo::decode(iter->val()); cpp2::ServiceInfo service; - service.set_role(info.role_); - service.set_addr(addr); + service.role_ref() = info.role_; + service.addr_ref() = addr; // fill the dir info if (info.role_ == meta::cpp2::HostRole::GRAPH || info.role_ == meta::cpp2::HostRole::STORAGE) { @@ -58,7 +58,7 @@ void ListClusterInfoProcessor::process(const cpp2::ListClusterInfoReq& req) { return; } auto dir = MetaKeyUtils::parseHostDir(std::move(nebula::value(dirRet))); - service.set_dir(std::move(dir)); + service.dir_ref() = std::move(dir); } if (hostServices.find(addr.host) == hostServices.end()) { diff --git a/src/meta/processors/admin/SnapShot.cpp b/src/meta/processors/admin/SnapShot.cpp index 733b9cae007..49452bd83d5 100644 --- a/src/meta/processors/admin/SnapShot.cpp +++ b/src/meta/processors/admin/SnapShot.cpp @@ -44,7 +44,7 @@ Snapshot::createSnapshot(const std::string& name) { auto it = spaceBackup.find(ck.get_space_id()); if (it == spaceBackup.cend()) { cpp2::HostBackupInfo hostBackup; - hostBackup.set_host(host); + hostBackup.host_ref() = host; hostBackup.checkpoints_ref().value().push_back(ck); spaceBackup[ck.get_space_id()] = std::move(hostBackup); } else { diff --git a/src/meta/test/AgentHBProcessorTest.cpp b/src/meta/test/AgentHBProcessorTest.cpp index edda9d32521..2a344037dcd 100644 --- a/src/meta/test/AgentHBProcessorTest.cpp +++ b/src/meta/test/AgentHBProcessorTest.cpp @@ -34,15 +34,15 @@ TEST(AgentHBProcessorTest, AgentHBTest) { const ClusterID kClusterId = 10; for (auto i = 0; i < 5; i++) { cpp2::HBReq req; - req.set_host(HostAddr(std::to_string(i), i)); - req.set_cluster_id(kClusterId); - req.set_role(cpp2::HostRole::STORAGE); + req.host_ref() = HostAddr(std::to_string(i), i); + req.cluster_id_ref() = kClusterId; + req.role_ref() = cpp2::HostRole::STORAGE; nebula::cpp2::DirInfo dir; - dir.set_root("/tmp/nebula"); + dir.root_ref() = "/tmp/nebula"; std::vector ds; ds.push_back("/tmp/nebula/data"); - dir.set_data(ds); - req.set_dir(dir); + dir.data_ref() = ds; + req.dir_ref() = dir; auto* processor = HBProcessor::instance(kv.get(), nullptr, kClusterId); auto f = processor->getFuture(); @@ -55,7 +55,7 @@ TEST(AgentHBProcessorTest, AgentHBTest) { // mock an agent in each host for (auto i = 0; i < 5; i++) { cpp2::AgentHBReq req; - req.set_host(HostAddr(std::to_string(i), 10 + i)); + req.host_ref() = HostAddr(std::to_string(i), 10 + i); auto* processor = AgentHBProcessor::instance(kv.get(), nullptr); auto f = processor->getFuture(); processor->process(req); diff --git a/src/meta/test/ListClusterInfoTest.cpp b/src/meta/test/ListClusterInfoTest.cpp index 1a6cdbd1b02..a804f57076f 100644 --- a/src/meta/test/ListClusterInfoTest.cpp +++ b/src/meta/test/ListClusterInfoTest.cpp @@ -42,10 +42,10 @@ TEST(ProcessorTest, ListClusterInfoTest) { std::vector dirs; nebula::cpp2::DirInfo dir; - dir.set_root(std::string(root_dir)); + dir.root_ref() = std::string(root_dir); std::vector ds; ds.push_back(std::string(data_dir)); - dir.set_data(ds); + dir.data_ref() = ds; dirs.emplace_back(std::make_pair(MetaKeyUtils::hostDirKey(storageHost.host, storageHost.port), MetaKeyUtils::hostDirVal(dir))); folly::Baton b;