mockcluster

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cluster

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

func (mc *Cluster) AddLabelsStore(storeID uint64, regionCount int, labels map[string]string)

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

func (mc *Cluster) AddLeaderStore(storeID uint64, leaderCount int, leaderSizes ...int64)

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

func (mc *Cluster) AddRegionStore(storeID uint64, regionCount int)

AddRegionStore adds store with specified count of region.

func (*Cluster) AddRegionStoreWithLeader

func (mc *Cluster) AddRegionStoreWithLeader(storeID uint64, regionCount int, leaderCounts ...int)

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

func (mc *Cluster) AddSuspectRegions(ids ...uint64)

AddSuspectRegions mock method

func (*Cluster) AddWitnessStore

func (mc *Cluster) AddWitnessStore(storeID uint64, witnessCount int)

AddWitnessStore adds store with specified count of witness.

func (*Cluster) AllocPeer

func (mc *Cluster) AllocPeer(storeID uint64) (*metapb.Peer, error)

AllocPeer allocs a new peer on a store.

func (*Cluster) BucketsStats

func (mc *Cluster) BucketsStats(degree int, regions ...uint64) map[uint64][]*buckets.BucketStat

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

func (mc *Cluster) CheckRegionUnderSuspect(id uint64) bool

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

func (mc *Cluster) GetAllocator() id.Allocator

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) GetOpts

func (mc *Cluster) GetOpts() sc.Config

GetOpts returns the cluster configuration.

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) GetStore

func (mc *Cluster) GetStore(storeID uint64) *core.StoreInfo

GetStore gets a store with a given store ID.

func (*Cluster) GetStoreConfig

func (mc *Cluster) GetStoreConfig() sc.StoreConfig

GetStoreConfig returns the store config.

func (*Cluster) GetStoresLoads

func (mc *Cluster) GetStoresLoads() map[uint64][]float64

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

func (mc *Cluster) LoadRegion(regionID uint64, peerStoreIDs ...uint64)

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

func (mc *Cluster) PutRegionStores(id uint64, stores ...uint64)

PutRegionStores mocks method.

func (*Cluster) PutStoreWithLabels

func (mc *Cluster) PutStoreWithLabels(id uint64, labelPairs ...string)

PutStoreWithLabels mocks method.

func (*Cluster) RecordOpStepWithTTL

func (mc *Cluster) RecordOpStepWithTTL(regionID uint64)

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

func (mc *Cluster) RemoveScheduler(name string) error

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

func (mc *Cluster) SetEnableLocationReplacement(v bool)

SetEnableLocationReplacement updates the EnableLocationReplacement configuration.

func (*Cluster) SetEnableMakeUpReplica

func (mc *Cluster) SetEnableMakeUpReplica(v bool)

SetEnableMakeUpReplica updates the EnableMakeUpReplica configuration.

func (*Cluster) SetEnableOneWayMerge

func (mc *Cluster) SetEnableOneWayMerge(v bool)

SetEnableOneWayMerge updates the EnableOneWayMerge configuration.

func (*Cluster) SetEnablePlacementRules

func (mc *Cluster) SetEnablePlacementRules(v bool)

SetEnablePlacementRules updates the EnablePlacementRules configuration.

func (*Cluster) SetEnableRemoveDownReplica

func (mc *Cluster) SetEnableRemoveDownReplica(v bool)

SetEnableRemoveDownReplica updates the EnableRemoveDownReplica configuration.

func (*Cluster) SetEnableRemoveExtraReplica

func (mc *Cluster) SetEnableRemoveExtraReplica(v bool)

SetEnableRemoveExtraReplica updates the EnableRemoveExtraReplica configuration.

func (*Cluster) SetEnableReplaceOfflineReplica

func (mc *Cluster) SetEnableReplaceOfflineReplica(v bool)

SetEnableReplaceOfflineReplica updates the EnableReplaceOfflineReplica configuration.

func (*Cluster) SetHotPendingInfluenceMetrics

func (mc *Cluster) SetHotPendingInfluenceMetrics(storeLabel, rwTy, dim string, load float64)

SetHotPendingInfluenceMetrics mock method

func (*Cluster) SetHotRegionCacheHitsThreshold

func (mc *Cluster) SetHotRegionCacheHitsThreshold(v int)

