Skip to content

Commit

Permalink
clustergen: add all-clusters cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
tanner-bruce committed May 6, 2024
1 parent 078df79 commit b069085
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions pkg/model/chi/ch_config_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -438,6 +439,35 @@ func (c *ClickHouseConfigGenerator) GetRemoteServers(options *RemoteServersGener
})
// </my_cluster_name>
util.Iline(b, 8, "</%s>", 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, "<shard>")
util.Iline(b, 12, " <internal_replication>%s</internal_replication>", shard.InternalReplication)

shard.WalkHosts(func(host *api.ChiHost) error {
if options.Include(host) {
c.getRemoteServersReplica(host, b)
}
return nil
})
util.Iline(b, 12, "</shard>")

return nil
})

return nil
})

// </my_cluster_name>
util.Iline(b, 8, "</%s>", clusterName)
}

// </remote_servers>
Expand Down

0 comments on commit b069085

Please sign in to comment.