| 194 | } |
| 195 | |
| 196 | std::map<String, UInt64> fetchServerStartTimes(Context & context, CnchTopologyMaster & topology_master, Poco::Logger * log) |
| 197 | { |
| 198 | std::map<String, UInt64> ret; |
| 199 | std::list<CnchServerTopology> server_topologies = topology_master.getCurrentTopology(); |
| 200 | if (server_topologies.empty()) |
| 201 | { |
| 202 | LOG_ERROR(log, "Server topology is empty, something wrong with topology, this iteration will be skip!"); |
| 203 | return ret; |
| 204 | } |
| 205 | |
| 206 | HostWithPortsVec host_ports = server_topologies.back().getServerList(); |
| 207 | |
| 208 | for (const auto & host_port : host_ports) |
| 209 | { |
| 210 | String rpc_address = host_port.getRPCAddress(); |
| 211 | CnchServerClientPtr client_ptr = context.getCnchServerClientPool().get(host_port); |
| 212 | if (!client_ptr) |
| 213 | { |
| 214 | LOG_WARNING(log, "Not able to connect to server with rpc address {}", rpc_address); |
| 215 | continue; |
| 216 | } |
| 217 | |
| 218 | try |
| 219 | { |
| 220 | UInt64 ts = client_ptr->getServerStartTime(); |
| 221 | ret.insert(std::make_pair(rpc_address, ts)); |
| 222 | } |
| 223 | catch (...) |
| 224 | { |
| 225 | LOG_INFO(log, "Failed to reach server with rpc address: {}", rpc_address); |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | if (ret.size() != host_ports.size()) |
| 230 | { |
| 231 | LOG_WARNING(log, "There is network partition, return empty result to skip this iteration"); |
| 232 | ret.clear(); |
| 233 | } |
| 234 | |
| 235 | return ret; |
| 236 | } |
| 237 | |
| 238 | std::vector<String> DaemonJobServerBGThread::updateServerStartTimeAndFindRestartServers(const std::map<String, UInt64> & new_server_start_time) |
| 239 | { |
no test coverage detected