Skip to content

Commit

Permalink
support fetch server info without starting Proxy (#7577)
Browse files Browse the repository at this point in the history
close #7436
  • Loading branch information
guo-shaoge authored Jun 1, 2023
1 parent c65dd72 commit 23a596b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
28 changes: 9 additions & 19 deletions dbms/src/Server/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1022,25 +1022,15 @@ int Server::main(const std::vector<std::string> & /*args*/)
});

/// get CPU/memory/disk info of this server
if (tiflash_instance_wrap.proxy_helper)
{
diagnosticspb::ServerInfoRequest request;
request.set_tp(static_cast<diagnosticspb::ServerInfoType>(1));
diagnosticspb::ServerInfoResponse response;
std::string req = request.SerializeAsString();
auto * helper = tiflash_instance_wrap.proxy_helper;
helper->fn_server_info(helper->proxy_ptr, strIntoView(&req), &response);
server_info.parseSysInfo(response);
setNumberOfLogicalCPUCores(server_info.cpu_info.logical_cores);
computeAndSetNumberOfPhysicalCPUCores(server_info.cpu_info.logical_cores, server_info.cpu_info.physical_cores);
LOG_INFO(log, "ServerInfo: {}", server_info.debugString());
}
else
{
setNumberOfLogicalCPUCores(std::thread::hardware_concurrency());
computeAndSetNumberOfPhysicalCPUCores(std::thread::hardware_concurrency(), std::thread::hardware_concurrency() / 2);
LOG_INFO(log, "TiFlashRaftProxyHelper is null, failed to get server info");
}
diagnosticspb::ServerInfoRequest request;
diagnosticspb::ServerInfoResponse response;
request.set_tp(static_cast<diagnosticspb::ServerInfoType>(1));
std::string req = request.SerializeAsString();
ffi_get_server_info_from_proxy(reinterpret_cast<intptr_t>(&helper), strIntoView(&req), &response);
server_info.parseSysInfo(response);
setNumberOfLogicalCPUCores(server_info.cpu_info.logical_cores);
computeAndSetNumberOfPhysicalCPUCores(server_info.cpu_info.logical_cores, server_info.cpu_info.physical_cores);
LOG_INFO(log, "ServerInfo: {}", server_info.debugString());

grpc_log = Logger::get("grpc");
gpr_set_log_verbosity(GPR_LOG_SEVERITY_DEBUG);
Expand Down

0 comments on commit 23a596b

Please sign in to comment.