Documentation
¶
Index ¶
- Constants
- Variables
- func AddOpInfluence(op *Operator, influence OpInfluence, cluster *core.BasicCluster)
- func ApplyOperator(mc *mockcluster.Cluster, op *Operator)
- func ApplyOperatorStep(region *core.RegionInfo, op *Operator) *core.RegionInfo
- func IncOperatorLimitCounter(typ types.CheckerSchedulerType, kind OpKind)
- func IsEndStatus(s OpStatus) bool
- func OpStatusToPDPB(s OpStatus) pdpb.OperatorStatus
- func OpStatusToString(s OpStatus) string
- func SkipOriginJointStateCheck(b *Builder)
- func SkipPlacementRulesCheck(b *Builder)
- type AddLearner
- func (al AddLearner) CheckInProgress(ci *core.BasicCluster, config config.SharedConfigProvider, ...) error
- func (al AddLearner) ConfVerChanged(region *core.RegionInfo) uint64
- func (al AddLearner) GetCmd(region *core.RegionInfo, useConfChangeV2 bool) *hbstream.Operation
- func (al AddLearner) Influence(opInfluence OpInfluence, region *core.RegionInfo)
- func (al AddLearner) IsFinish(region *core.RegionInfo) bool
- func (al AddLearner) String() string
- func (AddLearner) Timeout(regionSize int64) time.Duration
- type AddPeer
- func (ap AddPeer) CheckInProgress(ci *core.BasicCluster, config config.SharedConfigProvider, ...) error
- func (ap AddPeer) ConfVerChanged(region *core.RegionInfo) uint64
- func (ap AddPeer) GetCmd(region *core.RegionInfo, useConfChangeV2 bool) *hbstream.Operation
- func (ap AddPeer) Influence(opInfluence OpInfluence, region *core.RegionInfo)
- func (ap AddPeer) IsFinish(region *core.RegionInfo) bool
- func (ap AddPeer) String() string
- func (AddPeer) Timeout(regionSize int64) time.Duration
- type BatchSwitchWitness
- func (bsw BatchSwitchWitness) CheckInProgress(ci *core.BasicCluster, config config.SharedConfigProvider, ...) error
- func (bsw BatchSwitchWitness) ConfVerChanged(region *core.RegionInfo) uint64
- func (bsw BatchSwitchWitness) GetCmd(region *core.RegionInfo, useConfChangeV2 bool) *hbstream.Operation
- func (bsw BatchSwitchWitness) Influence(opInfluence OpInfluence, region *core.RegionInfo)
- func (bsw BatchSwitchWitness) IsFinish(region *core.RegionInfo) bool
- func (bsw BatchSwitchWitness) String() string
- func (bsw BatchSwitchWitness) Timeout(regionSize int64) time.Duration
- type BecomeNonWitness
- func (bn BecomeNonWitness) CheckInProgress(ci *core.BasicCluster, config config.SharedConfigProvider, ...) error
- func (bn BecomeNonWitness) ConfVerChanged(region *core.RegionInfo) uint64
- func (bn BecomeNonWitness) GetCmd(*core.RegionInfo, bool) *hbstream.Operation
- func (bn BecomeNonWitness) Influence(opInfluence OpInfluence, region *core.RegionInfo)
- func (bn BecomeNonWitness) IsFinish(region *core.RegionInfo) bool
- func (bn BecomeNonWitness) String() string
- func (BecomeNonWitness) Timeout(regionSize int64) time.Duration
- type BecomeWitness
- func (bw BecomeWitness) CheckInProgress(ci *core.BasicCluster, config config.SharedConfigProvider, ...) error
- func (bw BecomeWitness) ConfVerChanged(region *core.RegionInfo) uint64
- func (bw BecomeWitness) GetCmd(_ *core.RegionInfo, _ bool) *hbstream.Operation
- func (bw BecomeWitness) Influence(opInfluence OpInfluence, region *core.RegionInfo)
- func (bw BecomeWitness) IsFinish(region *core.RegionInfo) bool
- func (bw BecomeWitness) String() string
- func (BecomeWitness) Timeout(regionSize int64) time.Duration
- type Builder
- func (b *Builder) AddPeer(peer *metapb.Peer) *Builder
- func (b *Builder) BecomeNonWitness(storeID uint64) *Builder
- func (b *Builder) BecomeWitness(storeID uint64) *Builder
- func (b *Builder) Build(kind OpKind) (*Operator, error)
- func (b *Builder) DemoteVoter(storeID uint64) *Builder
- func (b *Builder) EnableForceTargetLeader() *Builder
- func (b *Builder) PromoteLearner(storeID uint64) *Builder
- func (b *Builder) RemovePeer(storeID uint64) *Builder
- func (b *Builder) SetAddLightPeer() *Builder
- func (b *Builder) SetExpectedRoles(roles map[uint64]placement.PeerRoleType) *Builder
- func (b *Builder) SetLeader(storeID uint64) *Builder
- func (b *Builder) SetLeaders(storeIDs []uint64) *Builder
- func (b *Builder) SetPeers(peers map[uint64]*metapb.Peer) *Builder
- func (b *Builder) SetRemoveLightPeer() *Builder
- type BuilderOption
- type CancelReasonType
- type ChangePeerV2Enter
- func (cpe ChangePeerV2Enter) CheckInProgress(_ *core.BasicCluster, _ config.SharedConfigProvider, region *core.RegionInfo) error
- func (cpe ChangePeerV2Enter) ConfVerChanged(region *core.RegionInfo) uint64
- func (cpe ChangePeerV2Enter) GetCmd(region *core.RegionInfo, useConfChangeV2 bool) *hbstream.Operation
- func (ChangePeerV2Enter) Influence(OpInfluence, *core.RegionInfo)
- func (cpe ChangePeerV2Enter) IsFinish(region *core.RegionInfo) bool
- func (cpe ChangePeerV2Enter) String() string
- func (cpe ChangePeerV2Enter) Timeout(regionSize int64) time.Duration
- type ChangePeerV2Leave
- func (cpl ChangePeerV2Leave) CheckInProgress(_ *core.BasicCluster, _ config.SharedConfigProvider, region *core.RegionInfo) error
- func (cpl ChangePeerV2Leave) ConfVerChanged(region *core.RegionInfo) uint64
- func (ChangePeerV2Leave) GetCmd(_ *core.RegionInfo, useConfChangeV2 bool) *hbstream.Operation
- func (ChangePeerV2Leave) Influence(OpInfluence, *core.RegionInfo)
- func (cpl ChangePeerV2Leave) IsFinish(region *core.RegionInfo) bool
- func (cpl ChangePeerV2Leave) String() string
- func (cpl ChangePeerV2Leave) Timeout(regionSize int64) time.Duration
- type Controller
- func (oc *Controller) AddOperator(ops ...*Operator) bool
- func (oc *Controller) AddWaitingOperator(ops ...*Operator) int
- func (oc *Controller) CleanAllOpRecords()
- func (oc *Controller) Ctx() context.Context
- func (oc *Controller) Dispatch(region *core.RegionInfo, source string, ...)
- func (oc *Controller) ExceedStoreLimit(ops ...*Operator) bool
- func (oc *Controller) GetCluster() *core.BasicCluster
- func (oc *Controller) GetFastOpInfluence(cluster *core.BasicCluster, influence OpInfluence)
- func (oc *Controller) GetHBStreams() *hbstream.HeartbeatStreams
- func (oc *Controller) GetHistory(start time.Time) []OpHistory
- func (oc *Controller) GetOpInfluence(cluster *core.BasicCluster, opts ...OpInfluenceOption) OpInfluence
- func (oc *Controller) GetOperator(regionID uint64) *Operator
- func (oc *Controller) GetOperatorStatus(id uint64) *OpWithStatus
- func (oc *Controller) GetOperators() []*Operator
- func (oc *Controller) GetOperatorsOfKind(mask OpKind) []*Operator
- func (oc *Controller) GetRecords(from time.Time) []*OpRecord
- func (oc *Controller) GetWaitingOperators() []*Operator
- func (oc *Controller) OperatorCount(kind OpKind) uint64
- func (oc *Controller) PromoteWaitingOperator()
- func (oc *Controller) PushOperators(recordOpStepWithTTL func(regionID uint64))
- func (oc *Controller) RemoveOperator(op *Operator, reasons ...CancelReasonType) bool
- func (oc *Controller) RemoveOperators(reasons ...CancelReasonType)
- func (oc *Controller) SendScheduleCommand(region *core.RegionInfo, step OpStep, source string)
- func (oc *Controller) SetOperator(op *Operator)
- type DemoteVoter
- func (dv DemoteVoter) ConfVerChanged(region *core.RegionInfo) uint64
- func (dv DemoteVoter) GetCmd(_ *core.RegionInfo, useConfChangeV2 bool) *hbstream.Operation
- func (dv DemoteVoter) IsFinish(region *core.RegionInfo) bool
- func (dv DemoteVoter) String() string
- func (DemoteVoter) Timeout(regionSize int64) time.Duration
- type MergeRegion
- func (MergeRegion) CheckInProgress(*core.BasicCluster, config.SharedConfigProvider, *core.RegionInfo) error
- func (MergeRegion) ConfVerChanged(*core.RegionInfo) uint64
- func (mr MergeRegion) GetCmd(*core.RegionInfo, bool) *hbstream.Operation
- func (mr MergeRegion) Influence(opInfluence OpInfluence, region *core.RegionInfo)
- func (mr MergeRegion) IsFinish(region *core.RegionInfo) bool
- func (mr MergeRegion) String() string
- func (MergeRegion) Timeout(regionSize int64) time.Duration
- type OpHistory
- type OpInfluence
- type OpInfluenceOption
- type OpKind
- type OpObject
- type OpRecord
- type OpStatus
- type OpStatusTracker
- func (trk *OpStatusTracker) CheckExpired(exp time.Duration) bool
- func (trk *OpStatusTracker) CheckTimeout(duration time.Duration) bool
- func (trk *OpStatusTracker) IsEnd() bool
- func (trk *OpStatusTracker) ReachTime() time.Time
- func (trk *OpStatusTracker) ReachTimeOf(s OpStatus) time.Time
- func (trk *OpStatusTracker) Status() OpStatus
- func (trk *OpStatusTracker) String() string
- func (trk *OpStatusTracker) To(dst OpStatus) bool
- type OpStep
- type OpWithStatus
- type Operator
- func CreateAddPeerOperator(desc string, ci sche.SharedCluster, region *core.RegionInfo, peer *metapb.Peer, ...) (*Operator, error)
- func CreateDemoteLearnerOperatorAndRemovePeer(desc string, ci sche.SharedCluster, region *core.RegionInfo, ...) (*Operator, error)
- func CreateDemoteVoterOperator(desc string, ci sche.SharedCluster, region *core.RegionInfo, peer *metapb.Peer) (*Operator, error)
- func CreateForceTransferLeaderOperator(desc string, ci sche.SharedCluster, region *core.RegionInfo, ...) (*Operator, error)
- func CreateLeaveJointStateOperator(desc string, ci sche.SharedCluster, origin *core.RegionInfo) (*Operator, error)
- func CreateMergeRegionOperator(desc string, ci sche.SharedCluster, source *core.RegionInfo, ...) ([]*Operator, error)
- func CreateMoveLeaderOperator(desc string, ci sche.SharedCluster, region *core.RegionInfo, kind OpKind, ...) (*Operator, error)
- func CreateMovePeerOperator(desc string, ci sche.SharedCluster, region *core.RegionInfo, kind OpKind, ...) (*Operator, error)
- func CreateMoveRegionOperator(desc string, ci sche.SharedCluster, region *core.RegionInfo, kind OpKind, ...) (*Operator, error)
- func CreateMoveWitnessOperator(desc string, ci sche.SharedCluster, region *core.RegionInfo, ...) (*Operator, error)
- func CreateNonWitnessPeerOperator(desc string, ci sche.SharedCluster, region *core.RegionInfo, peer *metapb.Peer) (*Operator, error)
- func CreatePromoteLearnerOperator(desc string, ci sche.SharedCluster, region *core.RegionInfo, peer *metapb.Peer) (*Operator, error)
- func CreatePromoteLearnerOperatorAndRemovePeer(desc string, ci sche.SharedCluster, region *core.RegionInfo, ...) (*Operator, error)
- func CreateRemovePeerOperator(desc string, ci sche.SharedCluster, kind OpKind, region *core.RegionInfo, ...) (*Operator, error)
- func CreateReplaceLeaderPeerOperator(desc string, ci sche.SharedCluster, region *core.RegionInfo, kind OpKind, ...) (*Operator, error)
- func CreateScatterRegionOperator(desc string, ci sche.SharedCluster, origin *core.RegionInfo, ...) (*Operator, error)
- func CreateSplitRegionOperator(desc string, region *core.RegionInfo, kind OpKind, policy pdpb.CheckPolicy, ...) (*Operator, error)
- func CreateTransferLeaderOperator(desc string, ci sche.SharedCluster, region *core.RegionInfo, ...) (*Operator, error)
- func CreateWitnessPeerOperator(desc string, ci sche.SharedCluster, region *core.RegionInfo, peer *metapb.Peer) (*Operator, error)
- func NewOperator(desc, brief string, regionID uint64, regionEpoch *metapb.RegionEpoch, ...) *Operator
- func NewTestOperator(regionID uint64, regionEpoch *metapb.RegionEpoch, kind OpKind, steps ...OpStep) *Operator
- func (o *Operator) AttachKind(kind OpKind)
- func (o *Operator) Brief() string
- func (o *Operator) Cancel(reason ...CancelReasonType) bool
- func (o *Operator) Check(region *core.RegionInfo) OpStep
- func (o *Operator) CheckAndGetStatus() OpStatus
- func (o *Operator) CheckExpired() bool
- func (o *Operator) CheckSuccess() bool
- func (o *Operator) CheckTimeout() bool
- func (o *Operator) ConfVerChanged(region *core.RegionInfo) (total uint64)
- func (o *Operator) ContainNonWitnessStep() bool
- func (o *Operator) Desc() string
- func (o *Operator) ElapsedTime() time.Duration
- func (o *Operator) GetAdditionalInfo(key string) string
- func (o *Operator) GetCreateTime() time.Time
- func (o *Operator) GetPriorityLevel() constant.PriorityLevel
- func (o *Operator) GetReachTimeOf(st OpStatus) time.Time
- func (o *Operator) GetStartTime() time.Time
- func (o *Operator) HasStarted() bool
- func (o *Operator) History() []OpHistory
- func (o *Operator) IsEnd() bool
- func (o *Operator) IsLeaveJointStateOperator() bool
- func (o *Operator) Kind() OpKind
- func (o *Operator) Len() int
- func (o *Operator) LogAdditionalInfo() string
- func (o *Operator) MarshalJSON() ([]byte, error)
- func (o *Operator) Record(finishTime time.Time) *OpRecord
- func (o *Operator) RegionEpoch() *metapb.RegionEpoch
- func (o *Operator) RegionID() uint64
- func (o *Operator) Replace() bool
- func (o *Operator) RunningTime() time.Duration
- func (o *Operator) SchedulerKind() OpKind
- func (o *Operator) SetAdditionalInfo(key string, value string)
- func (o *Operator) SetDesc(desc string)
- func (o *Operator) SetPriorityLevel(level constant.PriorityLevel)
- func (o *Operator) SetStatusReachTime(st OpStatus, t time.Time)
- func (o *Operator) Start() bool
- func (o *Operator) Status() OpStatus
- func (o *Operator) Step(i int) OpStep
- func (o *Operator) String() string
- func (o *Operator) Sync(other *Operator)
- func (o *Operator) ToJSONObject() *OpObject
- func (o *Operator) TotalInfluence(opInfluence OpInfluence, region *core.RegionInfo)
- func (o *Operator) UnfinishedInfluence(opInfluence OpInfluence, region *core.RegionInfo)
- type PromoteLearner
- func (pl PromoteLearner) CheckInProgress(_ *core.BasicCluster, _ config.SharedConfigProvider, region *core.RegionInfo) error
- func (pl PromoteLearner) ConfVerChanged(region *core.RegionInfo) uint64
- func (pl PromoteLearner) GetCmd(_ *core.RegionInfo, useConfChangeV2 bool) *hbstream.Operation
- func (PromoteLearner) Influence(OpInfluence, *core.RegionInfo)
- func (pl PromoteLearner) IsFinish(region *core.RegionInfo) bool
- func (pl PromoteLearner) String() string
- func (PromoteLearner) Timeout(regionSize int64) time.Duration
- type RemovePeer
- func (rp RemovePeer) CheckInProgress(_ *core.BasicCluster, _ config.SharedConfigProvider, region *core.RegionInfo) error
- func (rp RemovePeer) ConfVerChanged(region *core.RegionInfo) uint64
- func (rp RemovePeer) GetCmd(region *core.RegionInfo, useConfChangeV2 bool) *hbstream.Operation
- func (rp RemovePeer) Influence(opInfluence OpInfluence, region *core.RegionInfo)
- func (rp RemovePeer) IsFinish(region *core.RegionInfo) bool
- func (rp RemovePeer) String() string
- func (RemovePeer) Timeout(regionSize int64) time.Duration
- type SplitRegion
- func (SplitRegion) CheckInProgress(*core.BasicCluster, config.SharedConfigProvider, *core.RegionInfo) error
- func (SplitRegion) ConfVerChanged(*core.RegionInfo) uint64
- func (sr SplitRegion) GetCmd(*core.RegionInfo, bool) *hbstream.Operation
- func (SplitRegion) Influence(opInfluence OpInfluence, region *core.RegionInfo)
- func (sr SplitRegion) IsFinish(region *core.RegionInfo) bool
- func (sr SplitRegion) String() string
- func (SplitRegion) Timeout(regionSize int64) time.Duration
- type StoreInfluence
- func (s *StoreInfluence) AddStepCost(limitType storelimit.Type, cost int64)
- func (s *StoreInfluence) AdjustStepCost(limitType storelimit.Type, regionSize int64)
- func (s *StoreInfluence) GetStepCost(limitType storelimit.Type) int64
- func (s *StoreInfluence) ResourceProperty(kind constant.ScheduleKind) int64
- type TransferLeader
- func (tl TransferLeader) CheckInProgress(ci *core.BasicCluster, config config.SharedConfigProvider, ...) error
- func (TransferLeader) ConfVerChanged(_ *core.RegionInfo) uint64
- func (tl TransferLeader) GetCmd(region *core.RegionInfo, _ bool) *hbstream.Operation
- func (tl TransferLeader) Influence(opInfluence OpInfluence, region *core.RegionInfo)
- func (tl TransferLeader) IsFinish(region *core.RegionInfo) bool
- func (tl TransferLeader) String() string
- func (TransferLeader) Timeout(regionSize int64) time.Duration
- type WaitingOperator
Constants ¶
const ( DispatchFromHeartBeat = "heartbeat" DispatchFromNotifierQueue = "active push" DispatchFromCreate = "create" )
The source of dispatched region.
const ( // DefaultSlowExecutorRate is the slow rate of the step executor. // default: 6 s/Mb DefaultSlowExecutorRate = 6 // DefaultFastExecutorRate is the fast rate of the step executor. // default: 0.6 s/Mb DefaultFastExecutorRate = 0.6 // FastStepWaitTime is the duration that the OpStep may take. // there are some steps that may take a short time, such as transfer leader, remove peer etc. // It should consider the latency of handling region heartbeat especially big cluster. // The update duration of region heartbeat should be less than the region heartbeat interval(default 60s). FastStepWaitTime = 60 * time.Second // SlowStepWaitTime is the duration that the OpStep may take. // there are some steps that may take a long time, such as add peer, merge region etc. SlowStepWaitTime = 10 * time.Minute )
const OpDescLeaveJointState = "leave-joint-state"
OpDescLeaveJointState is the expected desc for LeaveJointStateOperator.
const OpWaiting = "waiting"
OpWaiting is the status of a waiting operators.
const ( // OperatorExpireTime is the duration that when an operator is not started // after it, the operator will be considered expired. OperatorExpireTime = 3 * time.Second )
Variables ¶
var ( // StoreBalanceBaseTime represents the base time of balance rate. StoreBalanceBaseTime float64 = 60 // FastOperatorFinishTime min finish time, if finish duration less than it, op will be pushed to fast operator queue FastOperatorFinishTime = 10 * time.Second )
var ( // OperatorExceededStoreLimitCounter exposes the counter when operator meet exceeded store limit. OperatorExceededStoreLimitCounter = prometheus.NewCounterVec( prometheus.CounterOpts{ Namespace: "pd", Subsystem: "schedule", Name: "operator_exceeded_store_limit", Help: "Counter of operator meeting store limit", }, []string{"desc"}) )
Functions ¶
func AddOpInfluence ¶
func AddOpInfluence(op *Operator, influence OpInfluence, cluster *core.BasicCluster)
AddOpInfluence add operator influence for cluster
func ApplyOperator ¶
func ApplyOperator(mc *mockcluster.Cluster, op *Operator)
ApplyOperator applies Only for test purpose.
func ApplyOperatorStep ¶
func ApplyOperatorStep(region *core.RegionInfo, op *Operator) *core.RegionInfo
ApplyOperatorStep applies operator step. Only for test purpose.
func IncOperatorLimitCounter ¶
func IncOperatorLimitCounter(typ types.CheckerSchedulerType, kind OpKind)
IncOperatorLimitCounter increases the counter of operator meeting limit.
func OpStatusToPDPB ¶
func OpStatusToPDPB(s OpStatus) pdpb.OperatorStatus
OpStatusToPDPB converts OpStatus to pdpb.OperatorStatus.
func OpStatusToString ¶
OpStatusToString converts Status to string.
func SkipOriginJointStateCheck ¶
func SkipOriginJointStateCheck(b *Builder)
SkipOriginJointStateCheck lets the builder skip the joint state check for origin peers.
func SkipPlacementRulesCheck ¶
func SkipPlacementRulesCheck(b *Builder)
SkipPlacementRulesCheck lets the builder skip the placement rules check for origin and target peers.
Types ¶
type AddLearner ¶
AddLearner is an OpStep that adds a region learner peer.
func (AddLearner) CheckInProgress ¶
func (al AddLearner) CheckInProgress(ci *core.BasicCluster, config config.SharedConfigProvider, region *core.RegionInfo) error
CheckInProgress checks if the step is in the progress of advancing.
func (AddLearner) ConfVerChanged ¶
func (al AddLearner) ConfVerChanged(region *core.RegionInfo) uint64
ConfVerChanged returns the delta value for version increased by this step.
func (AddLearner) GetCmd ¶
func (al AddLearner) GetCmd(region *core.RegionInfo, useConfChangeV2 bool) *hbstream.Operation
GetCmd returns the schedule command for heartbeat response.
func (AddLearner) Influence ¶
func (al AddLearner) Influence(opInfluence OpInfluence, region *core.RegionInfo)
Influence calculates the store difference that current step makes.
func (AddLearner) IsFinish ¶
func (al AddLearner) IsFinish(region *core.RegionInfo) bool
IsFinish checks if current step is finished.
func (AddLearner) String ¶
func (al AddLearner) String() string
type AddPeer ¶
AddPeer is an OpStep that adds a region peer.
func (AddPeer) CheckInProgress ¶
func (ap AddPeer) CheckInProgress(ci *core.BasicCluster, config config.SharedConfigProvider, region *core.RegionInfo) error
CheckInProgress checks if the step is in the progress of advancing.
func (AddPeer) ConfVerChanged ¶
func (ap AddPeer) ConfVerChanged(region *core.RegionInfo) uint64
ConfVerChanged returns the delta value for version increased by this step.
func (AddPeer) Influence ¶
func (ap AddPeer) Influence(opInfluence OpInfluence, region *core.RegionInfo)
Influence calculates the store difference that current step makes.
type BatchSwitchWitness ¶
type BatchSwitchWitness struct {
ToWitnesses []BecomeWitness
ToNonWitnesses []BecomeNonWitness
}
BatchSwitchWitness is an OpStep that batch switch witness.
func (BatchSwitchWitness) CheckInProgress ¶
func (bsw BatchSwitchWitness) CheckInProgress(ci *core.BasicCluster, config config.SharedConfigProvider, region *core.RegionInfo) error
CheckInProgress checks if the step is in the progress of advancing.
func (BatchSwitchWitness) ConfVerChanged ¶
func (bsw BatchSwitchWitness) ConfVerChanged(region *core.RegionInfo) uint64
ConfVerChanged returns the delta value for version increased by this step.
func (BatchSwitchWitness) GetCmd ¶
func (bsw BatchSwitchWitness) GetCmd(region *core.RegionInfo, useConfChangeV2 bool) *hbstream.Operation
GetCmd returns the schedule command for heartbeat response.
func (BatchSwitchWitness) Influence ¶
func (bsw BatchSwitchWitness) Influence(opInfluence OpInfluence, region *core.RegionInfo)
Influence calculates the store difference that current step makes.
func (BatchSwitchWitness) IsFinish ¶
func (bsw BatchSwitchWitness) IsFinish(region *core.RegionInfo) bool
IsFinish checks if current step is finished.
func (BatchSwitchWitness) String ¶
func (bsw BatchSwitchWitness) String() string
type BecomeNonWitness ¶
type BecomeNonWitness struct {
PeerID, StoreID, SendStore uint64
}
BecomeNonWitness is an OpStep that makes a peer become a non-witness.
func (BecomeNonWitness) CheckInProgress ¶
func (bn BecomeNonWitness) CheckInProgress(ci *core.BasicCluster, config config.SharedConfigProvider, region *core.RegionInfo) error
CheckInProgress checks if the step is in the progress of advancing.
func (BecomeNonWitness) ConfVerChanged ¶
func (bn BecomeNonWitness) ConfVerChanged(region *core.RegionInfo) uint64
ConfVerChanged returns the delta value for version increased by this step.
func (BecomeNonWitness) GetCmd ¶
func (bn BecomeNonWitness) GetCmd(*core.RegionInfo, bool) *hbstream.Operation
GetCmd returns the schedule command for heartbeat response.
func (BecomeNonWitness) Influence ¶
func (bn BecomeNonWitness) Influence(opInfluence OpInfluence, region *core.RegionInfo)
Influence calculates the store difference that current step makes.
func (BecomeNonWitness) IsFinish ¶
func (bn BecomeNonWitness) IsFinish(region *core.RegionInfo) bool
IsFinish checks if current step is finished.
func (BecomeNonWitness) String ¶
func (bn BecomeNonWitness) String() string
type BecomeWitness ¶
type BecomeWitness struct {
PeerID, StoreID uint64
}
BecomeWitness is an OpStep that makes a peer become a witness.
func (BecomeWitness) CheckInProgress ¶
func (bw BecomeWitness) CheckInProgress(ci *core.BasicCluster, config config.SharedConfigProvider, region *core.RegionInfo) error
CheckInProgress checks if the step is in the progress of advancing.
func (BecomeWitness) ConfVerChanged ¶
func (bw BecomeWitness) ConfVerChanged(region *core.RegionInfo) uint64
ConfVerChanged returns the delta value for version increased by this step.
func (BecomeWitness) GetCmd ¶
func (bw BecomeWitness) GetCmd(_ *core.RegionInfo, _ bool) *hbstream.Operation
GetCmd returns the schedule command for heartbeat response.
func (BecomeWitness) Influence ¶
func (bw BecomeWitness) Influence(opInfluence OpInfluence, region *core.RegionInfo)
Influence calculates the store difference that current step makes.
func (BecomeWitness) IsFinish ¶
func (bw BecomeWitness) IsFinish(region *core.RegionInfo) bool
IsFinish checks if current step is finished.
func (BecomeWitness) String ¶
func (bw BecomeWitness) String() string
type Builder ¶
type Builder struct {
sche.SharedCluster
// contains filtered or unexported fields
}
Builder is used to create operators. Usage:
op, err := NewBuilder(desc, cluster, region).
RemovePeer(store1).
AddPeer(peer1).
SetLeader(store2).
Build(kind)
The generated Operator will choose the most appropriate execution order according to various constraints.
func NewBuilder ¶
func NewBuilder(desc string, ci sche.SharedCluster, region *core.RegionInfo, opts ...BuilderOption) *Builder
NewBuilder creates a Builder.
func (*Builder) AddPeer ¶
AddPeer records an add Peer operation in Builder. If peer.Id is 0, the builder will allocate a new peer ID later.
func (*Builder) BecomeNonWitness ¶
BecomeNonWitness records a switch to non-witness operation in Builder.
func (*Builder) BecomeWitness ¶
BecomeWitness records a switch to witness operation in Builder.
func (*Builder) DemoteVoter ¶
DemoteVoter records a demote voter operation in Builder.
func (*Builder) EnableForceTargetLeader ¶
EnableForceTargetLeader marks the step of transferring leader to target is forcible.
func (*Builder) PromoteLearner ¶
PromoteLearner records a promote learner operation in Builder.
func (*Builder) RemovePeer ¶
RemovePeer records a remove peer operation in Builder.
func (*Builder) SetAddLightPeer ¶
SetAddLightPeer marks the add peer as light weight. It is used for scatter regions.
func (*Builder) SetExpectedRoles ¶
func (b *Builder) SetExpectedRoles(roles map[uint64]placement.PeerRoleType) *Builder
SetExpectedRoles records expected roles of target peers. It may update `targetLeaderStoreID` if there is a peer has role `leader` or `follower`.
func (*Builder) SetLeaders ¶
SetLeaders records all valid target leaders in Builder.
func (*Builder) SetPeers ¶
SetPeers resets the target peer list.
If peer's ID is 0, the builder will allocate a new ID later. If current target leader does not exist in peers, it will be reset.
func (*Builder) SetRemoveLightPeer ¶
SetRemoveLightPeer marks the remove peer as light weight. It is used for scatter regions.
type BuilderOption ¶
type BuilderOption func(*Builder)
BuilderOption is used to create operator builder.
type CancelReasonType ¶
type CancelReasonType string
CancelReasonType is the type of cancel reason.
var ( // RegionNotFound is the cancel reason when the region is not found. RegionNotFound CancelReasonType = "region not found" // EpochNotMatch is the cancel reason when the region epoch is not match. EpochNotMatch CancelReasonType = "epoch not match" // AlreadyExist is the cancel reason when the operator is running. AlreadyExist CancelReasonType = "already exist" // AdminStop is the cancel reason when the operator is stopped by admin. AdminStop CancelReasonType = "admin stop" // NotInRunningState is the cancel reason when the operator is not in running state. NotInRunningState CancelReasonType = "not in running state" // Timeout is the cancel reason when the operator is timeout. Timeout CancelReasonType = "timeout" // Expired is the cancel reason when the operator is expired. Expired CancelReasonType = "expired" // NotInCreateStatus is the cancel reason when the operator is not in create status. NotInCreateStatus CancelReasonType = "not in create status" // StaleStatus is the cancel reason when the operator is in a stale status. StaleStatus CancelReasonType = "stale status" // ExceedStoreLimit is the cancel reason when the operator exceeds the store limit. ExceedStoreLimit CancelReasonType = "exceed store limit" // ExceedWaitLimit is the cancel reason when the operator exceeds the waiting queue limit. ExceedWaitLimit CancelReasonType = "exceed wait limit" // RelatedMergeRegion is the cancel reason when the operator is cancelled by related merge region. RelatedMergeRegion CancelReasonType = "related merge region" // Unknown is the cancel reason when the operator is cancelled by an unknown reason. Unknown CancelReasonType = "unknown" )
type ChangePeerV2Enter ¶
type ChangePeerV2Enter struct {
PromoteLearners []PromoteLearner
DemoteVoters []DemoteVoter
}
ChangePeerV2Enter is an OpStep that uses joint consensus to request all PromoteLearner and DemoteVoter.
func (ChangePeerV2Enter) CheckInProgress ¶
func (cpe ChangePeerV2Enter) CheckInProgress(_ *core.BasicCluster, _ config.SharedConfigProvider, region *core.RegionInfo) error
CheckInProgress checks if the step is in the progress of advancing.
func (ChangePeerV2Enter) ConfVerChanged ¶
func (cpe ChangePeerV2Enter) ConfVerChanged(region *core.RegionInfo) uint64
ConfVerChanged returns the delta value for version increased by this step.
func (ChangePeerV2Enter) GetCmd ¶
func (cpe ChangePeerV2Enter) GetCmd(region *core.RegionInfo, useConfChangeV2 bool) *hbstream.Operation
GetCmd returns the schedule command for heartbeat response.
func (ChangePeerV2Enter) Influence ¶
func (ChangePeerV2Enter) Influence(OpInfluence, *core.RegionInfo)
Influence calculates the store difference that current step makes.
func (ChangePeerV2Enter) IsFinish ¶
func (cpe ChangePeerV2Enter) IsFinish(region *core.RegionInfo) bool
IsFinish checks if current step is finished.
func (ChangePeerV2Enter) String ¶
func (cpe ChangePeerV2Enter) String() string
type ChangePeerV2Leave ¶
type ChangePeerV2Leave struct {
PromoteLearners []PromoteLearner
DemoteVoters []DemoteVoter
}
ChangePeerV2Leave is an OpStep that leaves the joint state.
func (ChangePeerV2Leave) CheckInProgress ¶
func (cpl ChangePeerV2Leave) CheckInProgress(_ *core.BasicCluster, _ config.SharedConfigProvider, region *core.RegionInfo) error
CheckInProgress checks if the step is in the progress of advancing.
func (ChangePeerV2Leave) ConfVerChanged ¶
func (cpl ChangePeerV2Leave) ConfVerChanged(region *core.RegionInfo) uint64
ConfVerChanged returns the delta value for version increased by this step.
func (ChangePeerV2Leave) GetCmd ¶
func (ChangePeerV2Leave) GetCmd(_ *core.RegionInfo, useConfChangeV2 bool) *hbstream.Operation
GetCmd returns the schedule command for heartbeat response.
func (ChangePeerV2Leave) Influence ¶
func (ChangePeerV2Leave) Influence(OpInfluence, *core.RegionInfo)
Influence calculates the store difference that current step makes.
func (ChangePeerV2Leave) IsFinish ¶
func (cpl ChangePeerV2Leave) IsFinish(region *core.RegionInfo) bool
IsFinish checks if current step is finished.
func (ChangePeerV2Leave) String ¶
func (cpl ChangePeerV2Leave) String() string
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller is used to limit the speed of scheduling.
func NewController ¶
func NewController(ctx context.Context, cluster *core.BasicCluster, config config.SharedConfigProvider, hbStreams *hbstream.HeartbeatStreams) *Controller
NewController creates a Controller.
func (*Controller) AddOperator ¶
func (oc *Controller) AddOperator(ops ...*Operator) bool
AddOperator adds operators to the running operators.
func (*Controller) AddWaitingOperator ¶
func (oc *Controller) AddWaitingOperator(ops ...*Operator) int
AddWaitingOperator adds operators to waiting operators.
func (*Controller) CleanAllOpRecords ¶
func (oc *Controller) CleanAllOpRecords()
CleanAllOpRecords removes all operators' records. It is used in tests only.
func (*Controller) Ctx ¶
func (oc *Controller) Ctx() context.Context
Ctx returns a context which will be canceled once RaftCluster is stopped. For now, it is only used to control the lifetime of TTL cache in schedulers.
func (*Controller) Dispatch ¶
func (oc *Controller) Dispatch(region *core.RegionInfo, source string, recordOpStepWithTTL func(regionID uint64))
Dispatch is used to dispatch the operator of a region.
func (*Controller) ExceedStoreLimit ¶
func (oc *Controller) ExceedStoreLimit(ops ...*Operator) bool
ExceedStoreLimit returns true if the store exceeds the cost limit after adding the Otherwise, returns false.
func (*Controller) GetCluster ¶
func (oc *Controller) GetCluster() *core.BasicCluster
GetCluster exports basic cluster to evict-scheduler for check store status.
func (*Controller) GetFastOpInfluence ¶
func (oc *Controller) GetFastOpInfluence(cluster *core.BasicCluster, influence OpInfluence)
GetFastOpInfluence get fast finish operator influence
func (*Controller) GetHBStreams ¶
func (oc *Controller) GetHBStreams() *hbstream.HeartbeatStreams
GetHBStreams returns the heartbeat steams.
func (*Controller) GetHistory ¶
func (oc *Controller) GetHistory(start time.Time) []OpHistory
GetHistory gets operators' history.
func (*Controller) GetOpInfluence ¶
func (oc *Controller) GetOpInfluence(cluster *core.BasicCluster, opts ...OpInfluenceOption) OpInfluence
GetOpInfluence gets OpInfluence.
func (*Controller) GetOperator ¶
func (oc *Controller) GetOperator(regionID uint64) *Operator
GetOperator gets an operator from the given region.
func (*Controller) GetOperatorStatus ¶
func (oc *Controller) GetOperatorStatus(id uint64) *OpWithStatus
GetOperatorStatus gets the operator and its status with the specify id.
func (*Controller) GetOperators ¶
func (oc *Controller) GetOperators() []*Operator
GetOperators gets operators from the running operators.
func (*Controller) GetOperatorsOfKind ¶
func (oc *Controller) GetOperatorsOfKind(mask OpKind) []*Operator
GetOperatorsOfKind returns the running operators of the kind.
func (*Controller) GetRecords ¶
func (oc *Controller) GetRecords(from time.Time) []*OpRecord
GetRecords gets operators' records.
func (*Controller) GetWaitingOperators ¶
func (oc *Controller) GetWaitingOperators() []*Operator
GetWaitingOperators gets operators from the waiting operators.
func (*Controller) OperatorCount ¶
func (oc *Controller) OperatorCount(kind OpKind) uint64
OperatorCount gets the count of operators filtered by kind. kind only has one OpKind.
func (*Controller) PromoteWaitingOperator ¶
func (oc *Controller) PromoteWaitingOperator()
PromoteWaitingOperator promotes operators from waiting operators.
func (*Controller) PushOperators ¶
func (oc *Controller) PushOperators(recordOpStepWithTTL func(regionID uint64))
PushOperators periodically pushes the unfinished operator to the executor(TiKV).
func (*Controller) RemoveOperator ¶
func (oc *Controller) RemoveOperator(op *Operator, reasons ...CancelReasonType) bool
RemoveOperator removes an operator from the running operators.
func (*Controller) RemoveOperators ¶
func (oc *Controller) RemoveOperators(reasons ...CancelReasonType)
RemoveOperators removes all operators from the running operators.
func (*Controller) SendScheduleCommand ¶
func (oc *Controller) SendScheduleCommand(region *core.RegionInfo, step OpStep, source string)
SendScheduleCommand sends a command to the region.
func (*Controller) SetOperator ¶
func (oc *Controller) SetOperator(op *Operator)
SetOperator is only used for test.
type DemoteVoter ¶
DemoteVoter is very similar to DemoteFollower. But it allows Demote Leader. Note: It is not an OpStep, only a sub step in ChangePeerV2Enter and ChangePeerV2Leave.
func (DemoteVoter) ConfVerChanged ¶
func (dv DemoteVoter) ConfVerChanged(region *core.RegionInfo) uint64
ConfVerChanged returns the delta value for version increased by this step.
func (DemoteVoter) GetCmd ¶
func (dv DemoteVoter) GetCmd(_ *core.RegionInfo, useConfChangeV2 bool) *hbstream.Operation
GetCmd returns the schedule command for heartbeat response.
func (DemoteVoter) IsFinish ¶
func (dv DemoteVoter) IsFinish(region *core.RegionInfo) bool
IsFinish checks if current step is finished.
func (DemoteVoter) String ¶
func (dv DemoteVoter) String() string
type MergeRegion ¶
type MergeRegion struct {
FromRegion *metapb.Region
ToRegion *metapb.Region
// there are two regions involved in merge process,
// so to keep them from other scheduler,
// both of them should add MerRegion operatorStep.
// But actually, TiKV just needs the region want to be merged to get the merge request,
// thus use a IsPassive mark to indicate that
// this region doesn't need to send merge request to TiKV.
IsPassive bool
}
MergeRegion is an OpStep that merge two regions.
func (MergeRegion) CheckInProgress ¶
func (MergeRegion) CheckInProgress(*core.BasicCluster, config.SharedConfigProvider, *core.RegionInfo) error
CheckInProgress checks if the step is in the progress of advancing.
func (MergeRegion) ConfVerChanged ¶
func (MergeRegion) ConfVerChanged(*core.RegionInfo) uint64
ConfVerChanged returns the delta value for version increased by this step.
func (MergeRegion) GetCmd ¶
func (mr MergeRegion) GetCmd(*core.RegionInfo, bool) *hbstream.Operation
GetCmd returns the schedule command for heartbeat response.
func (MergeRegion) Influence ¶
func (mr MergeRegion) Influence(opInfluence OpInfluence, region *core.RegionInfo)
Influence calculates the store difference that current step makes.
func (MergeRegion) IsFinish ¶
func (mr MergeRegion) IsFinish(region *core.RegionInfo) bool
IsFinish checks if current step is finished.
func (MergeRegion) String ¶
func (mr MergeRegion) String() string
type OpHistory ¶
type OpHistory struct {
FinishTime time.Time
From, To uint64
Kind constant.ResourceKind
}
OpHistory is used to log and visualize completed operators.
type OpInfluence ¶
type OpInfluence struct {
StoresInfluence map[uint64]*StoreInfluence
}
OpInfluence records the influence of the cluster.
func NewTotalOpInfluence ¶
func NewTotalOpInfluence(operators []*Operator, cluster *core.BasicCluster) OpInfluence
NewTotalOpInfluence creates a OpInfluence.
func (OpInfluence) GetStoreInfluence ¶
func (m OpInfluence) GetStoreInfluence(id uint64) *StoreInfluence
GetStoreInfluence get storeInfluence of specific store.
type OpInfluenceOption ¶
type OpInfluenceOption func(region *core.RegionInfo) bool
OpInfluenceOption is used to filter the region. returns true if the region meets the condition, it will ignore this region in the influence calculation. returns false if the region does not meet the condition, it will calculate the influence of this region.
func WithRangeOption ¶
func WithRangeOption(ranges []keyutil.KeyRange) OpInfluenceOption
WithRangeOption returns an OpInfluenceOption that filters the region by the key ranges.
type OpKind ¶
type OpKind uint32
OpKind is a bit field to identify operator types.
const ( // Initiated by admin. OpAdmin OpKind = 1 << iota // Initiated by merge checker or merge scheduler. Note that it may not include region merge. // the order describe the operator's producer and is very helpful to decouple scheduler or checker limit OpMerge // Initiated by range scheduler. OpRange // Initiated by replica checker. OpReplica // Include region split. Initiated by rule checker if `kind & OpAdmin == 0`. OpSplit // Initiated by hot region scheduler. OpHotRegion // Include peer addition or removal or switch witness. This means that this operator may take a long time. OpRegion // Include leader transfer. OpLeader // Include witness leader transfer. OpWitnessLeader // Include witness transfer. OpWitness )
Flags for operators.
func ParseOperatorKind ¶
ParseOperatorKind converts string (flag name list concat by ',') to OpKind.
type OpObject ¶
type OpObject struct {
Desc string `json:"desc"`
Brief string `json:"brief"`
RegionID uint64 `json:"region_id"`
RegionEpoch *metapb.RegionEpoch `json:"region_epoch"`
Kind OpKind `json:"kind"`
Timeout string `json:"timeout"`
Status OpStatus `json:"status"`
}
OpObject is used to return Operator as a json object for API.
type OpRecord ¶
OpRecord is used to log and visualize completed operators. NOTE: This type is exported by HTTP API. Please pay more attention when modifying it.
func (*OpRecord) MarshalJSON ¶
MarshalJSON returns the status of operator as a JSON string
type OpStatus ¶
type OpStatus = uint32
OpStatus represents the status of an Operator.
const ( // Status list // Just created. Next status: {RUNNING, CANCELED, EXPIRED}. CREATED OpStatus = iota // Started and not finished. Next status: {SUCCESS, CANCELED, REPLACED, TIMEOUT}. STARTED // Followings are end status, i.e. no next status. SUCCESS // Finished successfully CANCELED // Canceled due to some reason REPLACED // Replaced by a higher priority operator EXPIRED // Didn't start to run for too long TIMEOUT // Running for too long )
Status list
type OpStatusTracker ¶
type OpStatusTracker struct {
// contains filtered or unexported fields
}
OpStatusTracker represents the status of an operator.
func NewOpStatusTracker ¶
func NewOpStatusTracker() OpStatusTracker
NewOpStatusTracker creates an OpStatus.
func (*OpStatusTracker) CheckExpired ¶
func (trk *OpStatusTracker) CheckExpired(exp time.Duration) bool
CheckExpired checks if expired, and update the current status.
func (*OpStatusTracker) CheckTimeout ¶
func (trk *OpStatusTracker) CheckTimeout(duration time.Duration) bool
CheckTimeout returns true if timeout, and update the current status.
func (*OpStatusTracker) IsEnd ¶
func (trk *OpStatusTracker) IsEnd() bool
IsEnd checks whether the current status is an end status.
func (*OpStatusTracker) ReachTime ¶
func (trk *OpStatusTracker) ReachTime() time.Time
ReachTime returns the reach time of current status.
func (*OpStatusTracker) ReachTimeOf ¶
func (trk *OpStatusTracker) ReachTimeOf(s OpStatus) time.Time
ReachTimeOf returns the time when reached given status. If didn't reached the given status, return zero.
func (*OpStatusTracker) Status ¶
func (trk *OpStatusTracker) Status() OpStatus
Status returns current status.
func (*OpStatusTracker) String ¶
func (trk *OpStatusTracker) String() string
String implements fmt.Stringer.
func (*OpStatusTracker) To ¶
func (trk *OpStatusTracker) To(dst OpStatus) bool
To transfer the current status to dst if this transition is valid, returns whether transferred.
type OpStep ¶
type OpStep interface {
fmt.Stringer
ConfVerChanged(region *core.RegionInfo) uint64
IsFinish(region *core.RegionInfo) bool
CheckInProgress(ci *core.BasicCluster, config config.SharedConfigProvider, region *core.RegionInfo) error
Influence(opInfluence OpInfluence, region *core.RegionInfo)
Timeout(regionSize int64) time.Duration
GetCmd(region *core.RegionInfo, useConfChangeV2 bool) *hbstream.Operation
}
OpStep describes the basic scheduling steps that can not be subdivided.
type OpWithStatus ¶
type OpWithStatus struct {
*Operator
Status pdpb.OperatorStatus
FinishTime time.Time
}
OpWithStatus records the operator and its status.
func NewOpWithStatus ¶
func NewOpWithStatus(op *Operator) *OpWithStatus
NewOpWithStatus creates an OpWithStatus from an operator.
func (*OpWithStatus) MarshalJSON ¶
func (o *OpWithStatus) MarshalJSON() ([]byte, error)
MarshalJSON returns the status of operator as a JSON string
type Operator ¶
type Operator struct {
Counters []prometheus.Counter
FinishedCounters []prometheus.Counter
ApproximateSize int64
// contains filtered or unexported fields
}
Operator contains execution steps generated by scheduler. NOTE: This type is exported by HTTP API. Please pay more attention when modifying it.
func CreateAddPeerOperator ¶
func CreateAddPeerOperator(desc string, ci sche.SharedCluster, region *core.RegionInfo, peer *metapb.Peer, kind OpKind) (*Operator, error)
CreateAddPeerOperator creates an operator that adds a new peer.
func CreateDemoteLearnerOperatorAndRemovePeer ¶
func CreateDemoteLearnerOperatorAndRemovePeer(desc string, ci sche.SharedCluster, region *core.RegionInfo, toDemote *metapb.Peer, toRemove *metapb.Peer) (*Operator, error)
CreateDemoteLearnerOperatorAndRemovePeer creates an operator that demotes a learner and removes a peer.
func CreateDemoteVoterOperator ¶
func CreateDemoteVoterOperator(desc string, ci sche.SharedCluster, region *core.RegionInfo, peer *metapb.Peer) (*Operator, error)
CreateDemoteVoterOperator creates an operator that demotes a voter
func CreateForceTransferLeaderOperator ¶
func CreateForceTransferLeaderOperator(desc string, ci sche.SharedCluster, region *core.RegionInfo, targetStoreID uint64, kind OpKind) (*Operator, error)
CreateForceTransferLeaderOperator creates an operator that transfers the leader from a source store to a target store forcible.
func CreateLeaveJointStateOperator ¶
func CreateLeaveJointStateOperator(desc string, ci sche.SharedCluster, origin *core.RegionInfo) (*Operator, error)
CreateLeaveJointStateOperator creates an operator that let region leave joint state.
func CreateMergeRegionOperator ¶
func CreateMergeRegionOperator(desc string, ci sche.SharedCluster, source *core.RegionInfo, target *core.RegionInfo, kind OpKind) ([]*Operator, error)
CreateMergeRegionOperator creates an operator that merge two region into one.
func CreateMoveLeaderOperator ¶
func CreateMoveLeaderOperator(desc string, ci sche.SharedCluster, region *core.RegionInfo, kind OpKind, oldStore uint64, peer *metapb.Peer) (*Operator, error)
CreateMoveLeaderOperator creates an operator that replaces an old leader with a new leader.
func CreateMovePeerOperator ¶
func CreateMovePeerOperator(desc string, ci sche.SharedCluster, region *core.RegionInfo, kind OpKind, oldStore uint64, peer *metapb.Peer) (*Operator, error)
CreateMovePeerOperator creates an operator that replaces an old peer with a new peer.
func CreateMoveRegionOperator ¶
func CreateMoveRegionOperator(desc string, ci sche.SharedCluster, region *core.RegionInfo, kind OpKind, roles map[uint64]placement.PeerRoleType) (*Operator, error)
CreateMoveRegionOperator creates an operator that moves a region to specified stores.
func CreateMoveWitnessOperator ¶
func CreateMoveWitnessOperator(desc string, ci sche.SharedCluster, region *core.RegionInfo, sourceStoreID uint64, targetStoreID uint64) (*Operator, error)
CreateMoveWitnessOperator creates an operator that replaces an old witness with a new witness.
func CreateNonWitnessPeerOperator ¶
func CreateNonWitnessPeerOperator(desc string, ci sche.SharedCluster, region *core.RegionInfo, peer *metapb.Peer) (*Operator, error)
CreateNonWitnessPeerOperator creates an operator that set a peer with non-witness
func CreatePromoteLearnerOperator ¶
func CreatePromoteLearnerOperator(desc string, ci sche.SharedCluster, region *core.RegionInfo, peer *metapb.Peer) (*Operator, error)
CreatePromoteLearnerOperator creates an operator that promotes a learner.
func CreatePromoteLearnerOperatorAndRemovePeer ¶
func CreatePromoteLearnerOperatorAndRemovePeer(desc string, ci sche.SharedCluster, region *core.RegionInfo, toPromote *metapb.Peer, toRemove *metapb.Peer) (*Operator, error)
CreatePromoteLearnerOperatorAndRemovePeer creates an operator that promotes a learner and removes a peer.
func CreateRemovePeerOperator ¶
func CreateRemovePeerOperator(desc string, ci sche.SharedCluster, kind OpKind, region *core.RegionInfo, storeID uint64) (*Operator, error)
CreateRemovePeerOperator creates an operator that removes a peer from region.
func CreateReplaceLeaderPeerOperator ¶
func CreateReplaceLeaderPeerOperator(desc string, ci sche.SharedCluster, region *core.RegionInfo, kind OpKind, oldStore uint64, peer *metapb.Peer, leader *metapb.Peer) (*Operator, error)
CreateReplaceLeaderPeerOperator creates an operator that replaces an old peer with a new peer, and move leader from old store firstly.
func CreateScatterRegionOperator ¶
func CreateScatterRegionOperator(desc string, ci sche.SharedCluster, origin *core.RegionInfo, targetPeers map[uint64]*metapb.Peer, targetLeader uint64, skipLimitCheck bool) (*Operator, error)
CreateScatterRegionOperator creates an operator that scatters the specified region.
func CreateSplitRegionOperator ¶
func CreateSplitRegionOperator(desc string, region *core.RegionInfo, kind OpKind, policy pdpb.CheckPolicy, keys [][]byte) (*Operator, error)
CreateSplitRegionOperator creates an operator that splits a region.
func CreateTransferLeaderOperator ¶
func CreateTransferLeaderOperator(desc string, ci sche.SharedCluster, region *core.RegionInfo, targetStoreID uint64, targetStoreIDs []uint64, kind OpKind) (*Operator, error)
CreateTransferLeaderOperator creates an operator that transfers the leader from a source store to a target store.
func CreateWitnessPeerOperator ¶
func CreateWitnessPeerOperator(desc string, ci sche.SharedCluster, region *core.RegionInfo, peer *metapb.Peer) (*Operator, error)
CreateWitnessPeerOperator creates an operator that set a follower or learner peer with witness
func NewOperator ¶
func NewOperator(desc, brief string, regionID uint64, regionEpoch *metapb.RegionEpoch, kind OpKind, approximateSize int64, steps ...OpStep) *Operator
NewOperator creates a new operator.
func NewTestOperator ¶
func NewTestOperator(regionID uint64, regionEpoch *metapb.RegionEpoch, kind OpKind, steps ...OpStep) *Operator
NewTestOperator creates a test operator, only used for unit test.
func (*Operator) AttachKind ¶
AttachKind attaches an operator kind for the operator.
func (*Operator) Cancel ¶
func (o *Operator) Cancel(reason ...CancelReasonType) bool
Cancel marks the operator canceled.
func (*Operator) Check ¶
func (o *Operator) Check(region *core.RegionInfo) OpStep
Check checks if current step is finished, returns next step to take action. If operator is at an end status, check returns nil. It's safe to be called by multiple goroutine concurrently.
func (*Operator) CheckAndGetStatus ¶
CheckAndGetStatus returns operator status after `CheckExpired` and `CheckTimeout`.
func (*Operator) CheckExpired ¶
CheckExpired checks if the operator is expired, and update the status.
func (*Operator) CheckSuccess ¶
CheckSuccess checks if all steps are finished, and update the status.
func (*Operator) CheckTimeout ¶
CheckTimeout returns true if the operator is timeout, and update the status.
func (*Operator) ConfVerChanged ¶
func (o *Operator) ConfVerChanged(region *core.RegionInfo) (total uint64)
ConfVerChanged returns the number of confver has consumed by steps
func (*Operator) ContainNonWitnessStep ¶
ContainNonWitnessStep returns true if it contains the target OpStep
func (*Operator) ElapsedTime ¶
ElapsedTime returns duration since it was created.
func (*Operator) GetAdditionalInfo ¶
GetAdditionalInfo returns additional info with key.
func (*Operator) GetCreateTime ¶
GetCreateTime gets the create time of operator.
func (*Operator) GetPriorityLevel ¶
func (o *Operator) GetPriorityLevel() constant.PriorityLevel
GetPriorityLevel gets the priority level.
func (*Operator) GetReachTimeOf ¶
GetReachTimeOf returns the time when operator reaches the given status.
func (*Operator) GetStartTime ¶
GetStartTime gets the start time of operator.
func (*Operator) HasStarted ¶
HasStarted returns whether operator has started.
func (*Operator) IsLeaveJointStateOperator ¶
IsLeaveJointStateOperator returns true if the desc is OpDescLeaveJointState.
func (*Operator) LogAdditionalInfo ¶
LogAdditionalInfo returns additional info with string
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 started.
func (*Operator) SchedulerKind ¶
SchedulerKind return the highest OpKind even if the operator has many OpKind fix #3778
func (*Operator) SetAdditionalInfo ¶
SetAdditionalInfo sets additional info with key and value.
func (*Operator) SetPriorityLevel ¶
func (o *Operator) SetPriorityLevel(level constant.PriorityLevel)
SetPriorityLevel sets the priority level for operator.
func (*Operator) SetStatusReachTime ¶
SetStatusReachTime sets the reach time of the operator, only for test purpose.
func (*Operator) ToJSONObject ¶
ToJSONObject serializes Operator as JSON object.
func (*Operator) TotalInfluence ¶
func (o *Operator) TotalInfluence(opInfluence OpInfluence, region *core.RegionInfo)
TotalInfluence calculates the store difference which whole operator steps make.
func (*Operator) UnfinishedInfluence ¶
func (o *Operator) UnfinishedInfluence(opInfluence OpInfluence, region *core.RegionInfo)
UnfinishedInfluence calculates the store difference which unfinished operator steps make.
type PromoteLearner ¶
PromoteLearner is an OpStep that promotes a region learner peer to normal voter.
func (PromoteLearner) CheckInProgress ¶
func (pl PromoteLearner) CheckInProgress(_ *core.BasicCluster, _ config.SharedConfigProvider, region *core.RegionInfo) error
CheckInProgress checks if the step is in the progress of advancing.
func (PromoteLearner) ConfVerChanged ¶
func (pl PromoteLearner) ConfVerChanged(region *core.RegionInfo) uint64
ConfVerChanged returns the delta value for version increased by this step. It is also used by ChangePeerV2Leave. Since there are currently four roles, we need to confirm whether it is a Voter, not a DemotingVoter, etc.
func (PromoteLearner) GetCmd ¶
func (pl PromoteLearner) GetCmd(_ *core.RegionInfo, useConfChangeV2 bool) *hbstream.Operation
GetCmd returns the schedule command for heartbeat response.
func (PromoteLearner) Influence ¶
func (PromoteLearner) Influence(OpInfluence, *core.RegionInfo)
Influence calculates the store difference that current step makes.
func (PromoteLearner) IsFinish ¶
func (pl PromoteLearner) IsFinish(region *core.RegionInfo) bool
IsFinish checks if current step is finished. It is also used by ChangePeerV2Leave.
func (PromoteLearner) String ¶
func (pl PromoteLearner) String() string
type RemovePeer ¶
RemovePeer is an OpStep that removes a region peer.
func (RemovePeer) CheckInProgress ¶
func (rp RemovePeer) CheckInProgress(_ *core.BasicCluster, _ config.SharedConfigProvider, region *core.RegionInfo) error
CheckInProgress checks if the step is in the progress of advancing.
func (RemovePeer) ConfVerChanged ¶
func (rp RemovePeer) ConfVerChanged(region *core.RegionInfo) uint64
ConfVerChanged returns the delta value for version increased by this step.
func (RemovePeer) GetCmd ¶
func (rp RemovePeer) GetCmd(region *core.RegionInfo, useConfChangeV2 bool) *hbstream.Operation
GetCmd returns the schedule command for heartbeat response.
func (RemovePeer) Influence ¶
func (rp RemovePeer) Influence(opInfluence OpInfluence, region *core.RegionInfo)
Influence calculates the store difference that current step makes.
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 SplitRegion ¶
type SplitRegion struct {
StartKey, EndKey []byte
Policy pdpb.CheckPolicy
SplitKeys [][]byte
}
SplitRegion is an OpStep that splits a region.
func (SplitRegion) CheckInProgress ¶
func (SplitRegion) CheckInProgress(*core.BasicCluster, config.SharedConfigProvider, *core.RegionInfo) error
CheckInProgress checks if the step is in the progress of advancing.
func (SplitRegion) ConfVerChanged ¶
func (SplitRegion) ConfVerChanged(*core.RegionInfo) uint64
ConfVerChanged returns the delta value for version increased by this step.
func (SplitRegion) GetCmd ¶
func (sr SplitRegion) GetCmd(*core.RegionInfo, bool) *hbstream.Operation
GetCmd returns the schedule command for heartbeat response.
func (SplitRegion) Influence ¶
func (SplitRegion) Influence(opInfluence OpInfluence, region *core.RegionInfo)
Influence calculates the store difference that current step makes.
func (SplitRegion) IsFinish ¶
func (sr SplitRegion) IsFinish(region *core.RegionInfo) bool
IsFinish checks if current step is finished.
func (SplitRegion) String ¶
func (sr SplitRegion) String() string
type StoreInfluence ¶
type StoreInfluence struct {
RegionSize int64
RegionCount int64
LeaderSize int64
LeaderCount int64
WitnessCount int64
StepCost map[storelimit.Type]int64
}
StoreInfluence records influences that pending operators will make.
func (*StoreInfluence) AddStepCost ¶
func (s *StoreInfluence) AddStepCost(limitType storelimit.Type, cost int64)
AddStepCost add cost to the influence.
func (*StoreInfluence) AdjustStepCost ¶
func (s *StoreInfluence) AdjustStepCost(limitType storelimit.Type, regionSize int64)
AdjustStepCost adjusts the step cost of specific type store limit according to region size
func (*StoreInfluence) GetStepCost ¶
func (s *StoreInfluence) GetStepCost(limitType storelimit.Type) int64
GetStepCost returns the specific type step cost
func (*StoreInfluence) ResourceProperty ¶
func (s *StoreInfluence) ResourceProperty(kind constant.ScheduleKind) int64
ResourceProperty returns delta size of leader/region by influence.
type TransferLeader ¶
type TransferLeader struct {
// Compatible with old TiKV's TransferLeader.
FromStore, ToStore uint64
// Multi-target transfer leader.
ToStores []uint64
}
TransferLeader is an OpStep that transfers a region's leader.
func (TransferLeader) CheckInProgress ¶
func (tl TransferLeader) CheckInProgress(ci *core.BasicCluster, config config.SharedConfigProvider, region *core.RegionInfo) error
CheckInProgress checks if the step is in the progress of advancing.
func (TransferLeader) ConfVerChanged ¶
func (TransferLeader) ConfVerChanged(_ *core.RegionInfo) uint64
ConfVerChanged returns the delta value for version increased by this step.
func (TransferLeader) GetCmd ¶
func (tl TransferLeader) GetCmd(region *core.RegionInfo, _ bool) *hbstream.Operation
GetCmd returns the schedule command for heartbeat response.
func (TransferLeader) Influence ¶
func (tl TransferLeader) Influence(opInfluence OpInfluence, region *core.RegionInfo)
Influence calculates the store difference that current step makes.
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