Skip to content

Commit

Permalink
Minor change
Browse files Browse the repository at this point in the history
  • Loading branch information
sherman-the-tank committed Dec 23, 2021
1 parent 5730710 commit fee6970
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 24 deletions.
8 changes: 4 additions & 4 deletions src/clients/meta/MetaClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2455,12 +2455,12 @@ folly::Future<StatusOr<bool>> 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<StatusOr<bool>> promise;
Expand Down
2 changes: 1 addition & 1 deletion src/common/base/Status.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
12 changes: 6 additions & 6 deletions src/meta/processors/admin/AgentHBProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/meta/processors/admin/ListClusterInfoProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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()) {
Expand Down
2 changes: 1 addition & 1 deletion src/meta/processors/admin/SnapShot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 7 additions & 7 deletions src/meta/test/AgentHBProcessorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> 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();
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/meta/test/ListClusterInfoTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ TEST(ProcessorTest, ListClusterInfoTest) {

std::vector<kvstore::KV> dirs;
nebula::cpp2::DirInfo dir;
dir.set_root(std::string(root_dir));
dir.root_ref() = std::string(root_dir);
std::vector<std::string> 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<true, std::atomic> b;
Expand Down

0 comments on commit fee6970

Please sign in to comment.