Rename function parameters, remove unnecessary virtual

This commit is contained in:
TTPO100AJIEX 2024-05-24 15:36:41 +03:00
parent 251010f109
commit aada1de796
5 changed files with 41 additions and 42 deletions

View File

@ -17,8 +17,8 @@ extern const int NETWORK_ERROR;
extern const int INVALID_CONFIG_PARAMETER;
}
IServersManager::IServersManager(ContextMutablePtr l_global_context, Poco::Logger * l_logger)
: global_context(l_global_context), logger(l_logger)
IServersManager::IServersManager(ContextMutablePtr global_context_, Poco::Logger * logger_)
: global_context(global_context_), logger(logger_)
{
}
@ -107,8 +107,8 @@ void IServersManager::createServer(
const Poco::Util::AbstractConfiguration & config,
const std::string & listen_host,
const char * port_name,
CreateServerFunc && func,
bool start_server)
bool start_server,
CreateServerFunc && func)
{
/// For testing purposes, user may omit tcp_port or http_port or https_port in configuration file.
if (config.getString(port_name, "").empty())

View File

@ -19,7 +19,7 @@ namespace DB
class IServersManager
{
public:
IServersManager(ContextMutablePtr global_context, Poco::Logger * logger);
IServersManager(ContextMutablePtr global_context_, Poco::Logger * logger_);
virtual ~IServersManager() = default;
bool empty() const;
@ -35,9 +35,9 @@ public:
const ServerType & server_type)
= 0;
virtual void startServers();
void startServers();
virtual void stopServers(const ServerType & server_type);
void stopServers(const ServerType & server_type);
virtual size_t stopServers(const ServerSettings & server_settings, std::mutex & servers_lock) = 0;
virtual void updateServers(
@ -58,14 +58,14 @@ protected:
const Poco::Util::AbstractConfiguration & config, Poco::Net::ServerSocket & socket, const std::string & host, UInt16 port) const;
using CreateServerFunc = std::function<ProtocolServerAdapter(UInt16)>;
virtual void createServer(
void createServer(
const Poco::Util::AbstractConfiguration & config,
const std::string & listen_host,
const char * port_name,
CreateServerFunc && func,
bool start_server);
bool start_server,
CreateServerFunc && func);
virtual void stopServersForUpdate(const Poco::Util::AbstractConfiguration & config, ConfigurationPtr latest_config);
void stopServersForUpdate(const Poco::Util::AbstractConfiguration & config, ConfigurationPtr latest_config);
Strings getListenHosts(const Poco::Util::AbstractConfiguration & config) const;
bool getListenTry(const Poco::Util::AbstractConfiguration & config) const;

View File

@ -71,6 +71,7 @@ void InterServersManager::createServers(
config,
listen_host,
port_name,
/* start_server = */ false,
[&](UInt16 port) -> ProtocolServerAdapter
{
Poco::Net::ServerSocket socket;
@ -92,14 +93,14 @@ void InterServersManager::createServers(
false),
server_pool,
socket));
},
/* start_server = */ false);
});
constexpr auto secure_port_name = "keeper_server.tcp_port_secure";
createServer(
config,
listen_host,
secure_port_name,
/* start_server = */ false,
[&](UInt16 port) -> ProtocolServerAdapter
{
# if USE_SSL
@ -128,14 +129,14 @@ void InterServersManager::createServers(
ErrorCodes::SUPPORT_IS_DISABLED,
"SSL support for TCP protocol is disabled because Poco library was built without NetSSL support.");
# endif
},
/* start_server: */ false);
});
/// HTTP control endpoints
createServer(
config,
listen_host,
/* port_name = */ "keeper_server.http_control.port",
/* start_server = */ false,
[&](UInt16 port) -> ProtocolServerAdapter
{
auto http_context = std::make_shared<HTTPContext>(global_context);
@ -159,8 +160,7 @@ void InterServersManager::createServers(
server_pool,
socket,
http_params));
},
/* start_server: */ false);
});
}
#else
throw Exception(
@ -264,6 +264,7 @@ void InterServersManager::createInterserverServers(
config,
interserver_listen_host,
port_name,
start_servers,
[&](UInt16 port) -> ProtocolServerAdapter
{
Poco::Net::ServerSocket socket;
@ -282,8 +283,7 @@ void InterServersManager::createInterserverServers(
http_params,
ProfileEvents::InterfaceInterserverReceiveBytes,
ProfileEvents::InterfaceInterserverSendBytes));
},
start_servers);
});
}
if (server_type.shouldStart(ServerType::Type::INTERSERVER_HTTPS))
@ -293,6 +293,7 @@ void InterServersManager::createInterserverServers(
config,
interserver_listen_host,
port_name,
start_servers,
[&](UInt16 port) -> ProtocolServerAdapter
{
#if USE_SSL
@ -318,8 +319,7 @@ void InterServersManager::createInterserverServers(
ErrorCodes::SUPPORT_IS_DISABLED,
"SSL support for TCP protocol is disabled because Poco library was built without NetSSL support.");
#endif
},
start_servers);
});
}
}
}

View File

