operator

package
v0.0.0-...-1338f1b Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: Apache-2.0 Imports: 10 Imported by: 5

Documentation

Index

Constants

View Source
const (
	// LeaderOperatorWaitTime is the duration that when a leader operator lives
	// longer than it, the operator will be considered timeout.
	LeaderOperatorWaitTime = 10 * time.Second
	// RegionOperatorWaitTime is the duration that when a region operator lives
	// longer than it, the operator will be considered timeout.
	RegionOperatorWaitTime = 10 * time.Minute
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AddPeer

type AddPeer struct {
	ToStore, PeerID uint64
}

AddPeer is an OpStep that adds a region peer.

func (AddPeer) ConfVerChanged

func (ap AddPeer) ConfVerChanged(region *core.RegionInfo) bool

ConfVerChanged returns true if the conf version has been changed by this step

func (AddPeer) IsFinish

func (ap AddPeer) IsFinish(region *core.RegionInfo) bool

IsFinish checks if current step is finished.

func (AddPeer) String

func (ap AddPeer) String() string

type Cluster

type Cluster interface {
	GetStore(id uint64) *core.StoreInfo
	AllocPeer(storeID uint64) (*metapb.Peer, error)
}

Cluster provides an overview of a cluster's regions distribution.

type OpKind

type OpKind uint32

OpKind is a bit field to identify operator types.

const (
	OpLeader   OpKind = 1 << iota // Include leader transfer.
	OpRegion                      // Include peer movement.
	OpAdmin                       // Initiated by admin.
	OpAdjacent                    // Initiated by adjacent region scheduler.
	OpReplica                     // Initiated by replica checkers.
	OpBalance                     // Initiated by balancers.
	OpMerge                       // Initiated by merge checkers or merge schedulers.
	OpRange                       // Initiated by range scheduler.

)

Flags for operators.

func ParseOperatorKind

func ParseOperatorKind(str string) (OpKind, error)

ParseOperatorKind converts string (flag name list concat by ',') to OpKind.

func (OpKind) String

func (k OpKind) String() string

type OpStep

type OpStep interface {
	fmt.Stringer
	ConfVerChanged(region *core.RegionInfo) bool
	IsFinish(region *core.RegionInfo) bool
}

OpStep describes the basic scheduling steps that can not be subdivided.

func CreateAddPeerSteps

func CreateAddPeerSteps(newStore uint64, peerID uint64) []OpStep

CreateAddPeerSteps creates an OpStep list that add a new peer.

type Operator

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

Operator contains execution steps generated by scheduler.

func CreateAddPeerOperator

func CreateAddPeerOperator(desc string, region *core.RegionInfo, peerID uint64, toStoreID uint64, kind OpKind) *Operator

CreateAddPeerOperator creates an operator that adds a new peer.

func CreateMovePeerOperator

func CreateMovePeerOperator(desc string, cluster Cluster, region *core.RegionInfo, kind OpKind, oldStore, newStore uint64, peerID uint64) (*Operator, error)

CreateMovePeerOperator creates an operator that replaces an old peer with a new peer.

func CreateOfflinePeerOperator

func CreateOfflinePeerOperator(desc string, cluster Cluster, region *core.RegionInfo, kind OpKind, oldStore, newStore uint64, peerID uint64) (*Operator, error)

CreateOfflinePeerOperator creates an operator that replaces an old peer with a new peer when offline a store.

func CreateRemovePeerOperator

func CreateRemovePeerOperator(desc string, cluster Cluster, kind OpKind, region *core.RegionInfo, storeID uint64) (*Operator, error)

CreateRemovePeerOperator creates an operator that removes a peer from region.

func CreateTransferLeaderOperator

func CreateTransferLeaderOperator(desc string, region *core.RegionInfo, sourceStoreID uint64, targetStoreID uint64, kind OpKind) *Operator

CreateTransferLeaderOperator creates an operator that transfers the leader from a source store to a target store.

func NewOperator

func NewOperator(desc, brief string, regionID uint64, regionEpoch *metapb.RegionEpoch, kind OpKind, steps ...OpStep) *Operator

NewOperator creates a new operator.

func (*Operator) AttachKind

func (o *Operator) AttachKind(kind OpKind)

AttachKind attaches an operator kind for the operator.

func (*Operator) Check

func (o *Operator) Check(region *core.RegionInfo) OpStep

Check checks if current step is finished, returns next step to take action. It's safe to be called by multiple goroutine concurrently.

func (*Operator) ConfVerChanged

func (o *Operator) ConfVerChanged(region *core.RegionInfo) int

ConfVerChanged returns the number of confver has consumed by steps

func (*Operator) Desc

func (o *Operator) Desc() string

Desc returns the operator's short description.

func (*Operator) ElapsedTime

func (o *Operator) ElapsedTime() time.Duration

ElapsedTime returns duration since it was created.

func (*Operator) GetPriorityLevel

func (o *Operator) GetPriorityLevel() core.PriorityLevel

GetPriorityLevel gets the priority level.

func (*Operator) GetStartTime

func (o *Operator) GetStartTime() time.Time

GetStartTime ges the start time for operator.

func (*Operator) IsFinish

func (o *Operator) IsFinish() bool

IsFinish checks if all steps are finished.

func (*Operator) IsTimeout

func (o *Operator) IsTimeout() bool

IsTimeout checks the operator's create time and determines if it is timeout.

func (*Operator) Kind

func (o *Operator) Kind() OpKind

Kind returns operator's kind.

func (*Operator) Len

func (o *Operator) Len() int

Len returns the operator's steps count.

func (*Operator) MarshalJSON

func (o *Operator) MarshalJSON() ([]byte, error)

MarshalJSON serializes custom types to JSON.

func (*Operator) RegionEpoch

func (o *Operator) RegionEpoch() *metapb.RegionEpoch

RegionEpoch returns the region's epoch that is attached to the operator.

func (*Operator) RegionID

func (o *Operator) RegionID() uint64

RegionID returns the region that operator is targeted.

func (*Operator) RunningTime

func (o *Operator) RunningTime() time.Duration

RunningTime returns duration since it was promoted.

func (*Operator) SetDesc

func (o *Operator) SetDesc(desc string)

SetDesc sets the description for the operator.

func (*Operator) SetPriorityLevel

func (o *Operator) SetPriorityLevel(level core.PriorityLevel)

SetPriorityLevel sets the priority level for operator.

func (*Operator) SetStartTime

func (o *Operator) SetStartTime(t time.Time)

SetStartTime sets the start time for operator.

func (*Operator) Step

func (o *Operator) Step(i int) OpStep

Step returns the i-th step.

func (*Operator) String

func (o *Operator) String() string

type RemovePeer

type RemovePeer struct {
	FromStore uint64
}

RemovePeer is an OpStep that removes a region peer.

func (RemovePeer) ConfVerChanged

func (rp RemovePeer) ConfVerChanged(region *core.RegionInfo) bool

ConfVerChanged returns true if the conf version has been changed by this step

func (RemovePeer) IsFinish

func (rp RemovePeer) IsFinish(region *core.RegionInfo) bool

IsFinish checks if current step is finished.

func (RemovePeer) String

func (rp RemovePeer) String() string

type TransferLeader

type TransferLeader struct {
	FromStore, ToStore uint64
}

TransferLeader is an OpStep that transfers a region's leader.

func (TransferLeader) ConfVerChanged

func (tl TransferLeader) ConfVerChanged(region *core.RegionInfo) bool

ConfVerChanged returns true if the conf version has been changed by this step

func (TransferLeader) IsFinish

func (tl TransferLeader) IsFinish(region *core.RegionInfo) bool

IsFinish checks if current step is finished.

func (TransferLeader) String

func (tl TransferLeader) String() string

Jump to

Keyboard shortcuts

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