MCPcopy Create free account
hub / github.com/4paradigm/OpenMLDB / UpdateClient

Method UpdateClient

src/catalog/client_manager.cc:459–489  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

457}
458
459bool ClientManager::UpdateClient(const std::map<std::string, std::string>& endpoint_map) {
460 if (endpoint_map.empty()) {
461 DLOG(INFO) << "endpoint_map is empty";
462 return true;
463 }
464 std::lock_guard<::fedb::base::SpinMutex> lock(mu_);
465 for (const auto& kv : endpoint_map) {
466 auto it = real_endpoint_map_.find(kv.first);
467 if (it == real_endpoint_map_.end()) {
468 auto wrapper = std::make_shared<TabletAccessor>(kv.first);
469 if (!wrapper->UpdateClient(kv.second)) {
470 LOG(WARNING) << "add client failed. name " << kv.first << ", endpoint " << kv.second;
471 continue;
472 }
473 LOG(INFO) << "add client. name " << kv.first << ", endpoint " << kv.second;
474 clients_.emplace(kv.first, wrapper);
475 real_endpoint_map_.emplace(kv.first, kv.second);
476 continue;
477 }
478 if (it->second != kv.second) {
479 auto client_it = clients_.find(kv.first);
480 LOG(INFO) << "update client " << kv.first << "from " << it->second << " to " << kv.second;
481 if (!client_it->second->UpdateClient(kv.second)) {
482 LOG(WARNING) << "update client failed. name " << kv.first << ", endpoint " << kv.second;
483 continue;
484 }
485 it->second = kv.second;
486 }
487 }
488 return true;
489}
490
491bool ClientManager::UpdateClient(
492 const std::map<std::string, std::shared_ptr<::fedb::client::TabletClient>>& tablet_clients) {

Callers

nothing calls this directly

Calls 2

GetRealEndpointMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected