Documentation ¶
Index ¶
- Constants
- func AllowMerge(cluster schedule.Cluster, region, adjacent *core.RegionInfo) bool
- type Controller
- func (c *Controller) AddSuspectKeyRange(start, end []byte)
- func (c *Controller) AddSuspectRegions(regionIDs ...uint64)
- func (c *Controller) AddWaitingRegion(region *core.RegionInfo)
- func (c *Controller) CheckRegion(region *core.RegionInfo) []*operator.Operator
- func (c *Controller) ClearSuspectKeyRanges()
- func (c *Controller) GetMergeChecker() *MergeChecker
- func (c *Controller) GetPauseController(name string) (*PauseController, error)
- func (c *Controller) GetPriorityRegions() []uint64
- func (c *Controller) GetRuleChecker() *RuleChecker
- func (c *Controller) GetSuspectRegions() []uint64
- func (c *Controller) GetWaitingRegions() []*cache.Item
- func (c *Controller) IsPendingRegion(regionID uint64) bool
- func (c *Controller) PopOneSuspectKeyRange() ([2][]byte, bool)
- func (c *Controller) RemovePriorityRegions(id uint64)
- func (c *Controller) RemoveSuspectRegion(id uint64)
- func (c *Controller) RemoveWaitingRegion(id uint64)
- type JointStateChecker
- type LearnerChecker
- type MergeChecker
- type PauseController
- type PriorityInspector
- type RegionPriorityEntry
- type ReplicaChecker
- type ReplicaStrategy
- func (s *ReplicaStrategy) SelectStoreToAdd(coLocationStores []*core.StoreInfo, extraFilters ...filter.Filter) (uint64, bool)
- func (s *ReplicaStrategy) SelectStoreToFix(coLocationStores []*core.StoreInfo, old uint64) (uint64, bool)
- func (s *ReplicaStrategy) SelectStoreToImprove(coLocationStores []*core.StoreInfo, old uint64) (uint64, bool)
- func (s *ReplicaStrategy) SelectStoreToRemove(coLocationStores []*core.StoreInfo) uint64
- type RuleChecker
- type SplitChecker
Constants ¶
const DefaultCacheSize = 1000
DefaultCacheSize is the default length of waiting list.
Variables ¶
This section is empty.
Functions ¶
func AllowMerge ¶
func AllowMerge(cluster schedule.Cluster, region, adjacent *core.RegionInfo) bool
AllowMerge returns true if two regions can be merged according to the key type.
Types ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller is used to manage all checkers.
func NewController ¶
func NewController(ctx context.Context, cluster schedule.Cluster, conf config.Config, ruleManager *placement.RuleManager, labeler *labeler.RegionLabeler, opController *schedule.OperatorController) *Controller
NewController create a new Controller.
func (*Controller) AddSuspectKeyRange ¶
func (c *Controller) AddSuspectKeyRange(start, end []byte)
AddSuspectKeyRange adds the key range with the its ruleID as the key The instance of each keyRange is like following format: [2][]byte: start key/end key
func (*Controller) AddSuspectRegions ¶
func (c *Controller) AddSuspectRegions(regionIDs ...uint64)
AddSuspectRegions adds regions to suspect list.
func (*Controller) AddWaitingRegion ¶
func (c *Controller) AddWaitingRegion(region *core.RegionInfo)
AddWaitingRegion returns the regions in the waiting list.
func (*Controller) CheckRegion ¶
func (c *Controller) CheckRegion(region *core.RegionInfo) []*operator.Operator
CheckRegion will check the region and add a new operator if needed.
func (*Controller) ClearSuspectKeyRanges ¶
func (c *Controller) ClearSuspectKeyRanges()
ClearSuspectKeyRanges clears the suspect keyRanges, only for unit test
func (*Controller) GetMergeChecker ¶
func (c *Controller) GetMergeChecker() *MergeChecker
GetMergeChecker returns the merge checker.
func (*Controller) GetPauseController ¶
func (c *Controller) GetPauseController(name string) (*PauseController, error)
GetPauseController returns pause controller of the checker
func (*Controller) GetPriorityRegions ¶
func (c *Controller) GetPriorityRegions() []uint64
GetPriorityRegions returns the region in priority queue
func (*Controller) GetRuleChecker ¶
func (c *Controller) GetRuleChecker() *RuleChecker
GetRuleChecker returns the rule checker.
func (*Controller) GetSuspectRegions ¶
func (c *Controller) GetSuspectRegions() []uint64
GetSuspectRegions gets all suspect regions.
func (*Controller) GetWaitingRegions ¶
func (c *Controller) GetWaitingRegions() []*cache.Item
GetWaitingRegions returns the regions in the waiting list.
func (*Controller) IsPendingRegion ¶
func (c *Controller) IsPendingRegion(regionID uint64) bool
IsPendingRegion returns true if the given region is in the pending list.
func (*Controller) PopOneSuspectKeyRange ¶
func (c *Controller) PopOneSuspectKeyRange() ([2][]byte, bool)
PopOneSuspectKeyRange gets one suspect keyRange group. it would return value and true if pop success, or return empty [][2][]byte and false if suspectKeyRanges couldn't pop keyRange group.
func (*Controller) RemovePriorityRegions ¶
func (c *Controller) RemovePriorityRegions(id uint64)
RemovePriorityRegions removes priority region from priority queue
func (*Controller) RemoveSuspectRegion ¶
func (c *Controller) RemoveSuspectRegion(id uint64)
RemoveSuspectRegion removes region from suspect list.
func (*Controller) RemoveWaitingRegion ¶
func (c *Controller) RemoveWaitingRegion(id uint64)
RemoveWaitingRegion removes the region from the waiting list.
type JointStateChecker ¶
type JointStateChecker struct { PauseController // contains filtered or unexported fields }
JointStateChecker ensures region is in joint state will leave.
func NewJointStateChecker ¶
func NewJointStateChecker(cluster schedule.Cluster) *JointStateChecker
NewJointStateChecker creates a joint state checker.
func (*JointStateChecker) Check ¶
func (c *JointStateChecker) Check(region *core.RegionInfo) *operator.Operator
Check verifies a region's role, creating an Operator if need.
type LearnerChecker ¶
type LearnerChecker struct { PauseController // contains filtered or unexported fields }
LearnerChecker ensures region has a learner will be promoted.
func NewLearnerChecker ¶
func NewLearnerChecker(cluster schedule.Cluster) *LearnerChecker
NewLearnerChecker creates a learner checker.
func (*LearnerChecker) Check ¶
func (l *LearnerChecker) Check(region *core.RegionInfo) *operator.Operator
Check verifies a region's role, creating an Operator if need.
type MergeChecker ¶
type MergeChecker struct { PauseController // contains filtered or unexported fields }
MergeChecker ensures region to merge with adjacent region when size is small
func NewMergeChecker ¶
func NewMergeChecker(ctx context.Context, cluster schedule.Cluster, conf config.Config) *MergeChecker
NewMergeChecker creates a merge checker.
func (*MergeChecker) Check ¶
func (m *MergeChecker) Check(region *core.RegionInfo) []*operator.Operator
Check verifies a region's replicas, creating an Operator if need.
func (*MergeChecker) GetType ¶
func (m *MergeChecker) GetType() string
GetType return MergeChecker's type
func (*MergeChecker) RecordRegionSplit ¶
func (m *MergeChecker) RecordRegionSplit(regionIDs []uint64)
RecordRegionSplit put the recently split region into cache. MergeChecker will skip check it for a while.
type PauseController ¶
type PauseController struct {
// contains filtered or unexported fields
}
PauseController sets and stores delay time in checkers.
func (*PauseController) IsPaused ¶
func (c *PauseController) IsPaused() bool
IsPaused check if checker is paused
func (*PauseController) PauseOrResume ¶
func (c *PauseController) PauseOrResume(t int64)
PauseOrResume pause or resume the checker
type PriorityInspector ¶
type PriorityInspector struct {
// contains filtered or unexported fields
}
PriorityInspector ensures high priority region should run first
func NewPriorityInspector ¶
func NewPriorityInspector(cluster schedule.Cluster, conf config.Config) *PriorityInspector
NewPriorityInspector creates a priority inspector.
func (*PriorityInspector) GetPriorityRegions ¶
func (p *PriorityInspector) GetPriorityRegions() (ids []uint64)
GetPriorityRegions returns all regions in priority queue that needs rerun
func (*PriorityInspector) Inspect ¶
func (p *PriorityInspector) Inspect(region *core.RegionInfo) (fit *placement.RegionFit)
Inspect inspects region's replicas, it will put into priority queue if the region lack of replicas.
func (*PriorityInspector) RemovePriorityRegion ¶
func (p *PriorityInspector) RemovePriorityRegion(regionID uint64)
RemovePriorityRegion removes priority region from priority queue
type RegionPriorityEntry ¶
type RegionPriorityEntry struct { Attempt int Last time.Time // contains filtered or unexported fields }
RegionPriorityEntry records region priority info
func NewRegionEntry ¶
func NewRegionEntry(regionID uint64) *RegionPriorityEntry
NewRegionEntry construct of region priority entry
func (RegionPriorityEntry) ID ¶
func (r RegionPriorityEntry) ID() uint64
ID implement PriorityQueueItem interface
type ReplicaChecker ¶
type ReplicaChecker struct { PauseController // contains filtered or unexported fields }
ReplicaChecker ensures region has the best replicas. Including the following: Replica number management. Unhealthy replica management, mainly used for disaster recovery of TiKV. Location management, mainly used for cross data center deployment.
func NewReplicaChecker ¶
func NewReplicaChecker(cluster schedule.Cluster, conf config.Config, regionWaitingList cache.Cache) *ReplicaChecker
NewReplicaChecker creates a replica checker.
func (*ReplicaChecker) Check ¶
func (r *ReplicaChecker) Check(region *core.RegionInfo) *operator.Operator
Check verifies a region's replicas, creating an operator.Operator if need.
func (*ReplicaChecker) GetType ¶
func (r *ReplicaChecker) GetType() string
GetType return ReplicaChecker's type
type ReplicaStrategy ¶
type ReplicaStrategy struct {
// contains filtered or unexported fields
}
ReplicaStrategy collects some utilities to manipulate region peers. It exists to allow replica_checker and rule_checker to reuse common logics.
func (*ReplicaStrategy) SelectStoreToAdd ¶
func (s *ReplicaStrategy) SelectStoreToAdd(coLocationStores []*core.StoreInfo, extraFilters ...filter.Filter) (uint64, bool)
SelectStoreToAdd returns the store to add a replica to a region. `coLocationStores` are the stores used to compare location with target store. `extraFilters` is used to set up more filters based on the context that calling this method.
For example, to select a target store to replace a region's peer, we can use the peer list with the peer removed as `coLocationStores`. Meanwhile, we need to provide more constraints to ensure that the isolation level cannot be reduced after replacement.
func (*ReplicaStrategy) SelectStoreToFix ¶
func (s *ReplicaStrategy) SelectStoreToFix(coLocationStores []*core.StoreInfo, old uint64) (uint64, bool)
SelectStoreToFix returns a store to replace down/offline old peer. The location placement after scheduling is allowed to be worse than original.
func (*ReplicaStrategy) SelectStoreToImprove ¶
func (s *ReplicaStrategy) SelectStoreToImprove(coLocationStores []*core.StoreInfo, old uint64) (uint64, bool)
SelectStoreToImprove returns a store to replace oldStore. The location placement after scheduling should be better than original.
func (*ReplicaStrategy) SelectStoreToRemove ¶
func (s *ReplicaStrategy) SelectStoreToRemove(coLocationStores []*core.StoreInfo) uint64
SelectStoreToRemove returns the best option to remove from the region.
type RuleChecker ¶
type RuleChecker struct { PauseController // contains filtered or unexported fields }
RuleChecker fix/improve region by placement rules.
func NewRuleChecker ¶
func NewRuleChecker(ctx context.Context, cluster schedule.Cluster, ruleManager *placement.RuleManager, regionWaitingList cache.Cache) *RuleChecker
NewRuleChecker creates a checker instance.
func (*RuleChecker) Check ¶
func (c *RuleChecker) Check(region *core.RegionInfo) *operator.Operator
Check checks if the region matches placement rules and returns Operator to fix it.
func (*RuleChecker) CheckWithFit ¶
func (c *RuleChecker) CheckWithFit(region *core.RegionInfo, fit *placement.RegionFit) (op *operator.Operator)
CheckWithFit is similar with Checker with placement.RegionFit
func (*RuleChecker) GetType ¶
func (c *RuleChecker) GetType() string
GetType returns RuleChecker's Type
func (*RuleChecker) RecordRegionPromoteToNonWitness ¶
func (c *RuleChecker) RecordRegionPromoteToNonWitness(regionID uint64)
RecordRegionPromoteToNonWitness put the recently switch non-witness region into cache. RuleChecker will skip switch it back to witness for a while.
type SplitChecker ¶
type SplitChecker struct { PauseController // contains filtered or unexported fields }
SplitChecker splits regions when the key range spans across rule/label boundary.
func NewSplitChecker ¶
func NewSplitChecker(cluster schedule.Cluster, ruleManager *placement.RuleManager, labeler *labeler.RegionLabeler) *SplitChecker
NewSplitChecker creates a new SplitChecker.
func (*SplitChecker) Check ¶
func (c *SplitChecker) Check(region *core.RegionInfo) *operator.Operator
Check checks whether the region need to split and returns Operator to fix.
func (*SplitChecker) GetType ¶
func (c *SplitChecker) GetType() string
GetType returns the checker type.