Documentation ¶
Index ¶
- Constants
- type AddPeer
- type Cluster
- type OpKind
- type OpStep
- type Operator
- func CreateAddPeerOperator(desc string, region *core.RegionInfo, peerID uint64, toStoreID uint64, ...) *Operator
- func CreateMovePeerOperator(desc string, cluster Cluster, region *core.RegionInfo, kind OpKind, ...) (*Operator, error)
- func CreateOfflinePeerOperator(desc string, cluster Cluster, region *core.RegionInfo, kind OpKind, ...) (*Operator, error)
- func CreateRemovePeerOperator(desc string, cluster Cluster, kind OpKind, region *core.RegionInfo, ...) (*Operator, error)
- func CreateTransferLeaderOperator(desc string, region *core.RegionInfo, sourceStoreID uint64, ...) *Operator
- func NewOperator(desc, brief string, regionID uint64, regionEpoch *metapb.RegionEpoch, ...) *Operator
- func (o *Operator) AttachKind(kind OpKind)
- func (o *Operator) Check(region *core.RegionInfo) OpStep
- func (o *Operator) ConfVerChanged(region *core.RegionInfo) int
- func (o *Operator) Desc() string
- func (o *Operator) ElapsedTime() time.Duration
- func (o *Operator) GetPriorityLevel() core.PriorityLevel
- func (o *Operator) GetStartTime() time.Time
- func (o *Operator) IsFinish() bool
- func (o *Operator) IsTimeout() bool
- func (o *Operator) Kind() OpKind
- func (o *Operator) Len() int
- func (o *Operator) MarshalJSON() ([]byte, error)
- func (o *Operator) RegionEpoch() *metapb.RegionEpoch
- func (o *Operator) RegionID() uint64
- func (o *Operator) RunningTime() time.Duration
- func (o *Operator) SetDesc(desc string)
- func (o *Operator) SetPriorityLevel(level core.PriorityLevel)
- func (o *Operator) SetStartTime(t time.Time)
- func (o *Operator) Step(i int) OpStep
- func (o *Operator) String() string
- type RemovePeer
- type TransferLeader
Constants ¶
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
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 ¶
ParseOperatorKind converts string (flag name list concat by ',') to OpKind.
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 ¶
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 ¶
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) ElapsedTime ¶
ElapsedTime returns duration since it was created.
func (*Operator) GetPriorityLevel ¶
func (o *Operator) GetPriorityLevel() core.PriorityLevel
GetPriorityLevel gets the priority level.
func (*Operator) GetStartTime ¶
GetStartTime ges the start time for operator.
func (*Operator) IsTimeout ¶
IsTimeout checks the operator's create time and determines if it is timeout.
func (*Operator) MarshalJSON ¶
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) RunningTime ¶
RunningTime returns duration since it was promoted.
func (*Operator) SetPriorityLevel ¶
func (o *Operator) SetPriorityLevel(level core.PriorityLevel)
SetPriorityLevel sets the priority level for operator.
func (*Operator) SetStartTime ¶
SetStartTime sets the start time for operator.
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