SetHotRegionCacheHitsThreshold updates the HotRegionCacheHitsThreshold configuration.

func (*Cluster) SetHotRegionScheduleLimit

func (mc *Cluster) SetHotRegionScheduleLimit(v int)

SetHotRegionScheduleLimit updates the HotRegionScheduleLimit configuration.

func (*Cluster) SetIsolationLevel

func (mc *Cluster) SetIsolationLevel(v string)

SetIsolationLevel updates the IsolationLevel configuration.

func (*Cluster) SetLeaderScheduleLimit

func (mc *Cluster) SetLeaderScheduleLimit(v int)

SetLeaderScheduleLimit updates the LeaderScheduleLimit configuration.

func (*Cluster) SetLeaderSchedulePolicy

func (mc *Cluster) SetLeaderSchedulePolicy(v string)

SetLeaderSchedulePolicy updates the LeaderSchedulePolicy configuration.

func (*Cluster) SetLocationLabels

func (mc *Cluster) SetLocationLabels(v []string)

SetLocationLabels updates the LocationLabels configuration.

func (*Cluster) SetMaxMergeRegionKeys

func (mc *Cluster) SetMaxMergeRegionKeys(v int)

SetMaxMergeRegionKeys updates the MaxMergeRegionKeys configuration.

func (*Cluster) SetMaxMergeRegionSize

func (mc *Cluster) SetMaxMergeRegionSize(v int)

SetMaxMergeRegionSize updates the MaxMergeRegionSize configuration.

func (*Cluster) SetMaxReplicas

func (mc *Cluster) SetMaxReplicas(v int)

SetMaxReplicas updates the maxReplicas configuration.

func (*Cluster) SetMaxReplicasWithLabel

func (mc *Cluster) SetMaxReplicasWithLabel(enablePlacementRules bool, num int, labels ...string)

SetMaxReplicasWithLabel sets the max replicas for the cluster in two ways.

func (*Cluster) SetMaxSnapshotCount

func (mc *Cluster) SetMaxSnapshotCount(v int)

SetMaxSnapshotCount updates the MaxSnapshotCount configuration.

func (*Cluster) SetMergeScheduleLimit

func (mc *Cluster) SetMergeScheduleLimit(v int)

SetMergeScheduleLimit updates the MergeScheduleLimit configuration.

func (*Cluster) SetRegionMaxSize

func (mc *Cluster) SetRegionMaxSize(v string)

SetRegionMaxSize sets the region max size.

func (*Cluster) SetRegionScheduleLimit

func (mc *Cluster) SetRegionScheduleLimit(v int)

SetRegionScheduleLimit updates the RegionScheduleLimit configuration.

func (*Cluster) SetRegionScoreFormulaVersion

func (mc *Cluster) SetRegionScoreFormulaVersion(v string)

SetRegionScoreFormulaVersion updates the RegionScoreFormulaVersion configuration.

func (*Cluster) SetRegionSizeMB

func (mc *Cluster) SetRegionSizeMB(v uint64)

SetRegionSizeMB sets the region max size.

func (*Cluster) SetSplitMergeInterval

func (mc *Cluster) SetSplitMergeInterval(v time.Duration)

SetSplitMergeInterval updates the SplitMergeInterval configuration.

func (*Cluster) SetStoreBusy

func (mc *Cluster) SetStoreBusy(storeID uint64, busy bool)

SetStoreBusy sets store busy.

func (*Cluster) SetStoreDisconnect

func (mc *Cluster) SetStoreDisconnect(storeID uint64)

SetStoreDisconnect changes a store's state to disconnected.

func (*Cluster) SetStoreDown

func (mc *Cluster) SetStoreDown(storeID uint64)

SetStoreDown sets store down.

func (*Cluster) SetStoreEvictLeader

func (mc *Cluster) SetStoreEvictLeader(storeID uint64, enableEvictLeader bool)

SetStoreEvictLeader set store whether evict leader.

func (*Cluster) SetStoreLabel

func (mc *Cluster) SetStoreLabel(storeID uint64, labels map[string]string)

SetStoreLabel set the labels to the target store

func (*Cluster) SetStoreLastHeartbeatInterval

func (mc *Cluster) SetStoreLastHeartbeatInterval(storeID uint64, interval time.Duration)

SetStoreLastHeartbeatInterval set the last heartbeat to the target store

func (*Cluster) SetStoreOffline

