13
13
#include < common/ErrorHandlers.h>
14
14
#include < ext/scope_guard.hpp>
15
15
#include < zkutil/ZooKeeper.h>
16
+ #include < zkutil/ZooKeeperNodeCache.h>
16
17
#include < DB/Common/Macros.h>
17
18
#include < DB/Common/StringUtils.h>
18
19
#include < DB/Common/getFQDNOrHostName.h>
20
+ #include < DB/Common/getMultipleKeysFromConfig.h>
19
21
#include < DB/Databases/DatabaseOrdinary.h>
20
22
#include < DB/IO/HTTPCommon.h>
21
23
#include < DB/Interpreters/AsynchronousMetrics.h>
22
24
#include < DB/Interpreters/ProcessList.h>
23
25
#include < DB/Interpreters/loadMetadata.h>
24
26
#include < DB/Storages/MergeTree/ReshardingWorker.h>
25
27
#include < DB/Storages/StorageReplicatedMergeTree.h>
26
- #include < DB/Storages/System/attach_system_tables .h>
28
+ #include < DB/Storages/System/attachSystemTables .h>
27
29
#include " ConfigReloader.h"
28
30
#include " HTTPHandler.h"
29
31
#include " InterserverIOHTTPHandler.h"
32
34
#include " StatusFile.h"
33
35
#include " TCPHandler.h"
34
36
37
+
35
38
namespace DB
36
39
{
37
40
namespace ErrorCodes
@@ -221,7 +224,7 @@ int Server::main(const std::vector<std::string> & args)
221
224
{
222
225
auto old_configuration = loaded_config.configuration ;
223
226
loaded_config = ConfigProcessor ().loadConfigWithZooKeeperIncludes (
224
- config_path, main_config_zk_node_cache, /* fallback_to_preprocessed = */ true );
227
+ config_path, main_config_zk_node_cache, /* fallback_to_preprocessed = */ true );
225
228
config ().removeConfiguration (old_configuration.get ());
226
229
config ().add (loaded_config.configuration .duplicate (), PRIO_DEFAULT, false );
227
230
}
@@ -321,11 +324,11 @@ int Server::main(const std::vector<std::string> & args)
321
324
322
325
// / Initialize main config reloader.
323
326
std::string include_from_path = config ().getString (" include_from" , " /etc/metrika.xml" );
324
- auto main_config_reloader = std::make_unique<ConfigReloader>(
325
- config_path, include_from_path,
326
- std::move (main_config_zk_node_cache),
327
- [&](ConfigurationPtr config) { global_context->setClustersConfig (config); },
328
- /* already_loaded = */ true );
327
+ auto main_config_reloader = std::make_unique<ConfigReloader>(config_path,
328
+ include_from_path,
329
+ std::move (main_config_zk_node_cache),
330
+ [&](ConfigurationPtr config) { global_context->setClustersConfig (config); },
331
+ /* already_loaded = */ true );
329
332
330
333
// / Initialize users config reloader.
331
334
std::string users_config_path = config ().getString (" users_config" , config_path);
@@ -337,11 +340,11 @@ int Server::main(const std::vector<std::string> & args)
337
340
if (Poco::File (config_dir + users_config_path).exists ())
338
341
users_config_path = config_dir + users_config_path;
339
342
}
340
- auto users_config_reloader = std::make_unique<ConfigReloader>(
341
- users_config_path, include_from_path,
342
- zkutil::ZooKeeperNodeCache ([&] { return global_context->getZooKeeper (); }),
343
- [&](ConfigurationPtr config) { global_context->setUsersConfig (config); },
344
- /* already_loaded = */ false );
343
+ auto users_config_reloader = std::make_unique<ConfigReloader>(users_config_path,
344
+ include_from_path,
345
+ zkutil::ZooKeeperNodeCache ([&] { return global_context->getZooKeeper (); }),
346
+ [&](ConfigurationPtr config) { global_context->setUsersConfig (config); },
347
+ /* already_loaded = */ false );
345
348
346
349
// / Limit on total number of coucurrently executed queries.
347
350
global_context->getProcessList ().setMaxSize (config ().getInt (" max_concurrent_queries" , 0 ));
@@ -385,7 +388,7 @@ int Server::main(const std::vector<std::string> & args)
385
388
386
389
DatabasePtr system_database = global_context->getDatabase (" system" );
387
390
388
- attach_system_tables_server (system_database, global_context.get (), has_zookeeper);
391
+ attachSystemTablesServer (system_database, global_context.get (), has_zookeeper);
389
392
390
393
bool has_resharding_worker = false ;
391
394
if (has_zookeeper && config ().has (" resharding" ))
@@ -425,12 +428,8 @@ int Server::main(const std::vector<std::string> & args)
425
428
std::vector<std::unique_ptr<Poco::Net::TCPServer>> servers;
426
429
427
430
std::vector<std::string> listen_hosts;
428
- Poco::Util::AbstractConfiguration::Keys config_keys;
429
- config ().keys (" " , config_keys);
430
- for (const auto & key : config_keys)
431
+ for (const auto & key : DB::getMultipleKeysFromConfig (config (), " " , " listen_host" ))
431
432
{
432
- if (!startsWith (key.data (), " listen_host" ))
433
- continue ;
434
433
listen_hosts.emplace_back (config ().getString (key));
435
434
}
436
435
@@ -585,10 +584,14 @@ int Server::main(const std::vector<std::string> & args)
585
584
// / This object will periodically calculate some metrics.
586
585
AsynchronousMetrics async_metrics (*global_context);
587
586
588
- attach_system_tables_async (system_database, async_metrics);
587
+ attachSystemTablesAsync (system_database, async_metrics);
588
+
589
+ std::vector<std::unique_ptr<MetricsTransmitter>> metrics_transmitters;
590
+ for (const auto & graphite_key : DB::getMultipleKeysFromConfig (config (), " " , " graphite" ))
591
+ {
592
+ metrics_transmitters.emplace_back (std::make_unique<MetricsTransmitter>(async_metrics, graphite_key));
593
+ }
589
594
590
- const auto metrics_transmitter
591
- = config ().getBool (" use_graphite" , true ) ? std::make_unique<MetricsTransmitter>(async_metrics) : nullptr ;
592
595
593
596
waitForTerminationRequest ();
594
597
}
0 commit comments