mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-06 19:02:18 +08:00
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>
43 lines
1.1 KiB
Go
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
|
|
}
|