| 1678 | } |
| 1679 | |
| 1680 | int NameServerImpl::UpdateTaskStatusRemote(bool is_recover_op) { |
| 1681 | if (mode_.load(std::memory_order_acquire) == kFOLLOWER) { |
| 1682 | return 0; |
| 1683 | } |
| 1684 | std::map<std::string, std::shared_ptr<::fedb::client::NsClient>> client_map; |
| 1685 | { |
| 1686 | std::lock_guard<std::mutex> lock(mu_); |
| 1687 | if (nsc_.empty()) { |
| 1688 | return 0; |
| 1689 | } |
| 1690 | for (auto iter = nsc_.begin(); iter != nsc_.end(); ++iter) { |
| 1691 | if (iter->second->state_.load(std::memory_order_relaxed) != kClusterHealthy) { |
| 1692 | PDLOG(INFO, "cluster[%s] is not Healthy", iter->first.c_str()); |
| 1693 | continue; |
| 1694 | } |
| 1695 | client_map.insert(std::make_pair( |
| 1696 | iter->first, std::atomic_load_explicit(&iter->second->client_, std::memory_order_relaxed))); |
| 1697 | } |
| 1698 | } |
| 1699 | uint64_t last_task_rpc_version = task_rpc_version_.load(std::memory_order_acquire); |
| 1700 | for (auto iter = client_map.begin(); iter != client_map.end(); ++iter) { |
| 1701 | ::fedb::api::TaskStatusResponse response; |
| 1702 | // get task status from replica cluster |
| 1703 | if (iter->second->GetTaskStatus(response)) { |
| 1704 | std::lock_guard<std::mutex> lock(mu_); |
| 1705 | if (last_task_rpc_version != task_rpc_version_.load(std::memory_order_acquire)) { |
| 1706 | DEBUGLOG("task_rpc_version mismatch"); |
| 1707 | break; |
| 1708 | } |
| 1709 | std::string endpoint = iter->first; |
| 1710 | uint32_t index = 0; |
| 1711 | for (const auto& op_list : task_vec_) { |
| 1712 | index++; |
| 1713 | if (index <= FLAGS_name_server_task_max_concurrency) { |
| 1714 | continue; |
| 1715 | } |
| 1716 | std::string endpoint_role = "replica cluster"; |
| 1717 | if (UpdateTask(op_list, endpoint, endpoint_role, is_recover_op, response) < 0) { |
| 1718 | continue; |
| 1719 | } |
| 1720 | } |
| 1721 | } else { |
| 1722 | if (response.has_msg()) { |
| 1723 | PDLOG(WARNING, "get task status faild : [%s]", response.msg().c_str()); |
| 1724 | } |
| 1725 | } |
| 1726 | } |
| 1727 | return 0; |
| 1728 | } |
| 1729 | |
| 1730 | int NameServerImpl::UpdateTask(const std::list<std::shared_ptr<OPData>>& op_list, const std::string& endpoint, |
| 1731 | const std::string& msg, bool is_recover_op, ::fedb::api::TaskStatusResponse& response) { |
nothing calls this directly
no test coverage detected