From b069085bb9b27f875cc603509038e78688134a69 Mon Sep 17 00:00:00 2001 From: Tanner Bruce Date: Wed, 13 Dec 2023 15:50:19 -0600 Subject: [PATCH] clustergen: add all-clusters cluster --- pkg/model/chi/ch_config_generator.go | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/pkg/model/chi/ch_config_generator.go b/pkg/model/chi/ch_config_generator.go index 99aa86d53..aa2c06ad1 100644 --- a/pkg/model/chi/ch_config_generator.go +++ b/pkg/model/chi/ch_config_generator.go @@ -33,6 +33,7 @@ const ( // 2. Cluster with all shards (1 replica). Used to gather/scatter data over all replicas. OneShardAllReplicasClusterName = "all-replicated" AllShardsOneReplicaClusterName = "all-sharded" + AllClustersClusterName = "all-clusters" ) // ClickHouseConfigGenerator generates ClickHouse configuration files content for specified CHI @@ -438,6 +439,35 @@ func (c *ClickHouseConfigGenerator) GetRemoteServers(options *RemoteServersGener }) // util.Iline(b, 8, "", clusterName) + + // All shards from all clusters + util.Iline(b, 8, "<%s>", AllClustersClusterName) + + c.chi.WalkClusters(func(cluster *api.Cluster) error { + cluster.WalkShards(func(index int, shard *api.ChiShard) error { + if c.ShardHostsNum(shard, options) < 1 { + // Skip empty shard + return nil + } + util.Iline(b, 12, "") + util.Iline(b, 12, " %s", shard.InternalReplication) + + shard.WalkHosts(func(host *api.ChiHost) error { + if options.Include(host) { + c.getRemoteServersReplica(host, b) + } + return nil + }) + util.Iline(b, 12, "") + + return nil + }) + + return nil + }) + + // + util.Iline(b, 8, "", clusterName) } //