Merge pull request #71058 from ClickHouse/sync-code

Sync changes to `ProtocolServerAdapter`
This commit is contained in:
Antonio Andelic 2024-10-28 08:12:50 +00:00 committed by GitHub
commit 04903c18a0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 22 additions and 5 deletions

View File

@ -3023,7 +3023,7 @@ void Server::updateServers(
for (auto * server : all_servers)
{
if (!server->isStopping())
if (server->supportsRuntimeReconfiguration() && !server->isStopping())
{
std::string port_name = server->getPortName();
bool has_host = false;

View File

@ -30,11 +30,13 @@ ProtocolServerAdapter::ProtocolServerAdapter(
const std::string & listen_host_,
const char * port_name_,
const std::string & description_,
std::unique_ptr<TCPServer> tcp_server_)
std::unique_ptr<TCPServer> tcp_server_,
bool supports_runtime_reconfiguration_)
: listen_host(listen_host_)
, port_name(port_name_)
, description(description_)
, impl(std::make_unique<TCPServerAdapterImpl>(std::move(tcp_server_)))
, supports_runtime_reconfiguration(supports_runtime_reconfiguration_)
{
}
@ -66,11 +68,13 @@ ProtocolServerAdapter::ProtocolServerAdapter(
const std::string & listen_host_,
const char * port_name_,
const std::string & description_,
std::unique_ptr<GRPCServer> grpc_server_)
std::unique_ptr<GRPCServer> grpc_server_,
bool supports_runtime_reconfiguration_)
: listen_host(listen_host_)
, port_name(port_name_)
, description(description_)
, impl(std::make_unique<GRPCServerAdapterImpl>(std::move(grpc_server_)))
, supports_runtime_reconfiguration(supports_runtime_reconfiguration_)
{
}
#endif

View File

@ -21,10 +21,20 @@ class ProtocolServerAdapter
public:
ProtocolServerAdapter(ProtocolServerAdapter && src) = default;
ProtocolServerAdapter & operator =(ProtocolServerAdapter && src) = default;
ProtocolServerAdapter(const std::string & listen_host_, const char * port_name_, const std::string & description_, std::unique_ptr<TCPServer> tcp_server_);
ProtocolServerAdapter(
const std::string & listen_host_,
const char * port_name_,
const std::string & description_,
std::unique_ptr<TCPServer> tcp_server_,
bool supports_runtime_reconfiguration_ = true);
#if USE_GRPC
ProtocolServerAdapter(const std::string & listen_host_, const char * port_name_, const std::string & description_, std::unique_ptr<GRPCServer> grpc_server_);
ProtocolServerAdapter(
const std::string & listen_host_,
const char * port_name_,
const std::string & description_,
std::unique_ptr<GRPCServer> grpc_server_,
bool supports_runtime_reconfiguration_ = true);
#endif
/// Starts the server. A new thread will be created that waits for and accepts incoming connections.
@ -46,6 +56,8 @@ public:
/// Returns the port this server is listening to.
UInt16 portNumber() const { return impl->portNumber(); }
bool supportsRuntimeReconfiguration() const { return supports_runtime_reconfiguration; }
const std::string & getListenHost() const { return listen_host; }
const std::string & getPortName() const { return port_name; }
@ -72,6 +84,7 @@ private:
std::string port_name;
std::string description;
std::unique_ptr<Impl> impl;
bool supports_runtime_reconfiguration = true;
};
}