MCPcopy Create free account
hub / github.com/ByConity/ByConity / fetchServerStartTimes

Function fetchServerStartTimes

src/DaemonManager/DaemonJobServerBGThread.cpp:196–236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

194}
195
196std::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
238std::vector<String> DaemonJobServerBGThread::updateServerStartTimeAndFindRestartServers(const std::map<String, UInt64> & new_server_start_time)
239{

Callers 1

executeImplMethod · 0.85

Calls 9

getCurrentTopologyMethod · 0.80
emptyMethod · 0.45
getServerListMethod · 0.45
getRPCAddressMethod · 0.45
getMethod · 0.45
getServerStartTimeMethod · 0.45
insertMethod · 0.45
sizeMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected