| 6355 | } |
| 6356 | |
| 6357 | int NameServerImpl::GetLeader(std::shared_ptr<::fedb::nameserver::TableInfo> table_info, uint32_t pid, |
| 6358 | std::string& leader_endpoint) { |
| 6359 | for (int idx = 0; idx < table_info->table_partition_size(); idx++) { |
| 6360 | if (table_info->table_partition(idx).pid() != pid) { |
| 6361 | continue; |
| 6362 | } |
| 6363 | for (int meta_idx = 0; meta_idx < table_info->table_partition(idx).partition_meta_size(); meta_idx++) { |
| 6364 | if (table_info->table_partition(idx).partition_meta(meta_idx).is_leader() && |
| 6365 | table_info->table_partition(idx).partition_meta(meta_idx).is_alive()) { |
| 6366 | leader_endpoint = table_info->table_partition(idx).partition_meta(meta_idx).endpoint(); |
| 6367 | return 0; |
| 6368 | } |
| 6369 | } |
| 6370 | break; |
| 6371 | } |
| 6372 | return -1; |
| 6373 | } |
| 6374 | |
| 6375 | int NameServerImpl::CreateReAddReplicaSimplifyOP(const std::string& name, const std::string& db, uint32_t pid, |
| 6376 | const std::string& endpoint, uint64_t offset_delta, uint64_t parent_id, |