balance

package
v0.10.3-0...-bec5499 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PlanInfoPrefix = "Balance-Plans:"
	DistInfoPrefix = "Balance-Dists:"
)

Variables

This section is empty.

Functions

func CreateChannelTasksFromPlans

func CreateChannelTasksFromPlans(ctx context.Context, source task.Source, timeout time.Duration, plans []ChannelAssignPlan) []task.Task

func CreateSegmentTasksFromPlans

func CreateSegmentTasksFromPlans(ctx context.Context, source task.Source, timeout time.Duration, plans []SegmentAssignPlan) []task.Task

func NewBalanceReport

func NewBalanceReport() *balanceReport

NewBalanceReport returns an initialized BalanceReport instance

func PrintCurrentReplicaDist

func PrintCurrentReplicaDist(replica *meta.Replica,
	stoppingNodesSegments map[int64][]*meta.Segment, nodeSegments map[int64][]*meta.Segment,
	channelManager *meta.ChannelDistManager, segmentDistMgr *meta.SegmentDistManager,
)

func PrintNewBalancePlans

func PrintNewBalancePlans(collectionID int64, replicaID int64, segmentPlans []SegmentAssignPlan,
	channelPlans []ChannelAssignPlan,
)

func StrRecord

func StrRecord(str string) strRecord

func StrRecordf

func StrRecordf(format string, values ...any) strRecordf

Types

type Balance

type Balance interface {
	AssignSegment(ctx context.Context, collectionID int64, segments []*meta.Segment, nodes []int64, manualBalance bool) []SegmentAssignPlan
	AssignChannel(ctx context.Context, channels []*meta.DmChannel, nodes []int64, manualBalance bool) []ChannelAssignPlan
	BalanceReplica(ctx context.Context, replica *meta.Replica) ([]SegmentAssignPlan, []ChannelAssignPlan)
}

type ChannelAssignPlan

type ChannelAssignPlan struct {
	Channel *meta.DmChannel
	Replica *meta.Replica
	From    int64
	To      int64
}

func (*ChannelAssignPlan) String

func (chanPlan *ChannelAssignPlan) String() string

type ChannelLevelScoreBalancer

type ChannelLevelScoreBalancer struct {
	*ScoreBasedBalancer
}

score based segment use (collection_row_count + global_row_count * factor) as node' score and try to make each node has almost same score through balance segment.

func NewChannelLevelScoreBalancer

func NewChannelLevelScoreBalancer(scheduler task.Scheduler,
	nodeManager *session.NodeManager,
	dist *meta.DistributionManager,
	meta *meta.Meta,
	targetMgr meta.TargetManagerInterface,
) *ChannelLevelScoreBalancer

func (*ChannelLevelScoreBalancer) BalanceReplica

func (b *ChannelLevelScoreBalancer) BalanceReplica(ctx context.Context, replica *meta.Replica) (segmentPlans []SegmentAssignPlan, channelPlans []ChannelAssignPlan)

type MockBalancer

type MockBalancer struct {
	mock.Mock
}

MockBalancer is an autogenerated mock type for the Balance type

func NewMockBalancer

func NewMockBalancer(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockBalancer

NewMockBalancer creates a new instance of MockBalancer. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockBalancer) AssignChannel

func (_m *MockBalancer) AssignChannel(ctx context.Context, channels []*meta.DmChannel, nodes []int64, manualBalance bool) []ChannelAssignPlan

AssignChannel provides a mock function with given fields: ctx, channels, nodes, manualBalance

func (*MockBalancer) AssignSegment

func (_m *MockBalancer) AssignSegment(ctx context.Context, collectionID int64, segments []*meta.Segment, nodes []int64, manualBalance bool) []SegmentAssignPlan

AssignSegment provides a mock function with given fields: ctx, collectionID, segments, nodes, manualBalance

func (*MockBalancer) BalanceReplica

func (_m *MockBalancer) BalanceReplica(ctx context.Context, replica *meta.Replica) ([]SegmentAssignPlan, []ChannelAssignPlan)

BalanceReplica provides a mock function with given fields: ctx, replica

func (*MockBalancer) EXPECT

func (_m *MockBalancer) EXPECT() *MockBalancer_Expecter

type MockBalancer_AssignChannel_Call

type MockBalancer_AssignChannel_Call struct {
	*mock.Call
}

MockBalancer_AssignChannel_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AssignChannel'

func (*MockBalancer_AssignChannel_Call) Return

func (*MockBalancer_AssignChannel_Call) Run

func (_c *MockBalancer_AssignChannel_Call) Run(run func(ctx context.Context, channels []*meta.DmChannel, nodes []int64, manualBalance bool)) *MockBalancer_AssignChannel_Call

func (*MockBalancer_AssignChannel_Call) RunAndReturn

type MockBalancer_AssignSegment_Call

type MockBalancer_AssignSegment_Call struct {
	*mock.Call
}

MockBalancer_AssignSegment_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AssignSegment'

func (*MockBalancer_AssignSegment_Call) Return

func (*MockBalancer_AssignSegment_Call) Run

func (_c *MockBalancer_AssignSegment_Call) Run(run func(ctx context.Context, collectionID int64, segments []*meta.Segment, nodes []int64, manualBalance bool)) *MockBalancer_AssignSegment_Call

func (*MockBalancer_AssignSegment_Call) RunAndReturn

type MockBalancer_BalanceReplica_Call

type MockBalancer_BalanceReplica_Call struct {
	*mock.Call
}

MockBalancer_BalanceReplica_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'BalanceReplica'

func (*MockBalancer_BalanceReplica_Call) Return

func (*MockBalancer_BalanceReplica_Call) Run

func (*MockBalancer_BalanceReplica_Call) RunAndReturn

