cluster discovery init only with zookeeper

This commit is contained in:
vdimir 2021-11-16 16:01:57 +03:00
parent 4816d1afcc
commit e7d3dbeebd
No known key found for this signature in database
GPG Key ID: 9B404D301C0CC7EB
4 changed files with 7 additions and 6 deletions

View File

@ -46,7 +46,7 @@ void ClusterCopier::init()
reloadTaskDescription(); reloadTaskDescription();
task_cluster->loadTasks(*task_cluster_current_config); task_cluster->loadTasks(*task_cluster_current_config);
getContext()->setClustersConfig(task_cluster_current_config, task_cluster->clusters_prefix); getContext()->setClustersConfig(task_cluster_current_config, false, task_cluster->clusters_prefix);
/// Set up shards and their priority /// Set up shards and their priority
task_cluster->random_engine.seed(task_cluster->random_device()); task_cluster->random_engine.seed(task_cluster->random_device());

View File

@ -841,7 +841,7 @@ if (ThreadFuzzer::instance().isEffective())
// in a lot of places. For now, disable updating log configuration without server restart. // in a lot of places. For now, disable updating log configuration without server restart.
//setTextLog(global_context->getTextLog()); //setTextLog(global_context->getTextLog());
updateLevels(*config, logger()); updateLevels(*config, logger());
global_context->setClustersConfig(config); global_context->setClustersConfig(config, has_zookeeper);
global_context->setMacros(std::make_unique<Macros>(*config, "macros", log)); global_context->setMacros(std::make_unique<Macros>(*config, "macros", log));
global_context->setExternalAuthenticatorsConfig(*config); global_context->setExternalAuthenticatorsConfig(*config);
@ -1555,6 +1555,7 @@ if (ThreadFuzzer::instance().isEffective())
server.start(); server.start();
LOG_INFO(log, "Ready for connections."); LOG_INFO(log, "Ready for connections.");
if (has_zookeeper)
global_context->registerNodeForClusterDiscovery(); global_context->registerNodeForClusterDiscovery();
SCOPE_EXIT_SAFE({ SCOPE_EXIT_SAFE({

View File

@ -2206,11 +2206,11 @@ void Context::registerNodeForClusterDiscovery()
/// On repeating calls updates existing clusters and adds new clusters, doesn't delete old clusters /// On repeating calls updates existing clusters and adds new clusters, doesn't delete old clusters
void Context::setClustersConfig(const ConfigurationPtr & config, const String & config_name) void Context::setClustersConfig(const ConfigurationPtr & config, bool enable_discovery, const String & config_name)
{ {
std::lock_guard lock(shared->clusters_mutex); std::lock_guard lock(shared->clusters_mutex);
if (!shared->cluster_discovery) if (enable_discovery && !shared->cluster_discovery)
{ {
shared->cluster_discovery = std::make_unique<ClusterDiscovery>(*config, shared_from_this()); shared->cluster_discovery = std::make_unique<ClusterDiscovery>(*config, shared_from_this());
} }

View File

@ -750,7 +750,7 @@ public:
std::shared_ptr<Clusters> getClusters() const; std::shared_ptr<Clusters> getClusters() const;
std::shared_ptr<Cluster> getCluster(const std::string & cluster_name) const; std::shared_ptr<Cluster> getCluster(const std::string & cluster_name) const;
std::shared_ptr<Cluster> tryGetCluster(const std::string & cluster_name) const; std::shared_ptr<Cluster> tryGetCluster(const std::string & cluster_name) const;
void setClustersConfig(const ConfigurationPtr & config, const String & config_name = "remote_servers"); void setClustersConfig(const ConfigurationPtr & config, bool enable_discovery = false, const String & config_name = "remote_servers");
void registerNodeForClusterDiscovery(); void registerNodeForClusterDiscovery();