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

Method UpdatePartitionClientManager

src/catalog/client_manager.cc:411–432  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

409}
410
411bool TableClientManager::UpdatePartitionClientManager(const ::fedb::storage::PartitionSt& partition,
412 const ClientManager& client_manager) {
413 uint32_t pid = partition.GetPid();
414 if (pid > partition_managers_.size()) {
415 return false;
416 }
417 auto leader = client_manager.GetTablet(partition.GetLeader());
418 if (!leader) {
419 return false;
420 }
421 std::vector<std::shared_ptr<TabletAccessor>> followers;
422 for (const auto& endpoint : partition.GetFollower()) {
423 auto client = client_manager.GetTablet(endpoint);
424 if (!client) {
425 return false;
426 }
427 followers.push_back(client);
428 }
429 auto partition_manager = std::make_shared<PartitionClientManager>(pid, leader, followers);
430 std::atomic_store_explicit(&partition_managers_[pid], partition_manager, std::memory_order_relaxed);
431 return true;
432}
433
434std::shared_ptr<TabletAccessor> ClientManager::GetTablet(const std::string& name) const {
435 std::lock_guard<::fedb::base::SpinMutex> lock(mu_);

Callers 1

UpdateMethod · 0.80

Calls 5

GetFollowerMethod · 0.80
GetPidMethod · 0.45
sizeMethod · 0.45
GetTabletMethod · 0.45
GetLeaderMethod · 0.45

Tested by

no test coverage detected