Skip to content

Commit

Permalink
chore: add logs
Browse files Browse the repository at this point in the history
  • Loading branch information
oh2024 committed Apr 12, 2024
1 parent d345297 commit a062271
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions src/zk/zk_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,26 @@ bool ZkClient::RegisterName() {
sname_vec.push_back(*it);
}
}
if (std::find(sname_vec.begin(), sname_vec.end(), sname) != sname_vec.end() &&
IsExistNode(names_root_path_ + "/" + sname) == 0) {
std::string ep;
if (GetNodeValue(names_root_path_ + "/" + sname, ep) && ep == real_endpoint_) {
LOG(INFO) << "node:" << sname << "value:" << ep << " exist";
return true;

if (std::find(sname_vec.begin(), sname_vec.end(), sname) != sname_vec.end()) {
auto node_path = names_root_path_ + "/" + sname;
if (auto code = IsExistNode(node_path); code == 0) {
std::string ep;
if (GetNodeValue(node_path, ep)) {
if (ep == real_endpoint_) {
LOG(INFO) << "node:" << sname << "value:" << ep << " exist";
return true;
} else {
LOG(WARNING) << "server name:" << sname << " duplicate";
return false;
}
} else {
LOG(WARNING) << "server name:" << sname << " GetNodeValue failed";
return false;
}
} else {
LOG(INFO) << "node:" << sname << "does not exist";
}
LOG(WARNING) << "server name:" << sname << " duplicate";
return false;
}

std::string name = names_root_path_ + "/" + sname;
Expand Down

0 comments on commit a062271

Please sign in to comment.