@ -19,7 +19,6 @@ public:
bool start_servers,
const ServerType & server_type) override;
using IServersManager::stopServers;
size_t stopServers(const ServerSettings & server_settings, std::mutex & servers_lock) override;
void updateServers(

View File

@ -99,6 +99,7 @@ void ProtocolServersManager::createServers(
config,
host,
port_name.c_str(),
start_servers,
[&](UInt16 port) -> ProtocolServerAdapter
{
Poco::Net::ServerSocket socket;
@ -110,8 +111,7 @@ void ProtocolServersManager::createServers(
port_name.c_str(),
description + ": " + address.toString(),
std::make_unique<TCPServer>(stack.release(), server_pool, socket, new Poco::Net::TCPServerParams));
},
start_servers);
});
}
}
@ -125,6 +125,7 @@ void ProtocolServersManager::createServers(
config,
listen_host,
port_name,
start_servers,
[&](UInt16 port) -> ProtocolServerAdapter
{
Poco::Net::ServerSocket socket;
@ -143,8 +144,7 @@ void ProtocolServersManager::createServers(
http_params,
ProfileEvents::InterfaceHTTPReceiveBytes,
ProfileEvents::InterfaceHTTPSendBytes));
},
start_servers);
});
}
if (server_type.shouldStart(ServerType::Type::HTTPS))
@ -155,6 +155,7 @@ void ProtocolServersManager::createServers(
config,
listen_host,
port_name,
start_servers,
[&](UInt16 port) -> ProtocolServerAdapter
{
#if USE_SSL
@ -180,8 +181,7 @@ void ProtocolServersManager::createServers(
ErrorCodes::SUPPORT_IS_DISABLED,
"HTTPS protocol is disabled because Poco library was built without NetSSL support.");
#endif
},
start_servers);
});
}
if (server_type.shouldStart(ServerType::Type::TCP))
@ -192,6 +192,7 @@ void ProtocolServersManager::createServers(
config,
listen_host,
port_name,
start_servers,
[&](UInt16 port) -> ProtocolServerAdapter
{
Poco::Net::ServerSocket socket;
@ -208,8 +209,7 @@ void ProtocolServersManager::createServers(
server_pool,
socket,
new Poco::Net::TCPServerParams));
},
start_servers);
});
}
if (server_type.shouldStart(ServerType::Type::TCP_WITH_PROXY))
@ -220,6 +220,7 @@ void ProtocolServersManager::createServers(
config,
listen_host,
port_name,
start_servers,
[&](UInt16 port) -> ProtocolServerAdapter
{
Poco::Net::ServerSocket socket;
@ -236,8 +237,7 @@ void ProtocolServersManager::createServers(
server_pool,
socket,
new Poco::Net::TCPServerParams));
},
start_servers);
});
}
if (server_type.shouldStart(ServerType::Type::TCP_SECURE))
@ -248,6 +248,7 @@ void ProtocolServersManager::createServers(
config,
listen_host,
port_name,
start_servers,
[&](UInt16 port) -> ProtocolServerAdapter
{
#if USE_SSL
@ -271,8 +272,7 @@ void ProtocolServersManager::createServers(
ErrorCodes::SUPPORT_IS_DISABLED,
"SSL support for TCP protocol is disabled because Poco library was built without NetSSL support.");
#endif
},
start_servers);
});
}
if (server_type.shouldStart(ServerType::Type::MYSQL))
@ -282,6 +282,7 @@ void ProtocolServersManager::createServers(
config,
listen_host,
port_name,
start_servers,
[&](UInt16 port) -> ProtocolServerAdapter
{
Poco::Net::ServerSocket socket;
@ -298,8 +299,7 @@ void ProtocolServersManager::createServers(
server_pool,
socket,
new Poco::Net::TCPServerParams));
},
start_servers);
});
}
if (server_type.shouldStart(ServerType::Type::POSTGRESQL))
@ -309,6 +309,7 @@ void ProtocolServersManager::createServers(
config,
listen_host,
port_name,
start_servers,
[&](UInt16 port) -> ProtocolServerAdapter
{
Poco::Net::ServerSocket socket;
@ -325,8 +326,7 @@ void ProtocolServersManager::createServers(
server_pool,
socket,
new Poco::Net::TCPServerParams));
},
start_servers);
});
}
#if USE_GRPC
@ -337,6 +337,7 @@ void ProtocolServersManager::createServers(
config,
listen_host,
port_name,
start_servers,
[&](UInt16 port) -> ProtocolServerAdapter
{
Poco::Net::SocketAddress server_address(listen_host, port);
@ -345,8 +346,7 @@ void ProtocolServersManager::createServers(
port_name,
"gRPC protocol: " + server_address.toString(),
std::make_unique<GRPCServer>(server, makeSocketAddress(listen_host, port, logger)));
},
start_servers);
});
}
#endif
if (server_type.shouldStart(ServerType::Type::PROMETHEUS))
@ -357,6 +357,7 @@ void ProtocolServersManager::createServers(
config,
listen_host,
port_name,
start_servers,
[&](UInt16 port) -> ProtocolServerAdapter
{
Poco::Net::ServerSocket socket;
@ -375,8 +376,7 @@ void ProtocolServersManager::createServers(
http_params,
ProfileEvents::InterfacePrometheusReceiveBytes,
ProfileEvents::InterfacePrometheusSendBytes));
},
start_servers);
});
}
}
}