MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / updateServers

Method updateServers

programs/server/Server.cpp:4053–4161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4051}
4052
4053void Server::updateServers(
4054 Poco::Util::AbstractConfiguration & config,
4055 const ServerSettings & server_settings,
4056 Poco::ThreadPool & server_pool,
4057 AsynchronousMetrics & async_metrics,
4058 std::vector<ProtocolServerAdapter> & servers,
4059 std::vector<ProtocolServerAdapter> & servers_to_start_before_tables)
4060{
4061 LoggerRawPtr log = &logger();
4062
4063 const auto listen_hosts = getListenHosts(config);
4064 const auto interserver_listen_hosts = getInterserverListenHosts(config);
4065 const auto listen_try = getListenTry(config, server_settings);
4066
4067 /// Remove servers once all their connections are closed
4068 auto check_server = [&log](const char prefix[], auto & server)
4069 {
4070 if (!server.isStopping())
4071 return false;
4072 size_t current_connections = server.currentConnections();
4073 LOG_DEBUG(log, "Server {}{}: {} ({} connections)",
4074 server.getDescription(),
4075 prefix,
4076 !current_connections ? "finished" : "waiting",
4077 current_connections);
4078 return !current_connections;
4079 };
4080
4081 std::erase_if(servers, std::bind_front(check_server, " (from one of previous reload)"));
4082
4083 Poco::Util::AbstractConfiguration & previous_config = latest_config ? *latest_config : config;
4084
4085 std::vector<ProtocolServerAdapter *> all_servers;
4086 all_servers.reserve(servers.size() + servers_to_start_before_tables.size());
4087 for (auto & server : servers)
4088 all_servers.push_back(&server);
4089
4090 for (auto & server : servers_to_start_before_tables)
4091 all_servers.push_back(&server);
4092
4093 for (auto * server : all_servers)
4094 {
4095 if (server->supportsRuntimeReconfiguration() && !server->isStopping())
4096 {
4097 std::string port_name = server->getPortName();
4098 bool has_host = false;
4099 bool is_http = false;
4100 String handlers_key = "http_handlers";
4101 if (port_name.starts_with("protocols."))
4102 {
4103 std::string protocol = port_name.substr(0, port_name.find_last_of('.'));
4104 has_host = config.has(protocol + ".host");
4105
4106 std::string conf_name = protocol;
4107 std::string prefix = protocol + ".";
4108 std::unordered_set<std::string> pset {conf_name};
4109 while (true)
4110 {

Callers

nothing calls this directly

Calls 15

loggerFunction · 0.85
getListenHostsFunction · 0.85
getListenTryFunction · 0.85
erase_ifFunction · 0.85
isSameConfigurationFunction · 0.85
ExceptionClass · 0.50
findFunction · 0.50
isStoppingMethod · 0.45
currentConnectionsMethod · 0.45
getDescriptionMethod · 0.45

Tested by

no test coverage detected