chyezh 1bc3c0b925
enhance: implement balancer at streaming coord (#34435)
issue: #33285

- add balancer implementation
- add channel count fair balance policy
- add channel assignment discover grpc service

Signed-off-by: chyezh <chyezh@outlook.com>
2024-07-11 09:58:48 +08:00

31 lines
996 B
Go

package util
import (
"fmt"
"github.com/milvus-io/milvus/pkg/util/paramtable"
"github.com/milvus-io/milvus/pkg/util/typeutil"
)
// GetAllTopicsFromConfiguration gets all topics from configuration.
// It's a utility function to fetch all topics from configuration.
func GetAllTopicsFromConfiguration() typeutil.Set[string] {
var channels typeutil.Set[string]
if paramtable.Get().CommonCfg.PreCreatedTopicEnabled.GetAsBool() {
channels = typeutil.NewSet[string](paramtable.Get().CommonCfg.TopicNames.GetAsStrings()...)
} else {
channels = genChannelNames(paramtable.Get().CommonCfg.RootCoordDml.GetValue(), paramtable.Get().RootCoordCfg.DmlChannelNum.GetAsInt())
}
return channels
}
// genChannelNames generates channel names with prefix and number.
func genChannelNames(prefix string, num int) typeutil.Set[string] {
results := typeutil.NewSet[string]()
for idx := 0; idx < num; idx++ {
result := fmt.Sprintf("%s_%d", prefix, idx)
results.Insert(result)
}
return results
}