balance

package
v0.0.0-...-34e0b2d Latest Latest
Warning

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

Go to latest
Published: Aug 9, 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 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,
)

Types

type Balance

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

type ChannelAssignPlan

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

func (*ChannelAssignPlan) ToString

func (chanPlan *ChannelAssignPlan) ToString() 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(replica *meta.Replica) ([]SegmentAssignPlan, []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(channels []*meta.DmChannel, nodes []int64, manualBalance bool) []ChannelAssignPlan

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

func (*MockBalancer) AssignSegment

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

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

func (*MockBalancer) BalanceReplica

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

BalanceReplica provides a mock function with given fields: 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(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(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(channels interface{}, nodes interface{}, manualBalance interface{}) *MockBalancer_AssignChannel_Call

AssignChannel is a helper method to define mock.On call

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

func (*MockBalancer_Expecter) AssignSegment

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

AssignSegment is a helper method to define mock.On call

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

func (*MockBalancer_Expecter) BalanceReplica

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

BalanceReplica is a helper method to define mock.On call

  • 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(replica *meta.Replica) ([]SegmentAssignPlan, []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(channels []*meta.DmChannel, nodes []int64, manualBalance bool) []ChannelAssignPlan

func (*RoundRobinBalancer) AssignSegment

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

func (*RoundRobinBalancer) BalanceReplica

func (b *RoundRobinBalancer) BalanceReplica(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(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(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(replica *meta.Replica) ([]SegmentAssignPlan, []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(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(replica *meta.Replica) ([]SegmentAssignPlan, []ChannelAssignPlan)

type SegmentAssignPlan

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

func (*SegmentAssignPlan) ToString

func (segPlan *SegmentAssignPlan) ToString() string

Jump to

Keyboard shortcuts

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