type MockBalancer_Expecter

type MockBalancer_Expecter struct {
	// contains filtered or unexported fields
}

func (*MockBalancer_Expecter) AssignChannel

func (_e *MockBalancer_Expecter) AssignChannel(ctx interface{}, channels interface{}, nodes interface{}, manualBalance interface{}) *MockBalancer_AssignChannel_Call

AssignChannel is a helper method to define mock.On call

  • ctx context.Context
  • channels []*meta.DmChannel
  • nodes []int64
  • manualBalance bool

func (*MockBalancer_Expecter) AssignSegment

func (_e *MockBalancer_Expecter) AssignSegment(ctx interface{}, collectionID interface{}, segments interface{}, nodes interface{}, manualBalance interface{}) *MockBalancer_AssignSegment_Call

AssignSegment is a helper method to define mock.On call

  • ctx context.Context
  • collectionID int64
  • segments []*meta.Segment
  • nodes []int64
  • manualBalance bool

func (*MockBalancer_Expecter) BalanceReplica

func (_e *MockBalancer_Expecter) BalanceReplica(ctx interface{}, replica interface{}) *MockBalancer_BalanceReplica_Call

BalanceReplica is a helper method to define mock.On call

  • ctx context.Context
  • replica *meta.Replica

type MultiTargetBalancer

type MultiTargetBalancer struct {
	*ScoreBasedBalancer
	// contains filtered or unexported fields
}

func NewMultiTargetBalancer

func NewMultiTargetBalancer(scheduler task.Scheduler, nodeManager *session.NodeManager, dist *meta.DistributionManager, meta *meta.Meta, targetMgr meta.TargetManagerInterface) *MultiTargetBalancer

func (*MultiTargetBalancer) BalanceReplica

func (b *MultiTargetBalancer) BalanceReplica(ctx context.Context, replica *meta.Replica) (segmentPlans []SegmentAssignPlan, channelPlans []ChannelAssignPlan)

type RoundRobinBalancer

type RoundRobinBalancer struct {
	// contains filtered or unexported fields
}

func NewRoundRobinBalancer

func NewRoundRobinBalancer(scheduler task.Scheduler, nodeManager *session.NodeManager) *RoundRobinBalancer

func (*RoundRobinBalancer) AssignChannel

func (b *RoundRobinBalancer) AssignChannel(ctx context.Context, channels []*meta.DmChannel, nodes []int64, manualBalance bool) []ChannelAssignPlan

func (*RoundRobinBalancer) AssignSegment

func (b *RoundRobinBalancer) AssignSegment(ctx context.Context, collectionID int64, segments []*meta.Segment, nodes []int64, manualBalance bool) []SegmentAssignPlan

func (*RoundRobinBalancer) BalanceReplica

func (b *RoundRobinBalancer) BalanceReplica(ctx context.Context, replica *meta.Replica) ([]SegmentAssignPlan, []ChannelAssignPlan)

type RowCountBasedBalancer

type RowCountBasedBalancer struct {
	*RoundRobinBalancer
	// contains filtered or unexported fields
}

func NewRowCountBasedBalancer

func NewRowCountBasedBalancer(
	scheduler task.Scheduler,
	nodeManager *session.NodeManager,
	dist *meta.DistributionManager,
	meta *meta.Meta,
	targetMgr meta.TargetManagerInterface,
) *RowCountBasedBalancer

func (*RowCountBasedBalancer) AssignChannel

func (b *RowCountBasedBalancer) AssignChannel(ctx context.Context, channels []*meta.DmChannel, nodes []int64, manualBalance bool) []ChannelAssignPlan

AssignSegment, when row count based balancer assign segments, it will assign channel to node with least global channel count. try to make every query node has channel count

func (*RowCountBasedBalancer) AssignSegment

func (b *RowCountBasedBalancer) AssignSegment(ctx context.Context, collectionID int64, segments []*meta.Segment, nodes []int64, manualBalance bool) []SegmentAssignPlan

AssignSegment, when row count based balancer assign segments, it will assign segment to node with least global row count. try to make every query node has same row count.

func (*RowCountBasedBalancer) BalanceReplica

func (b *RowCountBasedBalancer) BalanceReplica(ctx context.Context, replica *meta.Replica) (segmentPlans []SegmentAssignPlan, channelPlans []ChannelAssignPlan)

type ScoreBasedBalancer

type ScoreBasedBalancer struct {
	*RowCountBasedBalancer
}

score based segment use (collection_row_count + global_row_count * factor) as node' score and try to make each node has almost same score through balance segment.

func NewScoreBasedBalancer

func NewScoreBasedBalancer(scheduler task.Scheduler,
	nodeManager *session.NodeManager,
	dist *meta.DistributionManager,
	meta *meta.Meta,
	targetMgr meta.TargetManagerInterface,
) *ScoreBasedBalancer

func (*ScoreBasedBalancer) AssignSegment

func (b *ScoreBasedBalancer) AssignSegment(ctx context.Context, collectionID int64, segments []*meta.Segment, nodes []int64, manualBalance bool) []SegmentAssignPlan

AssignSegment got a segment list, and try to assign each segment to node's with lowest score

func (*ScoreBasedBalancer) BalanceReplica

func (b *ScoreBasedBalancer) BalanceReplica(ctx context.Context, replica *meta.Replica) (segmentPlans []SegmentAssignPlan, channelPlans []ChannelAssignPlan)

type SegmentAssignPlan

type SegmentAssignPlan struct {
	Segment      *meta.Segment
	Replica      *meta.Replica
	From         int64 // -1 if empty
	To           int64
	FromScore    int64
	ToScore      int64
	SegmentScore int64
}

func (*SegmentAssignPlan) String

func (segPlan *SegmentAssignPlan) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL