Zhen Ye 07fa2cbdd3
enhance: wal balance consider the wal status on streamingnode (#43265)
issue: #42995

- don't balance the wal if the producing-consuming lag is too long.
- don't balance if the rebalance is set as false.
- don't balance if the wal is balanced recently.

Signed-off-by: chyezh <chyezh@outlook.com>
2025-07-18 11:10:51 +08:00

43 lines
1.1 KiB
Go

package channel
import (
"fmt"
"time"
"github.com/milvus-io/milvus/pkg/v2/streaming/util/types"
)
// ChannelID is the unique id of a channel.
type ChannelID = types.ChannelID
// newPChannelView creates a new pchannel view.
func newPChannelView(metas map[ChannelID]*PChannelMeta) *PChannelView {
view := &PChannelView{
Channels: make(map[ChannelID]*PChannelMeta, len(metas)),
Stats: make(map[ChannelID]PChannelStatsView, len(metas)),
}
for _, meta := range metas {
id := meta.ChannelInfo().ChannelID()
if _, ok := view.Channels[id]; ok {
panic(fmt.Sprintf("duplicate rw channel: %s", id.String()))
}
view.Channels[id] = meta
stat := StaticPChannelStatsManager.MustGet().GetPChannelStats(id).View()
stat.LastAssignTimestamp = meta.LastAssignTimestamp()
view.Stats[id] = stat
}
return view
}
// PChannelView is the view of current pchannels.
type PChannelView struct {
Channels map[ChannelID]*PChannelMeta
Stats map[ChannelID]PChannelStatsView
}
// PChannelStatsView is the view of the pchannel stats.
type PChannelStatsView struct {
LastAssignTimestamp time.Time
VChannels map[string]int64
}