Documentation ¶
Index ¶
- type Cluster
- func (mc *Cluster) AddLabelsStore(storeID uint64, regionCount int, labels map[string]string)
- func (mc *Cluster) AddLabersStoreWithLearnerCount(storeID uint64, regionCount int, learnerCount int, labels map[string]string)
- func (mc *Cluster) AddLeaderRegion(regionID uint64, leaderStoreID uint64, otherPeerStoreIDs ...uint64) *core.RegionInfo
- func (mc *Cluster) AddLeaderRegionWithRange(regionID uint64, startKey string, endKey string, leaderStoreID uint64, ...)
- func (mc *Cluster) AddLeaderRegionWithWitness(regionID uint64, leaderStoreID uint64, otherPeerStoreIDs []uint64, ...) *core.RegionInfo
- func (mc *Cluster) AddLeaderRegionWithWriteInfo(regionID uint64, leaderStoreID uint64, ...) []*statistics.HotPeerStat
- func (mc *Cluster) AddLeaderStore(storeID uint64, leaderCount int, leaderSizes ...int64)
- func (mc *Cluster) AddLightWeightLeaderRegion(regionID uint64, leaderStoreID uint64, otherPeerStoreIDs ...uint64) *core.RegionInfo
- func (mc *Cluster) AddNoLeaderRegion(regionID uint64, otherPeerStoreIDs ...uint64) *core.RegionInfo
- func (mc *Cluster) AddRegionLeaderWithReadInfo(regionID uint64, leaderStoreID uint64, readBytes, readKeys, readQuery uint64, ...) []*statistics.HotPeerStat
- func (mc *Cluster) AddRegionStore(storeID uint64, regionCount int)
- func (mc *Cluster) AddRegionStoreWithLeader(storeID uint64, regionCount int, leaderCounts ...int)
- func (mc *Cluster) AddRegionWithLearner(regionID uint64, leaderStoreID uint64, ...) *core.RegionInfo
- func (mc *Cluster) AddRegionWithPeerReadInfo(...) []*statistics.HotPeerStat
- func (mc *Cluster) AddRegionWithReadInfo(regionID uint64, leaderStoreID uint64, readBytes, readKeys, readQuery uint64, ...) []*statistics.HotPeerStat
- func (mc *Cluster) AddSuspectRegions(ids ...uint64)
- func (mc *Cluster) AddWitnessStore(storeID uint64, witnessCount int)
- func (mc *Cluster) AllocPeer(storeID uint64) (*metapb.Peer, error)
- func (mc *Cluster) BucketsStats(degree int, regions ...uint64) map[uint64][]*buckets.BucketStat
- func (mc *Cluster) CheckLabelProperty(typ string, labels []*metapb.StoreLabel) bool
- func (mc *Cluster) CheckRegionLeaderRead(region *core.RegionInfo) []*statistics.HotPeerStat
- func (mc *Cluster) CheckRegionRead(region *core.RegionInfo) []*statistics.HotPeerStat
- func (mc *Cluster) CheckRegionUnderSuspect(id uint64) bool
- func (mc *Cluster) CheckRegionWrite(region *core.RegionInfo) []*statistics.HotPeerStat
- func (mc *Cluster) GetAllocator() id.Allocator
- func (mc *Cluster) GetBasicCluster() *core.BasicCluster
- func (mc *Cluster) GetHotPeerStat(rw statistics.RWType, regionID, storeID uint64) *statistics.HotPeerStat
- func (mc *Cluster) GetOpts() sc.Config
- func (mc *Cluster) GetRegionByKey(regionKey []byte) *core.RegionInfo
- func (mc *Cluster) GetRegionLabeler() *labeler.RegionLabeler
- func (mc *Cluster) GetRuleManager() *placement.RuleManager
- func (mc *Cluster) GetStore(storeID uint64) *core.StoreInfo
- func (mc *Cluster) GetStoreConfig() sc.StoreConfig
- func (mc *Cluster) GetStoresLoads() map[uint64][]float64
- func (mc *Cluster) HotRegionsFromStore(store uint64, kind statistics.RWType) []*core.RegionInfo
- func (mc *Cluster) IsRegionHot(region *core.RegionInfo) bool
- func (mc *Cluster) LoadRegion(regionID uint64, peerStoreIDs ...uint64)
- func (mc *Cluster) MockRegionInfo(regionID uint64, leaderStoreID uint64, ...) *core.RegionInfo
- func (mc *Cluster) ObserveRegionsStats()
- func (mc *Cluster) PutRegionStores(id uint64, stores ...uint64)
- func (mc *Cluster) PutStoreWithLabels(id uint64, labelPairs ...string)
- func (mc *Cluster) RecordOpStepWithTTL(regionID uint64)
- func (mc *Cluster) RegionReadStats() map[uint64][]*statistics.HotPeerStat
- func (mc *Cluster) RegionWriteStats() map[uint64][]*statistics.HotPeerStat
- func (mc *Cluster) RemoveScheduler(name string) error
- func (mc *Cluster) ResetSuspectRegions()
- func (mc *Cluster) ScanRegions(startKey, endKey []byte, limit int) []*core.RegionInfo
- func (mc *Cluster) SetEnableLocationReplacement(v bool)
- func (mc *Cluster) SetEnableMakeUpReplica(v bool)
- func (mc *Cluster) SetEnableOneWayMerge(v bool)
- func (mc *Cluster) SetEnablePlacementRules(v bool)
- func (mc *Cluster) SetEnableRemoveDownReplica(v bool)
- func (mc *Cluster) SetEnableRemoveExtraReplica(v bool)
- func (mc *Cluster) SetEnableReplaceOfflineReplica(v bool)
- func (mc *Cluster) SetHotPendingInfluenceMetrics(storeLabel, rwTy, dim string, load float64)
- func (mc *Cluster) SetHotRegionCacheHitsThreshold(v int)
- func (mc *Cluster) SetHotRegionScheduleLimit(v int)
- func (mc *Cluster) SetIsolationLevel(v string)
- func (mc *Cluster) SetLeaderScheduleLimit(v int)
- func (mc *Cluster) SetLeaderSchedulePolicy(v string)
- func (mc *Cluster) SetLocationLabels(v []string)
- func (mc *Cluster) SetMaxMergeRegionKeys(v int)
- func (mc *Cluster) SetMaxMergeRegionSize(v int)
- func (mc *Cluster) SetMaxReplicas(v int)
- func (mc *Cluster) SetMaxReplicasWithLabel(enablePlacementRules bool, num int, labels ...string)
- func (mc *Cluster) SetMaxSnapshotCount(v int)
- func (mc *Cluster) SetMergeScheduleLimit(v int)
- func (mc *Cluster) SetRegionMaxSize(v string)
- func (mc *Cluster) SetRegionScheduleLimit(v int)
- func (mc *Cluster) SetRegionScoreFormulaVersion(v string)
- func (mc *Cluster) SetRegionSizeMB(v uint64)
- func (mc *Cluster) SetSplitMergeInterval(v time.Duration)
- func (mc *Cluster) SetStoreBusy(storeID uint64, busy bool)
- func (mc *Cluster) SetStoreDisconnect(storeID uint64)
- func (mc *Cluster) SetStoreDown(storeID uint64)
- func (mc *Cluster) SetStoreEvictLeader(storeID uint64, enableEvictLeader bool)
- func (mc *Cluster) SetStoreLabel(storeID uint64, labels map[string]string)
- func (mc *Cluster) SetStoreLastHeartbeatInterval(storeID uint64, interval time.Duration)
- func (mc *Cluster) SetStoreOffline(storeID uint64)
- func (mc *Cluster) SetStoreUp(storeID uint64)
- func (mc *Cluster) SetTolerantSizeRatio(v float64)
- func (mc *Cluster) UpdateLeaderCount(storeID uint64, leaderCount int)
- func (mc *Cluster) UpdatePendingPeerCount(storeID uint64, pendingPeerCount int)
- func (mc *Cluster) UpdateRegionCount(storeID uint64, regionCount int)
- func (mc *Cluster) UpdateSnapshotCount(storeID uint64, snapshotCount int)
- func (mc *Cluster) UpdateStorageRatio(storeID uint64, usedRatio, availableRatio float64)
- func (mc *Cluster) UpdateStorageReadBytes(storeID uint64, bytesRead uint64)
- func (mc *Cluster) UpdateStorageReadKeys(storeID uint64, keysRead uint64)
- func (mc *Cluster) UpdateStorageReadQuery(storeID uint64, queryRead uint64)
- func (mc *Cluster) UpdateStorageReadStats(storeID, bytesRead, keysRead uint64)
- func (mc *Cluster) UpdateStorageWriteQuery(storeID uint64, queryWrite uint64)
- func (mc *Cluster) UpdateStorageWrittenBytes(storeID uint64, bytesWritten uint64)
- func (mc *Cluster) UpdateStorageWrittenKeys(storeID uint64, keysWritten uint64)
- func (mc *Cluster) UpdateStorageWrittenStats(storeID, bytesWritten, keysWritten uint64)
- func (mc *Cluster) UpdateStoreLeaderSize(storeID uint64, size int64)
- func (mc *Cluster) UpdateStoreLeaderWeight(storeID uint64, weight float64)
- func (mc *Cluster) UpdateStoreRegionSize(storeID uint64, size int64)
- func (mc *Cluster) UpdateStoreRegionWeight(storeID uint64, weight float64)
- func (mc *Cluster) UpdateStoreStatus(id uint64)
- func (mc *Cluster) UpdateWitnessCount(storeID uint64, witnessCount int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cluster ¶
type Cluster struct { *core.BasicCluster *mockid.IDAllocator *placement.RuleManager *labeler.RegionLabeler *statistics.HotStat *config.PersistOptions ID uint64 *config.StoreConfigManager *buckets.HotBucketCache // contains filtered or unexported fields }
Cluster is used to mock a cluster for test purpose.
func NewCluster ¶
func NewCluster(ctx context.Context, opts *config.PersistOptions) *Cluster
NewCluster creates a new Cluster
func (*Cluster) AddLabelsStore ¶
AddLabelsStore adds store with specified count of region and labels.
func (*Cluster) AddLabersStoreWithLearnerCount ¶
func (mc *Cluster) AddLabersStoreWithLearnerCount(storeID uint64, regionCount int, learnerCount int, labels map[string]string)
AddLabersStoreWithLearnerCount adds store with specified count of region, learner and labels.
func (*Cluster) AddLeaderRegion ¶
func (mc *Cluster) AddLeaderRegion(regionID uint64, leaderStoreID uint64, otherPeerStoreIDs ...uint64) *core.RegionInfo
AddLeaderRegion adds region with specified leader and followers.
func (*Cluster) AddLeaderRegionWithRange ¶
func (mc *Cluster) AddLeaderRegionWithRange(regionID uint64, startKey string, endKey string, leaderStoreID uint64, otherPeerStoreIDs ...uint64)
AddLeaderRegionWithRange adds region with specified leader, followers and key range.
func (*Cluster) AddLeaderRegionWithWitness ¶
func (mc *Cluster) AddLeaderRegionWithWitness(regionID uint64, leaderStoreID uint64, otherPeerStoreIDs []uint64, witnessStoreID uint64) *core.RegionInfo
AddLeaderRegionWithWitness adds region with specified leader and followers and witness.
func (*Cluster) AddLeaderRegionWithWriteInfo ¶
func (mc *Cluster) AddLeaderRegionWithWriteInfo( regionID uint64, leaderStoreID uint64, writtenBytes, writtenKeys, writtenQuery uint64, reportInterval uint64, otherPeerStoreIDs []uint64, filledNums ...int) []*statistics.HotPeerStat
AddLeaderRegionWithWriteInfo adds region with specified leader and peers write info.
func (*Cluster) AddLeaderStore ¶
AddLeaderStore adds store with specified count of leader.
func (*Cluster) AddLightWeightLeaderRegion ¶
func (mc *Cluster) AddLightWeightLeaderRegion(regionID uint64, leaderStoreID uint64, otherPeerStoreIDs ...uint64) *core.RegionInfo
AddLightWeightLeaderRegion adds a light-wight region with specified leader and followers.
func (*Cluster) AddNoLeaderRegion ¶
func (mc *Cluster) AddNoLeaderRegion(regionID uint64, otherPeerStoreIDs ...uint64) *core.RegionInfo
AddNoLeaderRegion adds region with specified replicas, no leader.
func (*Cluster) AddRegionLeaderWithReadInfo ¶
func (mc *Cluster) AddRegionLeaderWithReadInfo( regionID uint64, leaderStoreID uint64, readBytes, readKeys, readQuery uint64, reportInterval uint64, otherPeerStoreIDs []uint64, filledNums ...int) []*statistics.HotPeerStat
AddRegionLeaderWithReadInfo add region leader read info
func (*Cluster) AddRegionStore ¶
AddRegionStore adds store with specified count of region.
func (*Cluster) AddRegionStoreWithLeader ¶
AddRegionStoreWithLeader adds store with specified count of region and leader.
func (*Cluster) AddRegionWithLearner ¶
func (mc *Cluster) AddRegionWithLearner(regionID uint64, leaderStoreID uint64, followerStoreIDs, learnerStoreIDs []uint64) *core.RegionInfo
AddRegionWithLearner adds region with specified leader, followers and learners.
func (*Cluster) AddRegionWithPeerReadInfo ¶
func (mc *Cluster) AddRegionWithPeerReadInfo(regionID, leaderStoreID, targetStoreID, readBytes, readKeys, reportInterval uint64, otherPeerStoreIDs []uint64, filledNums ...int) []*statistics.HotPeerStat
AddRegionWithPeerReadInfo adds region with specified peer read info.
func (*Cluster) AddRegionWithReadInfo ¶
func (mc *Cluster) AddRegionWithReadInfo( regionID uint64, leaderStoreID uint64, readBytes, readKeys, readQuery uint64, reportInterval uint64, otherPeerStoreIDs []uint64, filledNums ...int) []*statistics.HotPeerStat
AddRegionWithReadInfo adds region with specified leader, followers and read info.
func (*Cluster) AddSuspectRegions ¶
AddSuspectRegions mock method
func (*Cluster) AddWitnessStore ¶
AddWitnessStore adds store with specified count of witness.
func (*Cluster) BucketsStats ¶
BucketsStats returns hot region's buckets stats.
func (*Cluster) CheckLabelProperty ¶
func (mc *Cluster) CheckLabelProperty(typ string, labels []*metapb.StoreLabel) bool
CheckLabelProperty checks label property.
func (*Cluster) CheckRegionLeaderRead ¶
func (mc *Cluster) CheckRegionLeaderRead(region *core.RegionInfo) []*statistics.HotPeerStat
CheckRegionLeaderRead checks region read info with leader peer
func (*Cluster) CheckRegionRead ¶
func (mc *Cluster) CheckRegionRead(region *core.RegionInfo) []*statistics.HotPeerStat
CheckRegionRead checks region read info with all peers
func (*Cluster) CheckRegionUnderSuspect ¶
CheckRegionUnderSuspect only used for unit test
func (*Cluster) CheckRegionWrite ¶
func (mc *Cluster) CheckRegionWrite(region *core.RegionInfo) []*statistics.HotPeerStat
CheckRegionWrite checks region write info with all peers
func (*Cluster) GetAllocator ¶
GetAllocator returns the ID allocator.
func (*Cluster) GetBasicCluster ¶
func (mc *Cluster) GetBasicCluster() *core.BasicCluster
GetBasicCluster mock method
func (*Cluster) GetHotPeerStat ¶
func (mc *Cluster) GetHotPeerStat(rw statistics.RWType, regionID, storeID uint64) *statistics.HotPeerStat
GetHotPeerStat returns hot peer stat with specified regionID and storeID.
func (*Cluster) GetRegionByKey ¶
func (mc *Cluster) GetRegionByKey(regionKey []byte) *core.RegionInfo
GetRegionByKey get region by key
func (*Cluster) GetRegionLabeler ¶
func (mc *Cluster) GetRegionLabeler() *labeler.RegionLabeler
GetRegionLabeler returns the region labeler of the cluster.
func (*Cluster) GetRuleManager ¶
func (mc *Cluster) GetRuleManager() *placement.RuleManager
GetRuleManager returns the ruleManager of the cluster.
func (*Cluster) GetStoreConfig ¶
func (mc *Cluster) GetStoreConfig() sc.StoreConfig
GetStoreConfig returns the store config.
func (*Cluster) GetStoresLoads ¶
GetStoresLoads gets stores load statistics.
func (*Cluster) HotRegionsFromStore ¶
func (mc *Cluster) HotRegionsFromStore(store uint64, kind statistics.RWType) []*core.RegionInfo
HotRegionsFromStore picks hot regions in specify store.
func (*Cluster) IsRegionHot ¶
func (mc *Cluster) IsRegionHot(region *core.RegionInfo) bool
IsRegionHot checks if the region is hot.
func (*Cluster) LoadRegion ¶
LoadRegion puts region info without leader
func (*Cluster) MockRegionInfo ¶
func (mc *Cluster) MockRegionInfo(regionID uint64, leaderStoreID uint64, followerStoreIDs, learnerStoreIDs []uint64, epoch *metapb.RegionEpoch) *core.RegionInfo
MockRegionInfo returns a mock region If leaderStoreID is zero, the regions would have no leader
func (*Cluster) ObserveRegionsStats ¶
func (mc *Cluster) ObserveRegionsStats()
ObserveRegionsStats records the current stores stats from region stats.
func (*Cluster) PutRegionStores ¶
PutRegionStores mocks method.
func (*Cluster) PutStoreWithLabels ¶
PutStoreWithLabels mocks method.
func (*Cluster) RecordOpStepWithTTL ¶
RecordOpStepWithTTL records OpStep with TTL
func (*Cluster) RegionReadStats ¶
func (mc *Cluster) RegionReadStats() map[uint64][]*statistics.HotPeerStat
RegionReadStats returns hot region's read stats. The result only includes peers that are hot enough.
func (*Cluster) RegionWriteStats ¶
func (mc *Cluster) RegionWriteStats() map[uint64][]*statistics.HotPeerStat
RegionWriteStats returns hot region's write stats. The result only includes peers that are hot enough.
func (*Cluster) RemoveScheduler ¶
RemoveScheduler mocks method.
func (*Cluster) ResetSuspectRegions ¶
func (mc *Cluster) ResetSuspectRegions()
ResetSuspectRegions only used for unit test
func (*Cluster) ScanRegions ¶
func (mc *Cluster) ScanRegions(startKey, endKey []byte, limit int) []*core.RegionInfo
ScanRegions scans region with start key, until number greater than limit.
func (*Cluster) SetEnableLocationReplacement ¶
SetEnableLocationReplacement updates the EnableLocationReplacement configuration.
func (*Cluster) SetEnableMakeUpReplica ¶
SetEnableMakeUpReplica updates the EnableMakeUpReplica configuration.
func (*Cluster) SetEnableOneWayMerge ¶
SetEnableOneWayMerge updates the EnableOneWayMerge configuration.
func (*Cluster) SetEnablePlacementRules ¶
SetEnablePlacementRules updates the EnablePlacementRules configuration.
func (*Cluster) SetEnableRemoveDownReplica ¶
SetEnableRemoveDownReplica updates the EnableRemoveDownReplica configuration.
func (*Cluster) SetEnableRemoveExtraReplica ¶
SetEnableRemoveExtraReplica updates the EnableRemoveExtraReplica configuration.
func (*Cluster) SetEnableReplaceOfflineReplica ¶
SetEnableReplaceOfflineReplica updates the EnableReplaceOfflineReplica configuration.
func (*Cluster) SetHotPendingInfluenceMetrics ¶
SetHotPendingInfluenceMetrics mock method
func (*Cluster) SetHotRegionCacheHitsThreshold ¶
SetHotRegionCacheHitsThreshold updates the HotRegionCacheHitsThreshold configuration.
func (*Cluster) SetHotRegionScheduleLimit ¶
SetHotRegionScheduleLimit updates the HotRegionScheduleLimit configuration.
func (*Cluster) SetIsolationLevel ¶
SetIsolationLevel updates the IsolationLevel configuration.
func (*Cluster) SetLeaderScheduleLimit ¶
SetLeaderScheduleLimit updates the LeaderScheduleLimit configuration.
func (*Cluster) SetLeaderSchedulePolicy ¶
SetLeaderSchedulePolicy updates the LeaderSchedulePolicy configuration.
func (*Cluster) SetLocationLabels ¶
SetLocationLabels updates the LocationLabels configuration.
func (*Cluster) SetMaxMergeRegionKeys ¶
SetMaxMergeRegionKeys updates the MaxMergeRegionKeys configuration.
func (*Cluster) SetMaxMergeRegionSize ¶
SetMaxMergeRegionSize updates the MaxMergeRegionSize configuration.
func (*Cluster) SetMaxReplicas ¶
SetMaxReplicas updates the maxReplicas configuration.
func (*Cluster) SetMaxReplicasWithLabel ¶
SetMaxReplicasWithLabel sets the max replicas for the cluster in two ways.
func (*Cluster) SetMaxSnapshotCount ¶
SetMaxSnapshotCount updates the MaxSnapshotCount configuration.
func (*Cluster) SetMergeScheduleLimit ¶
SetMergeScheduleLimit updates the MergeScheduleLimit configuration.
func (*Cluster) SetRegionMaxSize ¶
SetRegionMaxSize sets the region max size.
func (*Cluster) SetRegionScheduleLimit ¶
SetRegionScheduleLimit updates the RegionScheduleLimit configuration.
func (*Cluster) SetRegionScoreFormulaVersion ¶
SetRegionScoreFormulaVersion updates the RegionScoreFormulaVersion configuration.
func (*Cluster) SetRegionSizeMB ¶
SetRegionSizeMB sets the region max size.
func (*Cluster) SetSplitMergeInterval ¶
SetSplitMergeInterval updates the SplitMergeInterval configuration.
func (*Cluster) SetStoreBusy ¶
SetStoreBusy sets store busy.
func (*Cluster) SetStoreDisconnect ¶
SetStoreDisconnect changes a store's state to disconnected.
func (*Cluster) SetStoreDown ¶
SetStoreDown sets store down.
func (*Cluster) SetStoreEvictLeader ¶
SetStoreEvictLeader set store whether evict leader.
func (*Cluster) SetStoreLabel ¶
SetStoreLabel set the labels to the target store
func (*Cluster) SetStoreLastHeartbeatInterval ¶
SetStoreLastHeartbeatInterval set the last heartbeat to the target store
func (*Cluster) SetStoreOffline ¶
SetStoreOffline sets store state to be offline.
func (*Cluster) SetStoreUp ¶
SetStoreUp sets store state to be up.
func (*Cluster) SetTolerantSizeRatio ¶
SetTolerantSizeRatio updates the TolerantSizeRatio configuration.
func (*Cluster) UpdateLeaderCount ¶
UpdateLeaderCount updates store leader count.
func (*Cluster) UpdatePendingPeerCount ¶
UpdatePendingPeerCount updates store pending peer count.
func (*Cluster) UpdateRegionCount ¶
UpdateRegionCount updates store region count.
func (*Cluster) UpdateSnapshotCount ¶
UpdateSnapshotCount updates store snapshot count.
func (*Cluster) UpdateStorageRatio ¶
UpdateStorageRatio updates store storage ratio count.
func (*Cluster) UpdateStorageReadBytes ¶
UpdateStorageReadBytes updates store read bytes.
func (*Cluster) UpdateStorageReadKeys ¶
UpdateStorageReadKeys updates store read bytes.
func (*Cluster) UpdateStorageReadQuery ¶
UpdateStorageReadQuery updates store read query.
func (*Cluster) UpdateStorageReadStats ¶
UpdateStorageReadStats updates store written bytes.
func (*Cluster) UpdateStorageWriteQuery ¶
UpdateStorageWriteQuery updates store write query.
func (*Cluster) UpdateStorageWrittenBytes ¶
UpdateStorageWrittenBytes updates store written bytes.
func (*Cluster) UpdateStorageWrittenKeys ¶
UpdateStorageWrittenKeys updates store written keys.
func (*Cluster) UpdateStorageWrittenStats ¶
UpdateStorageWrittenStats updates store written bytes.
func (*Cluster) UpdateStoreLeaderSize ¶
UpdateStoreLeaderSize updates store leader size.
func (*Cluster) UpdateStoreLeaderWeight ¶
UpdateStoreLeaderWeight updates store leader weight.
func (*Cluster) UpdateStoreRegionSize ¶
UpdateStoreRegionSize updates store region size.
func (*Cluster) UpdateStoreRegionWeight ¶
UpdateStoreRegionWeight updates store region weight.
func (*Cluster) UpdateStoreStatus ¶
UpdateStoreStatus updates store status.
func (*Cluster) UpdateWitnessCount ¶
UpdateWitnessCount updates store witness count.