func (mc *Cluster) SetStoreOffline(storeID uint64)

SetStoreOffline sets store state to be offline.

func (*Cluster) SetStoreUp

func (mc *Cluster) SetStoreUp(storeID uint64)

SetStoreUp sets store state to be up.

func (*Cluster) SetTolerantSizeRatio

func (mc *Cluster) SetTolerantSizeRatio(v float64)

SetTolerantSizeRatio updates the TolerantSizeRatio configuration.

func (*Cluster) UpdateLeaderCount

func (mc *Cluster) UpdateLeaderCount(storeID uint64, leaderCount int)

UpdateLeaderCount updates store leader count.

func (*Cluster) UpdatePendingPeerCount

func (mc *Cluster) UpdatePendingPeerCount(storeID uint64, pendingPeerCount int)

UpdatePendingPeerCount updates store pending peer count.

func (*Cluster) UpdateRegionCount

func (mc *Cluster) UpdateRegionCount(storeID uint64, regionCount int)

UpdateRegionCount updates store region count.

func (*Cluster) UpdateSnapshotCount

func (mc *Cluster) UpdateSnapshotCount(storeID uint64, snapshotCount int)

UpdateSnapshotCount updates store snapshot count.

func (*Cluster) UpdateStorageRatio

func (mc *Cluster) UpdateStorageRatio(storeID uint64, usedRatio, availableRatio float64)

UpdateStorageRatio updates store storage ratio count.

func (*Cluster) UpdateStorageReadBytes

func (mc *Cluster) UpdateStorageReadBytes(storeID uint64, bytesRead uint64)

UpdateStorageReadBytes updates store read bytes.

func (*Cluster) UpdateStorageReadKeys

func (mc *Cluster) UpdateStorageReadKeys(storeID uint64, keysRead uint64)

UpdateStorageReadKeys updates store read bytes.

func (*Cluster) UpdateStorageReadQuery

func (mc *Cluster) UpdateStorageReadQuery(storeID uint64, queryRead uint64)

UpdateStorageReadQuery updates store read query.

func (*Cluster) UpdateStorageReadStats

func (mc *Cluster) UpdateStorageReadStats(storeID, bytesRead, keysRead uint64)

UpdateStorageReadStats updates store written bytes.

func (*Cluster) UpdateStorageWriteQuery

func (mc *Cluster) UpdateStorageWriteQuery(storeID uint64, queryWrite uint64)

UpdateStorageWriteQuery updates store write query.

func (*Cluster) UpdateStorageWrittenBytes

func (mc *Cluster) UpdateStorageWrittenBytes(storeID uint64, bytesWritten uint64)

UpdateStorageWrittenBytes updates store written bytes.

func (*Cluster) UpdateStorageWrittenKeys

func (mc *Cluster) UpdateStorageWrittenKeys(storeID uint64, keysWritten uint64)

UpdateStorageWrittenKeys updates store written keys.

func (*Cluster) UpdateStorageWrittenStats

func (mc *Cluster) UpdateStorageWrittenStats(storeID, bytesWritten, keysWritten uint64)

UpdateStorageWrittenStats updates store written bytes.

func (*Cluster) UpdateStoreLeaderSize

func (mc *Cluster) UpdateStoreLeaderSize(storeID uint64, size int64)

UpdateStoreLeaderSize updates store leader size.

func (*Cluster) UpdateStoreLeaderWeight

func (mc *Cluster) UpdateStoreLeaderWeight(storeID uint64, weight float64)

UpdateStoreLeaderWeight updates store leader weight.

func (*Cluster) UpdateStoreRegionSize

func (mc *Cluster) UpdateStoreRegionSize(storeID uint64, size int64)

UpdateStoreRegionSize updates store region size.

func (*Cluster) UpdateStoreRegionWeight

func (mc *Cluster) UpdateStoreRegionWeight(storeID uint64, weight float64)

UpdateStoreRegionWeight updates store region weight.

func (*Cluster) UpdateStoreStatus

func (mc *Cluster) UpdateStoreStatus(id uint64)

UpdateStoreStatus updates store status.

func (*Cluster) UpdateWitnessCount

func (mc *Cluster) UpdateWitnessCount(storeID uint64, witnessCount int)

UpdateWitnessCount updates store witness count.

Jump to

Keyboard shortcuts

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