| 409 | } |
| 410 | |
| 411 | bool 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 | |
| 434 | std::shared_ptr<TabletAccessor> ClientManager::GetTablet(const std::string& name) const { |
| 435 | std::lock_guard<::fedb::base::SpinMutex> lock(mu_); |