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

Method createInterserverServers

programs/server/Server.cpp:3965–4044  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3963}
3964
3965void Server::createInterserverServers(
3966 Poco::Util::AbstractConfiguration & config,
3967 const ServerSettings & server_settings,
3968 const Strings & interserver_listen_hosts,
3969 bool listen_try,
3970 Poco::ThreadPool & server_pool,
3971 AsynchronousMetrics & async_metrics,
3972 std::vector<ProtocolServerAdapter> & servers,
3973 bool start_servers,
3974 const ServerType & server_type)
3975{
3976 const Settings & settings = global_context->getSettingsRef();
3977
3978 Poco::Net::HTTPServerParams::Ptr http_params = new Poco::Net::HTTPServerParams;
3979 http_params->setTimeout(settings[Setting::http_receive_timeout]);
3980 http_params->setKeepAliveTimeout(global_context->getServerSettings()[ServerSetting::keep_alive_timeout]);
3981 http_params->setMaxQueued(server_settings[ServerSetting::listen_backlog]);
3982
3983 /// Now iterate over interserver_listen_hosts
3984 for (const auto & interserver_listen_host : interserver_listen_hosts)
3985 {
3986 const char * port_name = nullptr;
3987
3988 if (server_type.shouldStart(ServerType::Type::INTERSERVER_HTTP))
3989 {
3990 /// Interserver IO HTTP
3991 port_name = "interserver_http_port";
3992 createServer(config, interserver_listen_host, port_name, listen_try, start_servers, servers, [&](UInt16 port) -> ProtocolServerAdapter
3993 {
3994 Poco::Net::ServerSocket socket;
3995 auto address = socketBindListen(server_settings, socket, interserver_listen_host, port);
3996 socket.setReceiveTimeout(settings[Setting::http_receive_timeout]);
3997 socket.setSendTimeout(settings[Setting::http_send_timeout]);
3998 return ProtocolServerAdapter(
3999 interserver_listen_host,
4000 port_name,
4001 "replica communication (interserver): http://" + address.toString(),
4002 std::make_unique<HTTPServer>(
4003 httpContext(),
4004 createHandlerFactory(*this, config, async_metrics, "InterserverIOHTTPHandler-factory"),
4005 server_pool,
4006 socket,
4007 http_params,
4008 nullptr,
4009 ProfileEvents::InterfaceInterserverReceiveBytes,
4010 ProfileEvents::InterfaceInterserverSendBytes));
4011 });
4012 }
4013
4014 if (server_type.shouldStart(ServerType::Type::INTERSERVER_HTTPS))
4015 {
4016 port_name = "interserver_https_port";
4017 createServer(config, interserver_listen_host, port_name, listen_try, start_servers, servers, [&](UInt16 port) -> ProtocolServerAdapter
4018 {
4019#if USE_SSL
4020 Poco::Net::SecureServerSocket socket;
4021 auto address = socketBindListen(server_settings, socket, interserver_listen_host, port, /* secure = */ true);
4022 socket.setReceiveTimeout(settings[Setting::http_receive_timeout]);

Callers

nothing calls this directly

Calls 13

createServerFunction · 0.85
socketBindListenFunction · 0.85
httpContextFunction · 0.85
createHandlerFactoryFunction · 0.85
setMaxQueuedMethod · 0.80
shouldStartMethod · 0.80
ExceptionClass · 0.50
setTimeoutMethod · 0.45
setKeepAliveTimeoutMethod · 0.45
setReceiveTimeoutMethod · 0.45
setSendTimeoutMethod · 0.45

Tested by

no test coverage detected