update config structure: remote_servers_discovery -> remote_servers.discovery

This commit is contained in:
vdimir 2021-11-18 12:45:57 +03:00
parent 7404205f37
commit ceec643f90
No known key found for this signature in database
GPG Key ID: 9B404D301C0CC7EB
5 changed files with 33 additions and 9 deletions

View File

@ -327,6 +327,10 @@ void Clusters::updateClusters(const Poco::Util::AbstractConfiguration & new_conf
for (const auto & key : new_config_keys)
{
if (new_config.has(config_prefix + "." + key + ".discovery"))
/// Handled in ClusterDiscovery
continue;
if (key.find('.') != String::npos)
throw Exception("Cluster names with dots are not supported: '" + key + "'", ErrorCodes::SYNTAX_ERROR);
@ -489,10 +493,6 @@ Cluster::Cluster(const Poco::Util::AbstractConfiguration & config,
internal_replication
});
}
else if (startsWith(key, "discovery"))
{
continue;
}
else
throw Exception("Unknown element in config: " + key, ErrorCodes::UNKNOWN_ELEMENT_IN_CONFIG);

View File

@ -103,7 +103,10 @@ ClusterDiscovery::ClusterDiscovery(
for (const auto & key : config_keys)
{
String path = config.getString(config_prefix + "." + key + ".path");
String prefix = config_prefix + "." + key + ".discovery";
if (!config.has(prefix))
continue;
String path = config.getString(prefix + ".path");
trimRight(path, '/');
clusters_info.emplace(key, ClusterInfo(key, path));
}

View File

@ -28,7 +28,7 @@ public:
ClusterDiscovery(
const Poco::Util::AbstractConfiguration & config,
ContextPtr context_,
const String & config_prefix = "remote_servers_discovery"); // TODO(@vdimir) use `remote_servers`
const String & config_prefix = "remote_servers");
void start();

View File

@ -1,7 +1,25 @@
<clickhouse>
<remote_servers_discovery>
<remote_servers>
<test_auto_cluster>
<path>/clickhouse/discovery/test_auto_cluster</path>
<discovery>
<path>/clickhouse/discovery/test_auto_cluster</path>
</discovery>
</test_auto_cluster>
</remote_servers_discovery>
<two_shards>
<!-- just to check that there's no conflict between automatic and manual clusters -->
<shard>
<replica>
<host>node1</host>
<port>9000</port>
</replica>
<replica>
<host>node2</host>
<port>9000</port>
</replica>
</shard>
</two_shards>
</remote_servers>
</clickhouse>

View File

@ -28,6 +28,7 @@ def check_nodes_count_in_cluster(nodes, expected, cluster_name, *, retries=5):
"""
Check nodes count in system.clusters for specified cluster
"""
assert 1 <= retries <= 6
for retry in range(1, retries + 1):
nodes_cnt = [
@ -62,3 +63,5 @@ def test_cluster_discovery_startup_and_stop(start_cluster):
nodes[3].start_clickhouse()
check_nodes_count_in_cluster([nodes[0], nodes[2]], len(nodes), 'test_auto_cluster')
check_nodes_count_in_cluster([nodes[1], nodes[2]], 2, 'two_shards', retries=1)