Documentation
¶
Index ¶
- Constants
- Variables
- func CountInJointState(peers ...*metapb.Peer) int
- func DiffRegionKeyInfo(origin *RegionInfo, other *RegionInfo) string
- func DiffRegionPeersInfo(origin *RegionInfo, other *RegionInfo) string
- func DistinctScore(labels []string, stores []*StoreInfo, other *StoreInfo) float64
- func EncodeToString(src []byte) []byte
- func GetReadQueryNum(stats *pdpb.QueryStats) uint64
- func GetWriteQueryNum(stats *pdpb.QueryStats) uint64
- func HexRegionKey(key []byte) []byte
- func HexRegionKeyStr(key []byte) string
- func IsAvailableForMinResolvedTS(s *StoreInfo) bool
- func IsInJointState(peers ...*metapb.Peer) bool
- func IsLearner(peer *metapb.Peer) bool
- func IsLearnerOrDemotingVoter(peer *metapb.Peer) bool
- func IsStoreContainLabel(store *metapb.Store, key, value string) bool
- func IsVoter(peer *metapb.Peer) bool
- func IsVoterOrIncomingVoter(peer *metapb.Peer) bool
- func IsWitness(peer *metapb.Peer) bool
- func MergeLabels(origin []*metapb.StoreLabel, labels []*metapb.StoreLabel) []*metapb.StoreLabel
- func NeedTransferWitnessLeader(region *RegionInfo) bool
- func RandomKindReadQuery(queryRead uint64) *pdpb.QueryStats
- func RandomKindWriteQuery(queryWrite uint64) *pdpb.QueryStats
- func SortedPeersEqual(peersA, peersB []*metapb.Peer) bool
- func SortedPeersStatsEqual(peersA, peersB []*pdpb.PeerStats) bool
- func String(b []byte) (s string)
- func ToUpperASCIIInplace(s []byte) []byte
- type BasicCluster
- func (bc *BasicCluster) DeleteStore(store *StoreInfo)
- func (bc *BasicCluster) GetFollowerStores(region *RegionInfo) []*StoreInfo
- func (bc *BasicCluster) GetLeaderStore(region *RegionInfo) *StoreInfo
- func (bc *BasicCluster) GetLeaderStoreByRegionID(regionID uint64) *StoreInfo
- func (bc *BasicCluster) GetMetaStores() []*metapb.Store
- func (bc *BasicCluster) GetNonWitnessVoterStores(region *RegionInfo) []*StoreInfo
- func (bc *BasicCluster) GetRegionStores(region *RegionInfo) []*StoreInfo
- func (bc *BasicCluster) GetStore(storeID uint64) *StoreInfo
- func (bc *BasicCluster) GetStoreCount() int
- func (bc *BasicCluster) GetStores() []*StoreInfo
- func (bc *BasicCluster) GetStoresLeaderWriteRate() (storeIDs []uint64, bytesRates, keysRates []float64)
- func (bc *BasicCluster) GetStoresWriteRate() (storeIDs []uint64, bytesRates, keysRates []float64)
- func (bc *BasicCluster) PauseLeaderTransfer(storeID uint64) error
- func (bc *BasicCluster) PutStore(store *StoreInfo)
- func (bc *BasicCluster) ResetStoreLimit(storeID uint64, limitType storelimit.Type, ratePerSec ...float64)
- func (bc *BasicCluster) ResetStores()
- func (bc *BasicCluster) ResumeLeaderTransfer(storeID uint64)
- func (bc *BasicCluster) SlowStoreEvicted(storeID uint64) error
- func (bc *BasicCluster) SlowStoreRecovered(storeID uint64)
- func (bc *BasicCluster) SlowTrendEvicted(storeID uint64) error
- func (bc *BasicCluster) SlowTrendRecovered(storeID uint64)
- func (bc *BasicCluster) UpdateStoreStatus(storeID uint64)
- type HexRegionMeta
- type HexRegionsMeta
- type KeyRange
- type PeerInfo
- type RegionCreateOption
- func AddQueryStats(v *pdpb.QueryStats) RegionCreateOption
- func SetApproximateKeys(v int64) RegionCreateOption
- func SetApproximateSize(v int64) RegionCreateOption
- func SetBuckets(buckets *metapb.Buckets) RegionCreateOption
- func SetCPUUsage(v uint64) RegionCreateOption
- func SetFromHeartbeat(fromHeartbeat bool) RegionCreateOption
- func SetPeers(peers []*metapb.Peer) RegionCreateOption
- func SetQueryStats(v *pdpb.QueryStats) RegionCreateOption
- func SetReadBytes(v uint64) RegionCreateOption
- func SetReadKeys(v uint64) RegionCreateOption
- func SetReadQuery(v uint64) RegionCreateOption
- func SetRegionConfVer(confVer uint64) RegionCreateOption
- func SetRegionVersion(version uint64) RegionCreateOption
- func SetReplicationStatus(status *replication_modepb.RegionReplicationStatus) RegionCreateOption
- func SetReportInterval(start, end uint64) RegionCreateOption
- func SetWrittenBytes(v uint64) RegionCreateOption
- func SetWrittenKeys(v uint64) RegionCreateOption
- func SetWrittenQuery(v uint64) RegionCreateOption
- func WithAddPeer(peer *metapb.Peer) RegionCreateOption
- func WithDecConfVer() RegionCreateOption
- func WithDecVersion() RegionCreateOption
- func WithDownPeers(downPeers []*pdpb.PeerStats) RegionCreateOption
- func WithEndKey(key []byte) RegionCreateOption
- func WithFlowRoundByDigit(digit int) RegionCreateOption
- func WithIncConfVer() RegionCreateOption
- func WithIncVersion() RegionCreateOption
- func WithInterval(interval *pdpb.TimeInterval) RegionCreateOption
- func WithLeader(leader *metapb.Peer) RegionCreateOption
- func WithLearners(learners []*metapb.Peer) RegionCreateOption
- func WithNewPeerIDs(peerIDs ...uint64) RegionCreateOption
- func WithNewRegionID(id uint64) RegionCreateOption
- func WithPendingPeers(pendingPeers []*metapb.Peer) RegionCreateOption
- func WithRemoveStorePeer(storeID uint64) RegionCreateOption
- func WithReplacePeerStore(oldStoreID, newStoreID uint64) RegionCreateOption
- func WithRole(peerID uint64, role metapb.PeerRole) RegionCreateOption
- func WithStartKey(key []byte) RegionCreateOption
- func WithWitness(peerID uint64) RegionCreateOption
- func WithWitnesses(witnesses []*metapb.Peer) RegionCreateOption
- type RegionGuideFunc
- type RegionInfo
- func MergeRegions(regions []*RegionInfo) []*RegionInfo
- func NewRegionInfo(region *metapb.Region, leader *metapb.Peer, opts ...RegionCreateOption) *RegionInfo
- func NewTestRegionInfo(regionID, storeID uint64, start, end []byte, opts ...RegionCreateOption) *RegionInfo
- func RegionFromHeartbeat(heartbeat *pdpb.RegionHeartbeatRequest, opts ...RegionCreateOption) *RegionInfo
- func SplitRegions(regions []*RegionInfo) []*RegionInfo
- func (r *RegionInfo) Clone(opts ...RegionCreateOption) *RegionInfo
- func (r *RegionInfo) GetApproximateKeys() int64
- func (r *RegionInfo) GetApproximateSize() int64
- func (r *RegionInfo) GetBuckets() *metapb.Buckets
- func (r *RegionInfo) GetBytesRead() uint64
- func (r *RegionInfo) GetBytesWritten() uint64
- func (r *RegionInfo) GetCPUUsage() uint64
- func (r *RegionInfo) GetDiffFollowers(other *RegionInfo) []*metapb.Peer
- func (r *RegionInfo) GetDownLearner(peerID uint64) *metapb.Peer
- func (r *RegionInfo) GetDownPeer(peerID uint64) *metapb.Peer
- func (r *RegionInfo) GetDownPeers() []*pdpb.PeerStats
- func (r *RegionInfo) GetDownVoter(peerID uint64) *metapb.Peer
- func (r *RegionInfo) GetEndKey() []byte
- func (r *RegionInfo) GetFollower() *metapb.Peer
- func (r *RegionInfo) GetFollowers() map[uint64]*metapb.Peer
- func (r *RegionInfo) GetID() uint64
- func (r *RegionInfo) GetInterval() *pdpb.TimeInterval
- func (r *RegionInfo) GetKeysRead() uint64
- func (r *RegionInfo) GetKeysWritten() uint64
- func (r *RegionInfo) GetLeader() *metapb.Peer
- func (r *RegionInfo) GetLearners() []*metapb.Peer
- func (r *RegionInfo) GetLoads() []float64
- func (r *RegionInfo) GetMeta() *metapb.Region
- func (r *RegionInfo) GetNonWitnessVoters() map[uint64]*metapb.Peer
- func (r *RegionInfo) GetPeer(peerID uint64) *metapb.Peer
- func (r *RegionInfo) GetPeers() []*metapb.Peer
- func (r *RegionInfo) GetPendingLearner(peerID uint64) *metapb.Peer
- func (r *RegionInfo) GetPendingPeer(peerID uint64) *metapb.Peer
- func (r *RegionInfo) GetPendingPeers() []*metapb.Peer
- func (r *RegionInfo) GetPendingVoter(peerID uint64) *metapb.Peer
- func (r *RegionInfo) GetReadQueryNum() uint64
- func (r *RegionInfo) GetRegionEpoch() *metapb.RegionEpoch
- func (r *RegionInfo) GetReplicationStatus() *replication_modepb.RegionReplicationStatus
- func (r *RegionInfo) GetRoundBytesRead() uint64
- func (r *RegionInfo) GetRoundBytesWritten() uint64
- func (r *RegionInfo) GetStartKey() []byte
- func (r *RegionInfo) GetStat() *pdpb.RegionStat
- func (r *RegionInfo) GetStoreIDs() map[uint64]struct{}
- func (r *RegionInfo) GetStoreLearner(storeID uint64) *metapb.Peer
- func (r *RegionInfo) GetStorePeer(storeID uint64) *metapb.Peer
- func (r *RegionInfo) GetStorePeerApproximateKeys(storeID uint64) int64
- func (r *RegionInfo) GetStorePeerApproximateSize(storeID uint64) int64
- func (r *RegionInfo) GetStoreVoter(storeID uint64) *metapb.Peer
- func (r *RegionInfo) GetStoreWitness(storeID uint64) *metapb.Peer
- func (r *RegionInfo) GetTerm() uint64
- func (r *RegionInfo) GetVoters() []*metapb.Peer
- func (r *RegionInfo) GetWitnesses() []*metapb.Peer
- func (r *RegionInfo) GetWriteLoads() []float64
- func (r *RegionInfo) GetWriteQueryNum() uint64
- func (r *RegionInfo) GetWriteRate() (bytesRate, keysRate float64)
- func (r *RegionInfo) Inherit(origin *RegionInfo, bucketEnable bool)
- func (r *RegionInfo) IsFromHeartbeat() bool
- func (r *RegionInfo) IsOversized(maxSize int64, maxKeys int64) bool
- func (r *RegionInfo) NeedMerge(mergeSize int64, mergeKeys int64) bool
- func (r *RegionInfo) UpdateBuckets(buckets, old *metapb.Buckets) bool
- type RegionSetInformer
- type RegionsInfo
- func (r *RegionsInfo) AtomicCheckAndPutRegion(region *RegionInfo) ([]*RegionInfo, error)
- func (r *RegionsInfo) CheckAndPutRegion(region *RegionInfo) []*RegionInfo
- func (r *RegionsInfo) GetAdjacentRegions(region *RegionInfo) (*RegionInfo, *RegionInfo)
- func (r *RegionsInfo) GetAverageRegionSize() int64
- func (r *RegionsInfo) GetFollower(storeID uint64, region *RegionInfo) *RegionInfo
- func (r *RegionsInfo) GetLeader(storeID uint64, region *RegionInfo) *RegionInfo
- func (r *RegionsInfo) GetMetaRegions() []*metapb.Region
- func (r *RegionsInfo) GetOverlaps(region *RegionInfo) []*regionItem
- func (r *RegionsInfo) GetPrevRegionByKey(regionKey []byte) *RegionInfo
- func (r *RegionsInfo) GetRangeCount(startKey, endKey []byte) int
- func (r *RegionsInfo) GetRangeHoles() [][]string
- func (r *RegionsInfo) GetRegion(regionID uint64) *RegionInfo
- func (r *RegionsInfo) GetRegionByKey(regionKey []byte) *RegionInfo
- func (r *RegionsInfo) GetRegionCount() int
- func (r *RegionsInfo) GetRegionSizeByRange(startKey, endKey []byte) int64
- func (r *RegionsInfo) GetRegions() []*RegionInfo
- func (r *RegionsInfo) GetRelevantRegions(region *RegionInfo) (origin *RegionInfo, overlaps []*regionItem)
- func (r *RegionsInfo) GetStoreFollowerCount(storeID uint64) int
- func (r *RegionsInfo) GetStoreFollowerRegionSize(storeID uint64) int64
- func (r *RegionsInfo) GetStoreLeaderCount(storeID uint64) int
- func (r *RegionsInfo) GetStoreLeaderRegionSize(storeID uint64) int64
- func (r *RegionsInfo) GetStoreLeaderWriteRate(storeID uint64) (bytesRate, keysRate float64)
- func (r *RegionsInfo) GetStoreLearnerCount(storeID uint64) int
- func (r *RegionsInfo) GetStoreLearnerRegionSize(storeID uint64) int64
- func (r *RegionsInfo) GetStorePendingPeerCount(storeID uint64) int
- func (r *RegionsInfo) GetStoreRegionCount(storeID uint64) int
- func (r *RegionsInfo) GetStoreRegionSize(storeID uint64) int64
- func (r *RegionsInfo) GetStoreRegions(storeID uint64) []*RegionInfo
- func (r *RegionsInfo) GetStoreStats(storeID uint64) (leader, region, witness, learner, pending int, leaderSize, regionSize int64)
- func (r *RegionsInfo) GetStoreWitnessCount(storeID uint64) int
- func (r *RegionsInfo) GetStoreWriteRate(storeID uint64) (bytesRate, keysRate float64)
- func (r *RegionsInfo) PreCheckPutRegion(region *RegionInfo) (*RegionInfo, []*regionItem, error)
- func (r *RegionsInfo) PutRegion(region *RegionInfo) []*RegionInfo
- func (r *RegionsInfo) RandFollowerRegion(storeID uint64, ranges []KeyRange) *RegionInfo
- func (r *RegionsInfo) RandFollowerRegions(storeID uint64, ranges []KeyRange) []*RegionInfo
- func (r *RegionsInfo) RandLeaderRegion(storeID uint64, ranges []KeyRange) *RegionInfo
- func (r *RegionsInfo) RandLeaderRegions(storeID uint64, ranges []KeyRange) []*RegionInfo
- func (r *RegionsInfo) RandLearnerRegion(storeID uint64, ranges []KeyRange) *RegionInfo
- func (r *RegionsInfo) RandLearnerRegions(storeID uint64, ranges []KeyRange) []*RegionInfo
- func (r *RegionsInfo) RandPendingRegion(storeID uint64, ranges []KeyRange) *RegionInfo
- func (r *RegionsInfo) RandPendingRegions(storeID uint64, ranges []KeyRange) []*RegionInfo
- func (r *RegionsInfo) RandWitnessRegion(storeID uint64, ranges []KeyRange) *RegionInfo
- func (r *RegionsInfo) RandWitnessRegions(storeID uint64, ranges []KeyRange) []*RegionInfo
- func (r *RegionsInfo) RemoveRegion(region *RegionInfo)
- func (r *RegionsInfo) RemoveRegionFromSubTree(region *RegionInfo)
- func (r *RegionsInfo) RemoveRegionIfExist(id uint64)
- func (r *RegionsInfo) ResetRegionCache()
- func (r *RegionsInfo) ScanRange(startKey, endKey []byte, limit int) []*RegionInfo
- func (r *RegionsInfo) ScanRangeWithIterator(startKey []byte, iterator func(region *RegionInfo) bool)
- func (r *RegionsInfo) SetRegion(region *RegionInfo) (*RegionInfo, []*RegionInfo, bool)
- func (r *RegionsInfo) TreeLen() int
- func (r *RegionsInfo) UpdateSubTree(region, origin *RegionInfo, overlaps []*RegionInfo, rangeChanged bool)
- type StoreCreateOption
- func OfflineStore(physicallyDestroyed bool) StoreCreateOption
- func PauseLeaderTransfer() StoreCreateOption
- func ResetStoreLimit(limitType storelimit.Type, ratePerSec ...float64) StoreCreateOption
- func ResumeLeaderTransfer() StoreCreateOption
- func SetLastAwakenTime(lastAwaken time.Time) StoreCreateOption
- func SetLastHeartbeatTS(lastHeartbeatTS time.Time) StoreCreateOption
- func SetLastPersistTime(lastPersist time.Time) StoreCreateOption
- func SetLeaderCount(leaderCount int) StoreCreateOption
- func SetLeaderSize(leaderSize int64) StoreCreateOption
- func SetLeaderWeight(leaderWeight float64) StoreCreateOption
- func SetLearnerCount(learnerCount int) StoreCreateOption
- func SetMinResolvedTS(minResolvedTS uint64) StoreCreateOption
- func SetNewStoreStats(stats *pdpb.StoreStats) StoreCreateOption
- func SetPendingPeerCount(pendingPeerCount int) StoreCreateOption
- func SetRegionCount(regionCount int) StoreCreateOption
- func SetRegionSize(regionSize int64) StoreCreateOption
- func SetRegionWeight(regionWeight float64) StoreCreateOption
- func SetStoreAddress(address, statusAddress, peerAddress string) StoreCreateOption
- func SetStoreDeployPath(deployPath string) StoreCreateOption
- func SetStoreLabels(labels []*metapb.StoreLabel) StoreCreateOption
- func SetStoreLimit(limit storelimit.StoreLimit) StoreCreateOption
- func SetStoreStartTime(startTS int64) StoreCreateOption
- func SetStoreStats(stats *pdpb.StoreStats) StoreCreateOption
- func SetStoreVersion(githash, version string) StoreCreateOption
- func SetWitnessCount(witnessCount int) StoreCreateOption
- func SlowStoreEvicted() StoreCreateOption
- func SlowStoreRecovered() StoreCreateOption
- func SlowTrendEvicted() StoreCreateOption
- func SlowTrendRecovered() StoreCreateOption
- func TombstoneStore() StoreCreateOption
- func UpStore() StoreCreateOption
- type StoreInfo
- func (s *StoreInfo) AllowLeaderTransfer() bool
- func (s *StoreInfo) AvailableRatio() float64
- func (s *StoreInfo) Clone(opts ...StoreCreateOption) *StoreInfo
- func (ss StoreInfo) CloneStoreStats() *pdpb.StoreStats
- func (s *StoreInfo) CompareLocation(other *StoreInfo, labels []string) int
- func (s *StoreInfo) DownTime() time.Duration
- func (s *StoreInfo) EvictedAsSlowStore() bool
- func (s *StoreInfo) Feedback(e float64)
- func (s *StoreInfo) GetAddress() string
- func (ss StoreInfo) GetAvailable() uint64
- func (ss StoreInfo) GetAvgAvailable() uint64
- func (ss StoreInfo) GetBytesRead() uint64
- func (ss StoreInfo) GetBytesWritten() uint64
- func (ss StoreInfo) GetCapacity() uint64
- func (s *StoreInfo) GetID() uint64
- func (ss StoreInfo) GetKeysRead() uint64
- func (ss StoreInfo) GetKeysWritten() uint64
- func (s *StoreInfo) GetLabelValue(key string) string
- func (s *StoreInfo) GetLabels() []*metapb.StoreLabel
- func (s *StoreInfo) GetLastHeartbeatTS() time.Time
- func (s *StoreInfo) GetLeaderCount() int
- func (s *StoreInfo) GetLeaderSize() int64
- func (s *StoreInfo) GetLeaderWeight() float64
- func (s *StoreInfo) GetLearnerCount() int
- func (s *StoreInfo) GetMeta() *metapb.Store
- func (s *StoreInfo) GetMinResolvedTS() uint64
- func (s *StoreInfo) GetNodeState() metapb.NodeState
- func (s *StoreInfo) GetPendingPeerCount() int
- func (ss StoreInfo) GetReceivingSnapCount() uint32
- func (s *StoreInfo) GetRegionCount() int
- func (s *StoreInfo) GetRegionSize() int64
- func (s *StoreInfo) GetRegionWeight() float64
- func (ss StoreInfo) GetSendingSnapCount() uint32
- func (s *StoreInfo) GetSlowScore() uint64
- func (s *StoreInfo) GetSlowTrend() *pdpb.SlowTrend
- func (s *StoreInfo) GetStartTime() time.Time
- func (s *StoreInfo) GetState() metapb.StoreState
- func (s *StoreInfo) GetStatusAddress() string
- func (s *StoreInfo) GetStoreLimit() storelimit.StoreLimit
- func (ss StoreInfo) GetStoreStats() *pdpb.StoreStats
- func (s *StoreInfo) GetUptime() time.Duration
- func (ss StoreInfo) GetUsedSize() uint64
- func (s *StoreInfo) GetVersion() string
- func (s *StoreInfo) GetWitnessCount() int
- func (s *StoreInfo) IsAvailable(limitType storelimit.Type, level constant.PriorityLevel) bool
- func (ss StoreInfo) IsBusy() bool
- func (s *StoreInfo) IsDisconnected() bool
- func (s *StoreInfo) IsEvictedAsSlowTrend() bool
- func (s *StoreInfo) IsLowSpace(lowSpaceRatio float64) bool
- func (s *StoreInfo) IsPhysicallyDestroyed() bool
- func (s *StoreInfo) IsPreparing() bool
- func (s *StoreInfo) IsRemoved() bool
- func (s *StoreInfo) IsRemoving() bool
- func (s *StoreInfo) IsServing() bool
- func (s *StoreInfo) IsSlow() bool
- func (s *StoreInfo) IsTiFlash() bool
- func (s *StoreInfo) IsUnhealthy() bool
- func (s *StoreInfo) IsUp() bool
- func (s *StoreInfo) LeaderScore(policy constant.SchedulePolicy, delta int64) float64
- func (s *StoreInfo) LimitVersion() string
- func (s *StoreInfo) NeedAwakenStore() bool
- func (s *StoreInfo) NeedPersist() bool
- func (s *StoreInfo) RegionScore(version string, highSpaceRatio, lowSpaceRatio float64, delta int64) float64
- func (s *StoreInfo) ResourceCount(kind constant.ResourceKind) uint64
- func (s *StoreInfo) ResourceSize(kind constant.ResourceKind) int64
- func (s *StoreInfo) ResourceWeight(kind constant.ResourceKind) float64
- func (s *StoreInfo) ShallowClone(opts ...StoreCreateOption) *StoreInfo
- func (s *StoreInfo) StorageSize() uint64
- func (s *StoreInfo) WitnessScore(delta int64) float64
- type StoreSetController
- type StoreSetInformer
- type StoresInfo
- func (s *StoresInfo) DeleteStore(store *StoreInfo)
- func (s *StoresInfo) GetMetaStores() []*metapb.Store
- func (s *StoresInfo) GetStore(storeID uint64) *StoreInfo
- func (s *StoresInfo) GetStoreCount() int
- func (s *StoresInfo) GetStores() []*StoreInfo
- func (s *StoresInfo) PauseLeaderTransfer(storeID uint64) error
- func (s *StoresInfo) ResetStoreLimit(storeID uint64, limitType storelimit.Type, ratePerSec ...float64)
- func (s *StoresInfo) ResumeLeaderTransfer(storeID uint64)
- func (s *StoresInfo) SetLeaderCount(storeID uint64, leaderCount int)
- func (s *StoresInfo) SetLeaderSize(storeID uint64, leaderSize int64)
- func (s *StoresInfo) SetPendingPeerCount(storeID uint64, pendingPeerCount int)
- func (s *StoresInfo) SetRegionCount(storeID uint64, regionCount int)
- func (s *StoresInfo) SetRegionSize(storeID uint64, regionSize int64)
- func (s *StoresInfo) SetStore(store *StoreInfo)
- func (s *StoresInfo) SlowStoreEvicted(storeID uint64) error
- func (s *StoresInfo) SlowStoreRecovered(storeID uint64)
- func (s *StoresInfo) SlowTrendEvicted(storeID uint64) error
- func (s *StoresInfo) SlowTrendRecovered(storeID uint64)
- func (s *StoresInfo) UpdateStoreStatus(storeID uint64, ...)
Constants ¶
const ( // EmptyRegionApproximateSize is the region approximate size of an empty region // (heartbeat size <= 1MB). EmptyRegionApproximateSize = 1 // ImpossibleFlowSize is an impossible flow size (such as written_bytes, read_keys, etc.) // It may be caused by overflow, refer to https://github.com/gottingen/tm/issues/3379. // They need to be filtered so as not to affect downstream. // (flow size >= 1024TB) ImpossibleFlowSize = 1 << 50 // InitClusterRegionThreshold is a threshold which represent a new cluster. InitClusterRegionThreshold = 100 )
const ( // EngineKey is the label key used to indicate engine. EngineKey = "engine" // EngineTiFlash is the tiflash value of the engine label. EngineTiFlash = "tiflash" // EngineTiKV indicates the tikv engine in metrics EngineTiKV = "tikv" )
Variables ¶
var ( // RegionFactory returns new region. RegionFactory = func() *metapb.Region { return &metapb.Region{} } // RegionPeerFactory returns new region peer. RegionPeerFactory = func() *metapb.Peer { return &metapb.Peer{} } // RegionHeartbeatResponseFactory returns new region heartbeat response. RegionHeartbeatResponseFactory = func() *pdpb.RegionHeartbeatResponse { return &pdpb.RegionHeartbeatResponse{} } // PeerStatsFactory returns new peer stats. PeerStatsFactory = func() *pdpb.PeerStats { return &pdpb.PeerStats{} } // StoreFactory returns new store. StoreFactory = func() *metapb.Store { return &metapb.Store{} } // StoreStatsFactory returns new store stats. StoreStatsFactory = func() *pdpb.StoreStats { return &pdpb.StoreStats{} } // KeyDictionaryFactory returns new key dictionary. KeyDictionaryFactory = func() *encryptionpb.KeyDictionary { return &encryptionpb.KeyDictionary{} } // MemberFactory returns new member. MemberFactory = func() *pdpb.Member { return &pdpb.Member{} } // ClusterFactory returns new cluster. ClusterFactory = func() *metapb.Cluster { return &metapb.Cluster{} } // TimeIntervalFactory returns new time interval. TimeIntervalFactory = func() *pdpb.TimeInterval { return &pdpb.TimeInterval{} } // QueryStatsFactory returns new query stats. QueryStatsFactory = func() *pdpb.QueryStats { return &pdpb.QueryStats{} } )
Functions ¶
func CountInJointState ¶
CountInJointState count the peers are in joint state.
func DiffRegionKeyInfo ¶
func DiffRegionKeyInfo(origin *RegionInfo, other *RegionInfo) string
DiffRegionKeyInfo return the difference of key info between two RegionInfo
func DiffRegionPeersInfo ¶
func DiffRegionPeersInfo(origin *RegionInfo, other *RegionInfo) string
DiffRegionPeersInfo return the difference of peers info between two RegionInfo
func DistinctScore ¶
DistinctScore returns the score that the other is distinct from the stores. A higher score means the other store is more different from the existed stores.
func EncodeToString ¶
EncodeToString overrides hex.EncodeToString implementation. Difference: returns []byte, not string
func GetReadQueryNum ¶
func GetReadQueryNum(stats *pdpb.QueryStats) uint64
GetReadQueryNum returns read query num from this QueryStats
func GetWriteQueryNum ¶
func GetWriteQueryNum(stats *pdpb.QueryStats) uint64
GetWriteQueryNum returns write query num from this QueryStats
func HexRegionKey ¶
HexRegionKey converts region key to hex format. Used for formating region in logs.
func HexRegionKeyStr ¶
HexRegionKeyStr converts region key to hex format. Used for formating region in logs.
func IsAvailableForMinResolvedTS ¶
IsAvailableForMinResolvedTS returns if the store is available for min resolved ts.
func IsInJointState ¶
IsInJointState judges whether the Peer is in joint state.
func IsLearnerOrDemotingVoter ¶
IsLearnerOrDemotingVoter judges whether peer role will become Learner. The peer is not nil and the role is equal to DemotingVoter or Learner.
func IsStoreContainLabel ¶
IsStoreContainLabel returns if the store contains the given label.
func IsVoterOrIncomingVoter ¶
IsVoterOrIncomingVoter judges whether peer role will become Voter. The peer is not nil and the role is equal to IncomingVoter or Voter.
func MergeLabels ¶
func MergeLabels(origin []*metapb.StoreLabel, labels []*metapb.StoreLabel) []*metapb.StoreLabel
MergeLabels merges the passed in labels with origins, overriding duplicated ones.
func NeedTransferWitnessLeader ¶
func NeedTransferWitnessLeader(region *RegionInfo) bool
NeedTransferWitnessLeader is used to judge if the region's leader is a witness
func RandomKindReadQuery ¶
func RandomKindReadQuery(queryRead uint64) *pdpb.QueryStats
RandomKindReadQuery returns query stat with random query kind, only used for unit test.
func RandomKindWriteQuery ¶
func RandomKindWriteQuery(queryWrite uint64) *pdpb.QueryStats
RandomKindWriteQuery returns query stat with random query kind, only used for unit test.
func SortedPeersEqual ¶
SortedPeersEqual judges whether two sorted `peerSlice` are equal
func SortedPeersStatsEqual ¶
SortedPeersStatsEqual judges whether two sorted `peerStatsSlice` are equal
func ToUpperASCIIInplace ¶
ToUpperASCIIInplace bytes.ToUpper but zero-cost
Types ¶
type BasicCluster ¶
type BasicCluster struct { Stores struct { *StoresInfo // contains filtered or unexported fields } *RegionsInfo }
BasicCluster provides basic data member and interface for a tikv cluster.
func (*BasicCluster) DeleteStore ¶
func (bc *BasicCluster) DeleteStore(store *StoreInfo)
DeleteStore deletes a store.
func (*BasicCluster) GetFollowerStores ¶
func (bc *BasicCluster) GetFollowerStores(region *RegionInfo) []*StoreInfo
GetFollowerStores returns all Stores that contains the region's follower peer.
func (*BasicCluster) GetLeaderStore ¶
func (bc *BasicCluster) GetLeaderStore(region *RegionInfo) *StoreInfo
GetLeaderStore returns all Stores that contains the region's leader peer.
func (*BasicCluster) GetLeaderStoreByRegionID ¶
func (bc *BasicCluster) GetLeaderStoreByRegionID(regionID uint64) *StoreInfo
GetLeaderStoreByRegionID returns the leader store of the given region.
func (*BasicCluster) GetMetaStores ¶
func (bc *BasicCluster) GetMetaStores() []*metapb.Store
GetMetaStores gets a complete set of metapb.Store.
func (*BasicCluster) GetNonWitnessVoterStores ¶
func (bc *BasicCluster) GetNonWitnessVoterStores(region *RegionInfo) []*StoreInfo
GetNonWitnessVoterStores returns all Stores that contains the non-witness's voter peer.
func (*BasicCluster) GetRegionStores ¶
func (bc *BasicCluster) GetRegionStores(region *RegionInfo) []*StoreInfo
GetRegionStores returns all Stores that contains the region's peer.
func (*BasicCluster) GetStore ¶
func (bc *BasicCluster) GetStore(storeID uint64) *StoreInfo
GetStore searches for a store by ID.
func (*BasicCluster) GetStoreCount ¶
func (bc *BasicCluster) GetStoreCount() int
GetStoreCount returns the total count of storeInfo.
func (*BasicCluster) GetStores ¶
func (bc *BasicCluster) GetStores() []*StoreInfo
GetStores returns all Stores in the cluster.
func (*BasicCluster) GetStoresLeaderWriteRate ¶
func (bc *BasicCluster) GetStoresLeaderWriteRate() (storeIDs []uint64, bytesRates, keysRates []float64)
GetStoresLeaderWriteRate get total write rate of each store's leaders.
func (*BasicCluster) GetStoresWriteRate ¶
func (bc *BasicCluster) GetStoresWriteRate() (storeIDs []uint64, bytesRates, keysRates []float64)
GetStoresWriteRate get total write rate of each store's regions.
func (*BasicCluster) PauseLeaderTransfer ¶
func (bc *BasicCluster) PauseLeaderTransfer(storeID uint64) error
PauseLeaderTransfer prevents the store from been selected as source or target store of TransferLeader.
func (*BasicCluster) PutStore ¶
func (bc *BasicCluster) PutStore(store *StoreInfo)
PutStore put a store.
func (*BasicCluster) ResetStoreLimit ¶
func (bc *BasicCluster) ResetStoreLimit(storeID uint64, limitType storelimit.Type, ratePerSec ...float64)
ResetStoreLimit resets the limit for a specific store.
func (*BasicCluster) ResetStores ¶
func (bc *BasicCluster) ResetStores()
ResetStores resets the store cache.
func (*BasicCluster) ResumeLeaderTransfer ¶
func (bc *BasicCluster) ResumeLeaderTransfer(storeID uint64)
ResumeLeaderTransfer cleans a store's pause state. The store can be selected as source or target of TransferLeader again.
func (*BasicCluster) SlowStoreEvicted ¶
func (bc *BasicCluster) SlowStoreEvicted(storeID uint64) error
SlowStoreEvicted marks a store as a slow store and prevents transferring leader to the store
func (*BasicCluster) SlowStoreRecovered ¶
func (bc *BasicCluster) SlowStoreRecovered(storeID uint64)
SlowStoreRecovered cleans the evicted state of a store.
func (*BasicCluster) SlowTrendEvicted ¶
func (bc *BasicCluster) SlowTrendEvicted(storeID uint64) error
SlowTrendEvicted marks a store as a slow store by trend and prevents transferring leader to the store
func (*BasicCluster) SlowTrendRecovered ¶
func (bc *BasicCluster) SlowTrendRecovered(storeID uint64)
SlowTrendRecovered cleans the evicted by slow trend state of a store.
func (*BasicCluster) UpdateStoreStatus ¶
func (bc *BasicCluster) UpdateStoreStatus(storeID uint64)
UpdateStoreStatus updates the information of the store.
type HexRegionMeta ¶
HexRegionMeta is a region meta in the hex format. Used for formating region in logs.
func RegionToHexMeta ¶
func RegionToHexMeta(meta *metapb.Region) HexRegionMeta
RegionToHexMeta converts a region meta's keys to hex format. Used for formating region in logs.
func (HexRegionMeta) String ¶
func (h HexRegionMeta) String() string
type HexRegionsMeta ¶
HexRegionsMeta is a slice of regions' meta in the hex format. Used for formating region in logs.
func RegionsToHexMeta ¶
func RegionsToHexMeta(regions []*metapb.Region) HexRegionsMeta
RegionsToHexMeta converts regions' meta keys to hex format. Used for formating region in logs.
func (HexRegionsMeta) String ¶
func (h HexRegionsMeta) String() string
type KeyRange ¶
KeyRange is a key range.
func NewKeyRange ¶
NewKeyRange create a KeyRange with the given start key and end key.
type PeerInfo ¶
PeerInfo provides peer information
func NewPeerInfo ¶
NewPeerInfo creates PeerInfo
func (*PeerInfo) GetInterval ¶
GetInterval returns reporting interval
type RegionCreateOption ¶
type RegionCreateOption func(region *RegionInfo)
RegionCreateOption used to create region.
func AddQueryStats ¶
func AddQueryStats(v *pdpb.QueryStats) RegionCreateOption
AddQueryStats sets the query stats for the region, it will preserve previous statistic. This func is only used for test and simulator.
func SetApproximateKeys ¶
func SetApproximateKeys(v int64) RegionCreateOption
SetApproximateKeys sets the approximate keys for the region.
func SetApproximateSize ¶
func SetApproximateSize(v int64) RegionCreateOption
SetApproximateSize sets the approximate size for the region.
func SetBuckets ¶
func SetBuckets(buckets *metapb.Buckets) RegionCreateOption
SetBuckets sets the buckets for the region, only use test.
func SetCPUUsage ¶
func SetCPUUsage(v uint64) RegionCreateOption
SetCPUUsage sets the CPU usage of the region.
func SetFromHeartbeat ¶
func SetFromHeartbeat(fromHeartbeat bool) RegionCreateOption
SetFromHeartbeat sets if the region info comes from the region heartbeat.
func SetPeers ¶
func SetPeers(peers []*metapb.Peer) RegionCreateOption
SetPeers sets the peers for the region.
func SetQueryStats ¶
func SetQueryStats(v *pdpb.QueryStats) RegionCreateOption
SetQueryStats sets the query stats for the region, it will cover previous statistic. This func is only used for unit test.
func SetReadBytes ¶
func SetReadBytes(v uint64) RegionCreateOption
SetReadBytes sets the read bytes for the region.
func SetReadKeys ¶
func SetReadKeys(v uint64) RegionCreateOption
SetReadKeys sets the read keys for the region.
func SetReadQuery ¶
func SetReadQuery(v uint64) RegionCreateOption
SetReadQuery sets the read query for the region, only used for unit test.
func SetRegionConfVer ¶
func SetRegionConfVer(confVer uint64) RegionCreateOption
SetRegionConfVer sets the config version for the region.
func SetRegionVersion ¶
func SetRegionVersion(version uint64) RegionCreateOption
SetRegionVersion sets the version for the region.
func SetReplicationStatus ¶
func SetReplicationStatus(status *replication_modepb.RegionReplicationStatus) RegionCreateOption
SetReplicationStatus sets the region's replication status.
func SetReportInterval ¶
func SetReportInterval(start, end uint64) RegionCreateOption
SetReportInterval sets the report interval for the region. This func is only used for test.
func SetWrittenBytes ¶
func SetWrittenBytes(v uint64) RegionCreateOption
SetWrittenBytes sets the written bytes for the region.
func SetWrittenKeys ¶
func SetWrittenKeys(v uint64) RegionCreateOption
SetWrittenKeys sets the written keys for the region.
func SetWrittenQuery ¶
func SetWrittenQuery(v uint64) RegionCreateOption
SetWrittenQuery sets the write query for the region, only used for unit test.
func WithAddPeer ¶
func WithAddPeer(peer *metapb.Peer) RegionCreateOption
WithAddPeer adds a peer for the region.
func WithDecConfVer ¶
func WithDecConfVer() RegionCreateOption
WithDecConfVer decreases the config version of the region.
func WithDecVersion ¶
func WithDecVersion() RegionCreateOption
WithDecVersion decreases the version of the region.
func WithDownPeers ¶
func WithDownPeers(downPeers []*pdpb.PeerStats) RegionCreateOption
WithDownPeers sets the down peers for the region.
func WithEndKey ¶
func WithEndKey(key []byte) RegionCreateOption
WithEndKey sets the end key for the region.
func WithFlowRoundByDigit ¶
func WithFlowRoundByDigit(digit int) RegionCreateOption
WithFlowRoundByDigit set the digit, which use to round to the nearest number
func WithIncConfVer ¶
func WithIncConfVer() RegionCreateOption
WithIncConfVer increases the config version of the region.
func WithIncVersion ¶
func WithIncVersion() RegionCreateOption
WithIncVersion increases the version of the region.
func WithInterval ¶
func WithInterval(interval *pdpb.TimeInterval) RegionCreateOption
WithInterval sets the interval
func WithLeader ¶
func WithLeader(leader *metapb.Peer) RegionCreateOption
WithLeader sets the leader for the region.
func WithLearners ¶
func WithLearners(learners []*metapb.Peer) RegionCreateOption
WithLearners sets the learners for the region.
func WithNewPeerIDs ¶
func WithNewPeerIDs(peerIDs ...uint64) RegionCreateOption
WithNewPeerIDs sets new ids for peers.
func WithNewRegionID ¶
func WithNewRegionID(id uint64) RegionCreateOption
WithNewRegionID sets new id for the region.
func WithPendingPeers ¶
func WithPendingPeers(pendingPeers []*metapb.Peer) RegionCreateOption
WithPendingPeers sets the pending peers for the region.
func WithRemoveStorePeer ¶
func WithRemoveStorePeer(storeID uint64) RegionCreateOption
WithRemoveStorePeer removes the specified peer for the region.
func WithReplacePeerStore ¶
func WithReplacePeerStore(oldStoreID, newStoreID uint64) RegionCreateOption
WithReplacePeerStore replaces a peer's storeID with another ID.
func WithRole ¶
func WithRole(peerID uint64, role metapb.PeerRole) RegionCreateOption
WithRole changes the role.
func WithStartKey ¶
func WithStartKey(key []byte) RegionCreateOption
WithStartKey sets the start key for the region.
func WithWitness ¶
func WithWitness(peerID uint64) RegionCreateOption
WithWitness sets the witness for the region.
func WithWitnesses ¶
func WithWitnesses(witnesses []*metapb.Peer) RegionCreateOption
WithWitnesses sets the witnesses for the region.
type RegionGuideFunc ¶
type RegionGuideFunc func(region, origin *RegionInfo) (isNew, saveKV, saveCache, needSync bool)
RegionGuideFunc is a function that determines which follow-up operations need to be performed based on the origin and new region information.
func GenerateRegionGuideFunc ¶
func GenerateRegionGuideFunc(enableLog bool) RegionGuideFunc
GenerateRegionGuideFunc is used to generate a RegionGuideFunc. Control the log output by specifying the log function. nil means do not print the log.
type RegionInfo ¶
type RegionInfo struct {
// contains filtered or unexported fields
}
RegionInfo records detail region info. the properties are Read-Only once created except buckets. the `buckets` could be modified by the request `report buckets` with greater version.
func MergeRegions ¶
func MergeRegions(regions []*RegionInfo) []*RegionInfo
MergeRegions merge a set of RegionInfo by regionKey. Only for test purpose.
func NewRegionInfo ¶
func NewRegionInfo(region *metapb.Region, leader *metapb.Peer, opts ...RegionCreateOption) *RegionInfo
NewRegionInfo creates RegionInfo with region's meta and leader peer.
func NewTestRegionInfo ¶
func NewTestRegionInfo(regionID, storeID uint64, start, end []byte, opts ...RegionCreateOption) *RegionInfo
NewTestRegionInfo creates a new RegionInfo for test purpose.
func RegionFromHeartbeat ¶
func RegionFromHeartbeat(heartbeat *pdpb.RegionHeartbeatRequest, opts ...RegionCreateOption) *RegionInfo
RegionFromHeartbeat constructs a Region from region heartbeat.
func SplitRegions ¶
func SplitRegions(regions []*RegionInfo) []*RegionInfo
SplitRegions split a set of RegionInfo by the middle of regionKey. Only for test purpose.
func (*RegionInfo) Clone ¶
func (r *RegionInfo) Clone(opts ...RegionCreateOption) *RegionInfo
Clone returns a copy of current regionInfo.
func (*RegionInfo) GetApproximateKeys ¶
func (r *RegionInfo) GetApproximateKeys() int64
GetApproximateKeys returns the approximate keys of the region.
func (*RegionInfo) GetApproximateSize ¶
func (r *RegionInfo) GetApproximateSize() int64
GetApproximateSize returns the approximate size of the region.
func (*RegionInfo) GetBuckets ¶
func (r *RegionInfo) GetBuckets() *metapb.Buckets
GetBuckets returns the buckets of the region.
func (*RegionInfo) GetBytesRead ¶
func (r *RegionInfo) GetBytesRead() uint64
GetBytesRead returns the read bytes of the region.
func (*RegionInfo) GetBytesWritten ¶
func (r *RegionInfo) GetBytesWritten() uint64
GetBytesWritten returns the written bytes of the region.
func (*RegionInfo) GetCPUUsage ¶
func (r *RegionInfo) GetCPUUsage() uint64
GetCPUUsage returns the CPU usage of the region since the last heartbeat. The number range is [0, N * 100], where N is the number of CPU cores. However, since the TiKV basically only meters the CPU usage inside the Unified Read Pool, it should be considered as an indicator of Region read CPU overhead for now.
func (*RegionInfo) GetDiffFollowers ¶
func (r *RegionInfo) GetDiffFollowers(other *RegionInfo) []*metapb.Peer
GetDiffFollowers returns the followers which is not located in the same store as any other followers of the another specified region.
func (*RegionInfo) GetDownLearner ¶
func (r *RegionInfo) GetDownLearner(peerID uint64) *metapb.Peer
GetDownLearner returns the down learner with soecified peer id.
func (*RegionInfo) GetDownPeer ¶
func (r *RegionInfo) GetDownPeer(peerID uint64) *metapb.Peer
GetDownPeer returns the down peer with specified peer id.
func (*RegionInfo) GetDownPeers ¶
func (r *RegionInfo) GetDownPeers() []*pdpb.PeerStats
GetDownPeers returns the down peers of the region.
func (*RegionInfo) GetDownVoter ¶
func (r *RegionInfo) GetDownVoter(peerID uint64) *metapb.Peer
GetDownVoter returns the down voter with specified peer id.
func (*RegionInfo) GetEndKey ¶
func (r *RegionInfo) GetEndKey() []byte
GetEndKey returns the end key of the region.
func (*RegionInfo) GetFollower ¶
func (r *RegionInfo) GetFollower() *metapb.Peer
GetFollower randomly returns a follow peer.
func (*RegionInfo) GetFollowers ¶
func (r *RegionInfo) GetFollowers() map[uint64]*metapb.Peer
GetFollowers returns a map indicate the follow peers distributed.
func (*RegionInfo) GetInterval ¶
func (r *RegionInfo) GetInterval() *pdpb.TimeInterval
GetInterval returns the interval information of the region.
func (*RegionInfo) GetKeysRead ¶
func (r *RegionInfo) GetKeysRead() uint64
GetKeysRead returns the read keys of the region.
func (*RegionInfo) GetKeysWritten ¶
func (r *RegionInfo) GetKeysWritten() uint64
GetKeysWritten returns the written keys of the region.
func (*RegionInfo) GetLeader ¶
func (r *RegionInfo) GetLeader() *metapb.Peer
GetLeader returns the leader of the region.
func (*RegionInfo) GetLearners ¶
func (r *RegionInfo) GetLearners() []*metapb.Peer
GetLearners returns the learners.
func (*RegionInfo) GetLoads ¶
func (r *RegionInfo) GetLoads() []float64
GetLoads returns loads from region
func (*RegionInfo) GetMeta ¶
func (r *RegionInfo) GetMeta() *metapb.Region
GetMeta returns the meta information of the region.
func (*RegionInfo) GetNonWitnessVoters ¶
func (r *RegionInfo) GetNonWitnessVoters() map[uint64]*metapb.Peer
GetNonWitnessVoters returns a map indicate the non-witness voter peers distributed.
func (*RegionInfo) GetPeer ¶
func (r *RegionInfo) GetPeer(peerID uint64) *metapb.Peer
GetPeer returns the peer with specified peer id.
func (*RegionInfo) GetPeers ¶
func (r *RegionInfo) GetPeers() []*metapb.Peer
GetPeers returns the peers of the region.
func (*RegionInfo) GetPendingLearner ¶
func (r *RegionInfo) GetPendingLearner(peerID uint64) *metapb.Peer
GetPendingLearner returns the pending learner peer with specified peer id.
func (*RegionInfo) GetPendingPeer ¶
func (r *RegionInfo) GetPendingPeer(peerID uint64) *metapb.Peer
GetPendingPeer returns the pending peer with specified peer id.
func (*RegionInfo) GetPendingPeers ¶
func (r *RegionInfo) GetPendingPeers() []*metapb.Peer
GetPendingPeers returns the pending peers of the region.
func (*RegionInfo) GetPendingVoter ¶
func (r *RegionInfo) GetPendingVoter(peerID uint64) *metapb.Peer
GetPendingVoter returns the pending voter with specified peer id.
func (*RegionInfo) GetReadQueryNum ¶
func (r *RegionInfo) GetReadQueryNum() uint64
GetReadQueryNum returns read query num from this region
func (*RegionInfo) GetRegionEpoch ¶
func (r *RegionInfo) GetRegionEpoch() *metapb.RegionEpoch
GetRegionEpoch returns the region epoch of the region.
func (*RegionInfo) GetReplicationStatus ¶
func (r *RegionInfo) GetReplicationStatus() *replication_modepb.RegionReplicationStatus
GetReplicationStatus returns the region's replication status.
func (*RegionInfo) GetRoundBytesRead ¶
func (r *RegionInfo) GetRoundBytesRead() uint64
GetRoundBytesRead returns the read bytes of the region.
func (*RegionInfo) GetRoundBytesWritten ¶
func (r *RegionInfo) GetRoundBytesWritten() uint64
GetRoundBytesWritten returns the written bytes of the region.
func (*RegionInfo) GetStartKey ¶
func (r *RegionInfo) GetStartKey() []byte
GetStartKey returns the start key of the region.
func (*RegionInfo) GetStat ¶
func (r *RegionInfo) GetStat() *pdpb.RegionStat
GetStat returns the statistics of the region.
func (*RegionInfo) GetStoreIDs ¶
func (r *RegionInfo) GetStoreIDs() map[uint64]struct{}
GetStoreIDs returns a map indicate the region distributed.
func (*RegionInfo) GetStoreLearner ¶
func (r *RegionInfo) GetStoreLearner(storeID uint64) *metapb.Peer
GetStoreLearner returns the learner peer in specified store.
func (*RegionInfo) GetStorePeer ¶
func (r *RegionInfo) GetStorePeer(storeID uint64) *metapb.Peer
GetStorePeer returns the peer in specified store.
func (*RegionInfo) GetStorePeerApproximateKeys ¶
func (r *RegionInfo) GetStorePeerApproximateKeys(storeID uint64) int64
GetStorePeerApproximateKeys returns the approximate keys of the peer on the specified store.
func (*RegionInfo) GetStorePeerApproximateSize ¶
func (r *RegionInfo) GetStorePeerApproximateSize(storeID uint64) int64
GetStorePeerApproximateSize returns the approximate size of the peer on the specified store.
func (*RegionInfo) GetStoreVoter ¶
func (r *RegionInfo) GetStoreVoter(storeID uint64) *metapb.Peer
GetStoreVoter returns the voter in specified store.
func (*RegionInfo) GetStoreWitness ¶
func (r *RegionInfo) GetStoreWitness(storeID uint64) *metapb.Peer
GetStoreWitness returns the witness peer in specified store.
func (*RegionInfo) GetTerm ¶
func (r *RegionInfo) GetTerm() uint64
GetTerm returns the current term of the region
func (*RegionInfo) GetVoters ¶
func (r *RegionInfo) GetVoters() []*metapb.Peer
GetVoters returns the voters.
func (*RegionInfo) GetWitnesses ¶
func (r *RegionInfo) GetWitnesses() []*metapb.Peer
GetWitnesses returns the witnesses.
func (*RegionInfo) GetWriteLoads ¶
func (r *RegionInfo) GetWriteLoads() []float64
GetWriteLoads returns write loads from region
func (*RegionInfo) GetWriteQueryNum ¶
func (r *RegionInfo) GetWriteQueryNum() uint64
GetWriteQueryNum returns write query num from this region
func (*RegionInfo) GetWriteRate ¶
func (r *RegionInfo) GetWriteRate() (bytesRate, keysRate float64)
GetWriteRate returns the write rate of the region.
func (*RegionInfo) Inherit ¶
func (r *RegionInfo) Inherit(origin *RegionInfo, bucketEnable bool)
Inherit inherits the buckets and region size from the parent region if bucket enabled. correct approximate size and buckets by the previous size if here exists a reported RegionInfo. See https://github.com/tikv/tikv/issues/11114
func (*RegionInfo) IsFromHeartbeat ¶
func (r *RegionInfo) IsFromHeartbeat() bool
IsFromHeartbeat returns whether the region info is from the region heartbeat.
func (*RegionInfo) IsOversized ¶
func (r *RegionInfo) IsOversized(maxSize int64, maxKeys int64) bool
IsOversized indicates whether the region is oversized.
func (*RegionInfo) NeedMerge ¶
func (r *RegionInfo) NeedMerge(mergeSize int64, mergeKeys int64) bool
NeedMerge returns true if size is less than merge size and keys is less than mergeKeys.
func (*RegionInfo) UpdateBuckets ¶
func (r *RegionInfo) UpdateBuckets(buckets, old *metapb.Buckets) bool
UpdateBuckets sets the buckets of the region.
type RegionSetInformer ¶
type RegionSetInformer interface { GetRegionCount() int RandFollowerRegions(storeID uint64, ranges []KeyRange) []*RegionInfo RandLeaderRegions(storeID uint64, ranges []KeyRange) []*RegionInfo RandLearnerRegions(storeID uint64, ranges []KeyRange) []*RegionInfo RandWitnessRegions(storeID uint64, ranges []KeyRange) []*RegionInfo RandPendingRegions(storeID uint64, ranges []KeyRange) []*RegionInfo GetAverageRegionSize() int64 GetStoreRegionCount(storeID uint64) int GetRegion(id uint64) *RegionInfo GetAdjacentRegions(region *RegionInfo) (*RegionInfo, *RegionInfo) ScanRegions(startKey, endKey []byte, limit int) []*RegionInfo GetRegionByKey(regionKey []byte) *RegionInfo }
RegionSetInformer provides access to a shared informer of regions.
type RegionsInfo ¶
type RegionsInfo struct {
// contains filtered or unexported fields
}
RegionsInfo for export
func NewRegionsInfo ¶
func NewRegionsInfo() *RegionsInfo
NewRegionsInfo creates RegionsInfo with tree, regions, leaders and followers
func (*RegionsInfo) AtomicCheckAndPutRegion ¶
func (r *RegionsInfo) AtomicCheckAndPutRegion(region *RegionInfo) ([]*RegionInfo, error)
AtomicCheckAndPutRegion checks if the region is valid to put, if valid then put.
func (*RegionsInfo) CheckAndPutRegion ¶
func (r *RegionsInfo) CheckAndPutRegion(region *RegionInfo) []*RegionInfo
CheckAndPutRegion checks if the region is valid to put, if valid then put.
func (*RegionsInfo) GetAdjacentRegions ¶
func (r *RegionsInfo) GetAdjacentRegions(region *RegionInfo) (*RegionInfo, *RegionInfo)
GetAdjacentRegions returns region's info that is adjacent with specific region
func (*RegionsInfo) GetAverageRegionSize ¶
func (r *RegionsInfo) GetAverageRegionSize() int64
GetAverageRegionSize returns the average region approximate size.
func (*RegionsInfo) GetFollower ¶
func (r *RegionsInfo) GetFollower(storeID uint64, region *RegionInfo) *RegionInfo
GetFollower returns follower RegionInfo by storeID and regionID (now only used in test)
func (*RegionsInfo) GetLeader ¶
func (r *RegionsInfo) GetLeader(storeID uint64, region *RegionInfo) *RegionInfo
GetLeader returns leader RegionInfo by storeID and regionID (now only used in test)
func (*RegionsInfo) GetMetaRegions ¶
func (r *RegionsInfo) GetMetaRegions() []*metapb.Region
GetMetaRegions gets a set of metapb.Region from regionMap
func (*RegionsInfo) GetOverlaps ¶
func (r *RegionsInfo) GetOverlaps(region *RegionInfo) []*regionItem
GetOverlaps returns the regions which are overlapped with the specified region range.
func (*RegionsInfo) GetPrevRegionByKey ¶
func (r *RegionsInfo) GetPrevRegionByKey(regionKey []byte) *RegionInfo
GetPrevRegionByKey searches previous RegionInfo from regionTree
func (*RegionsInfo) GetRangeCount ¶
func (r *RegionsInfo) GetRangeCount(startKey, endKey []byte) int
GetRangeCount returns the number of regions that overlap with the range [startKey, endKey).
func (*RegionsInfo) GetRangeHoles ¶
func (r *RegionsInfo) GetRangeHoles() [][]string
GetRangeHoles returns all range holes, i.e the key ranges without any region info.
func (*RegionsInfo) GetRegion ¶
func (r *RegionsInfo) GetRegion(regionID uint64) *RegionInfo
GetRegion returns the RegionInfo with regionID
func (*RegionsInfo) GetRegionByKey ¶
func (r *RegionsInfo) GetRegionByKey(regionKey []byte) *RegionInfo
GetRegionByKey searches RegionInfo from regionTree
func (*RegionsInfo) GetRegionCount ¶
func (r *RegionsInfo) GetRegionCount() int
GetRegionCount gets the total count of RegionInfo of regionMap
func (*RegionsInfo) GetRegionSizeByRange ¶
func (r *RegionsInfo) GetRegionSizeByRange(startKey, endKey []byte) int64
GetRegionSizeByRange scans regions intersecting [start key, end key), returns the total region size of this range.
func (*RegionsInfo) GetRegions ¶
func (r *RegionsInfo) GetRegions() []*RegionInfo
GetRegions gets all RegionInfo from regionMap
func (*RegionsInfo) GetRelevantRegions ¶
func (r *RegionsInfo) GetRelevantRegions(region *RegionInfo) (origin *RegionInfo, overlaps []*regionItem)
GetRelevantRegions returns the relevant regions for a given region.
func (*RegionsInfo) GetStoreFollowerCount ¶
func (r *RegionsInfo) GetStoreFollowerCount(storeID uint64) int
GetStoreFollowerCount get the total count of a store's follower RegionInfo
func (*RegionsInfo) GetStoreFollowerRegionSize ¶
func (r *RegionsInfo) GetStoreFollowerRegionSize(storeID uint64) int64
GetStoreFollowerRegionSize get total size of store's follower regions
func (*RegionsInfo) GetStoreLeaderCount ¶
func (r *RegionsInfo) GetStoreLeaderCount(storeID uint64) int
GetStoreLeaderCount get the total count of a store's leader RegionInfo
func (*RegionsInfo) GetStoreLeaderRegionSize ¶
func (r *RegionsInfo) GetStoreLeaderRegionSize(storeID uint64) int64
GetStoreLeaderRegionSize get total size of store's leader regions
func (*RegionsInfo) GetStoreLeaderWriteRate ¶
func (r *RegionsInfo) GetStoreLeaderWriteRate(storeID uint64) (bytesRate, keysRate float64)
GetStoreLeaderWriteRate get total write rate of store's leaders
func (*RegionsInfo) GetStoreLearnerCount ¶
func (r *RegionsInfo) GetStoreLearnerCount(storeID uint64) int
GetStoreLearnerCount get the total count of a store's learner RegionInfo
func (*RegionsInfo) GetStoreLearnerRegionSize ¶
func (r *RegionsInfo) GetStoreLearnerRegionSize(storeID uint64) int64
GetStoreLearnerRegionSize get total size of store's learner regions
func (*RegionsInfo) GetStorePendingPeerCount ¶
func (r *RegionsInfo) GetStorePendingPeerCount(storeID uint64) int
GetStorePendingPeerCount gets the total count of a store's region that includes pending peer
func (*RegionsInfo) GetStoreRegionCount ¶
func (r *RegionsInfo) GetStoreRegionCount(storeID uint64) int
GetStoreRegionCount gets the total count of a store's leader, follower and learner RegionInfo by storeID
func (*RegionsInfo) GetStoreRegionSize ¶
func (r *RegionsInfo) GetStoreRegionSize(storeID uint64) int64
GetStoreRegionSize get total size of store's regions
func (*RegionsInfo) GetStoreRegions ¶
func (r *RegionsInfo) GetStoreRegions(storeID uint64) []*RegionInfo
GetStoreRegions gets all RegionInfo with a given storeID
func (*RegionsInfo) GetStoreStats ¶
func (r *RegionsInfo) GetStoreStats(storeID uint64) (leader, region, witness, learner, pending int, leaderSize, regionSize int64)
GetStoreStats returns the store stats.
func (*RegionsInfo) GetStoreWitnessCount ¶
func (r *RegionsInfo) GetStoreWitnessCount(storeID uint64) int
GetStoreWitnessCount get the total count of a store's witness RegionInfo
func (*RegionsInfo) GetStoreWriteRate ¶
func (r *RegionsInfo) GetStoreWriteRate(storeID uint64) (bytesRate, keysRate float64)
GetStoreWriteRate get total write rate of store's regions
func (*RegionsInfo) PreCheckPutRegion ¶
func (r *RegionsInfo) PreCheckPutRegion(region *RegionInfo) (*RegionInfo, []*regionItem, error)
PreCheckPutRegion checks if the region is valid to put.
func (*RegionsInfo) PutRegion ¶
func (r *RegionsInfo) PutRegion(region *RegionInfo) []*RegionInfo
PutRegion put a region.
func (*RegionsInfo) RandFollowerRegion ¶
func (r *RegionsInfo) RandFollowerRegion(storeID uint64, ranges []KeyRange) *RegionInfo
RandFollowerRegion randomly gets a store's follower region.
func (*RegionsInfo) RandFollowerRegions ¶
func (r *RegionsInfo) RandFollowerRegions(storeID uint64, ranges []KeyRange) []*RegionInfo
RandFollowerRegions randomly gets a store's n follower regions.
func (*RegionsInfo) RandLeaderRegion ¶
func (r *RegionsInfo) RandLeaderRegion(storeID uint64, ranges []KeyRange) *RegionInfo
RandLeaderRegion randomly gets a store's leader region.
func (*RegionsInfo) RandLeaderRegions ¶
func (r *RegionsInfo) RandLeaderRegions(storeID uint64, ranges []KeyRange) []*RegionInfo
RandLeaderRegions randomly gets a store's n leader regions.
func (*RegionsInfo) RandLearnerRegion ¶
func (r *RegionsInfo) RandLearnerRegion(storeID uint64, ranges []KeyRange) *RegionInfo
RandLearnerRegion randomly gets a store's learner region.
func (*RegionsInfo) RandLearnerRegions ¶
func (r *RegionsInfo) RandLearnerRegions(storeID uint64, ranges []KeyRange) []*RegionInfo
RandLearnerRegions randomly gets a store's n learner regions.
func (*RegionsInfo) RandPendingRegion ¶
func (r *RegionsInfo) RandPendingRegion(storeID uint64, ranges []KeyRange) *RegionInfo
RandPendingRegion randomly gets a store's region with a pending peer.
func (*RegionsInfo) RandPendingRegions ¶
func (r *RegionsInfo) RandPendingRegions(storeID uint64, ranges []KeyRange) []*RegionInfo
RandPendingRegions randomly gets a store's n regions with a pending peer.
func (*RegionsInfo) RandWitnessRegion ¶
func (r *RegionsInfo) RandWitnessRegion(storeID uint64, ranges []KeyRange) *RegionInfo
RandWitnessRegion randomly gets a store's witness region.
func (*RegionsInfo) RandWitnessRegions ¶
func (r *RegionsInfo) RandWitnessRegions(storeID uint64, ranges []KeyRange) []*RegionInfo
RandWitnessRegions randomly gets a store's n witness regions.
func (*RegionsInfo) RemoveRegion ¶
func (r *RegionsInfo) RemoveRegion(region *RegionInfo)
RemoveRegion removes RegionInfo from regionTree and regionMap
func (*RegionsInfo) RemoveRegionFromSubTree ¶
func (r *RegionsInfo) RemoveRegionFromSubTree(region *RegionInfo)
RemoveRegionFromSubTree removes RegionInfo from regionSubTrees
func (*RegionsInfo) RemoveRegionIfExist ¶
func (r *RegionsInfo) RemoveRegionIfExist(id uint64)
RemoveRegionIfExist removes RegionInfo from regionTree and regionMap if exists.
func (*RegionsInfo) ResetRegionCache ¶
func (r *RegionsInfo) ResetRegionCache()
ResetRegionCache resets the regions info.
func (*RegionsInfo) ScanRange ¶
func (r *RegionsInfo) ScanRange(startKey, endKey []byte, limit int) []*RegionInfo
ScanRange scans regions intersecting [start key, end key), returns at most `limit` regions. limit <= 0 means no limit.
func (*RegionsInfo) ScanRangeWithIterator ¶
func (r *RegionsInfo) ScanRangeWithIterator(startKey []byte, iterator func(region *RegionInfo) bool)
ScanRangeWithIterator scans from the first region containing or behind start key, until iterator returns false.
func (*RegionsInfo) SetRegion ¶
func (r *RegionsInfo) SetRegion(region *RegionInfo) (*RegionInfo, []*RegionInfo, bool)
SetRegion sets the RegionInfo to regionTree and regionMap and return the update info of subtree.
func (*RegionsInfo) TreeLen ¶
func (r *RegionsInfo) TreeLen() int
TreeLen returns the RegionsInfo tree length(now only used in test)
func (*RegionsInfo) UpdateSubTree ¶
func (r *RegionsInfo) UpdateSubTree(region, origin *RegionInfo, overlaps []*RegionInfo, rangeChanged bool)
UpdateSubTree updates the subtree.
type StoreCreateOption ¶
type StoreCreateOption func(store *StoreInfo)
StoreCreateOption is used to create store.
func OfflineStore ¶
func OfflineStore(physicallyDestroyed bool) StoreCreateOption
OfflineStore offline a store
func PauseLeaderTransfer ¶
func PauseLeaderTransfer() StoreCreateOption
PauseLeaderTransfer prevents the store from been selected as source or target store of TransferLeader.
func ResetStoreLimit ¶
func ResetStoreLimit(limitType storelimit.Type, ratePerSec ...float64) StoreCreateOption
ResetStoreLimit resets the store limit for a store.
func ResumeLeaderTransfer ¶
func ResumeLeaderTransfer() StoreCreateOption
ResumeLeaderTransfer cleans a store's pause state. The store can be selected as source or target of TransferLeader again.
func SetLastAwakenTime ¶
func SetLastAwakenTime(lastAwaken time.Time) StoreCreateOption
SetLastAwakenTime sets last awaken time for the store.
func SetLastHeartbeatTS ¶
func SetLastHeartbeatTS(lastHeartbeatTS time.Time) StoreCreateOption
SetLastHeartbeatTS sets the time of last heartbeat for the store.
func SetLastPersistTime ¶
func SetLastPersistTime(lastPersist time.Time) StoreCreateOption
SetLastPersistTime updates the time of last persistent.
func SetLeaderCount ¶
func SetLeaderCount(leaderCount int) StoreCreateOption
SetLeaderCount sets the leader count for the store.
func SetLeaderSize ¶
func SetLeaderSize(leaderSize int64) StoreCreateOption
SetLeaderSize sets the leader size for the store.
func SetLeaderWeight ¶
func SetLeaderWeight(leaderWeight float64) StoreCreateOption
SetLeaderWeight sets the leader weight for the store.
func SetLearnerCount ¶
func SetLearnerCount(learnerCount int) StoreCreateOption
SetLearnerCount sets the learner count for the store.
func SetMinResolvedTS ¶
func SetMinResolvedTS(minResolvedTS uint64) StoreCreateOption
SetMinResolvedTS sets min resolved ts for the store.
func SetNewStoreStats ¶
func SetNewStoreStats(stats *pdpb.StoreStats) StoreCreateOption
SetNewStoreStats sets the raw statistics information for the store.
func SetPendingPeerCount ¶
func SetPendingPeerCount(pendingPeerCount int) StoreCreateOption
SetPendingPeerCount sets the pending peer count for the store.
func SetRegionCount ¶
func SetRegionCount(regionCount int) StoreCreateOption
SetRegionCount sets the Region count for the store.
func SetRegionSize ¶
func SetRegionSize(regionSize int64) StoreCreateOption
SetRegionSize sets the Region size for the store.
func SetRegionWeight ¶
func SetRegionWeight(regionWeight float64) StoreCreateOption
SetRegionWeight sets the Region weight for the store.
func SetStoreAddress ¶
func SetStoreAddress(address, statusAddress, peerAddress string) StoreCreateOption
SetStoreAddress sets the address for the store.
func SetStoreDeployPath ¶
func SetStoreDeployPath(deployPath string) StoreCreateOption
SetStoreDeployPath sets the deploy path for the store.
func SetStoreLabels ¶
func SetStoreLabels(labels []*metapb.StoreLabel) StoreCreateOption
SetStoreLabels sets the labels for the store.
func SetStoreLimit ¶
func SetStoreLimit(limit storelimit.StoreLimit) StoreCreateOption
SetStoreLimit set the store for a store, it may switch the store limit mode.
func SetStoreStartTime ¶
func SetStoreStartTime(startTS int64) StoreCreateOption
SetStoreStartTime sets the start timestamp for the store.
func SetStoreStats ¶
func SetStoreStats(stats *pdpb.StoreStats) StoreCreateOption
SetStoreStats sets the statistics information for the store.
func SetStoreVersion ¶
func SetStoreVersion(githash, version string) StoreCreateOption
SetStoreVersion sets the version for the store.
func SetWitnessCount ¶
func SetWitnessCount(witnessCount int) StoreCreateOption
SetWitnessCount sets the witness count for the store.
func SlowStoreEvicted ¶
func SlowStoreEvicted() StoreCreateOption
SlowStoreEvicted marks a store as a slow store and prevents transferring leader to the store
func SlowStoreRecovered ¶
func SlowStoreRecovered() StoreCreateOption
SlowStoreRecovered cleans the evicted state of a store.
func SlowTrendEvicted ¶
func SlowTrendEvicted() StoreCreateOption
SlowTrendEvicted marks a store as a slow store by trend and prevents transferring leader to the store
func SlowTrendRecovered ¶
func SlowTrendRecovered() StoreCreateOption
SlowTrendRecovered cleans the evicted by slow trend state of a store.
func TombstoneStore ¶
func TombstoneStore() StoreCreateOption
TombstoneStore set a store to tombstone.
type StoreInfo ¶
type StoreInfo struct {
// contains filtered or unexported fields
}
StoreInfo contains information about a store. NOTE: This type is exported by HTTP API. Please pay more attention when modifying it.
func NewStoreInfo ¶
func NewStoreInfo(store *metapb.Store, opts ...StoreCreateOption) *StoreInfo
NewStoreInfo creates StoreInfo with meta data.
func NewStoreInfoWithLabel ¶
NewStoreInfoWithLabel is create a store with specified labels. only for test purpose.
func (*StoreInfo) AllowLeaderTransfer ¶
AllowLeaderTransfer returns if the store is allowed to be selected as source or target of transfer leader.
func (*StoreInfo) AvailableRatio ¶
AvailableRatio is store's freeSpace/capacity.
func (*StoreInfo) Clone ¶
func (s *StoreInfo) Clone(opts ...StoreCreateOption) *StoreInfo
Clone creates a copy of current StoreInfo.
func (StoreInfo) CloneStoreStats ¶
func (ss StoreInfo) CloneStoreStats() *pdpb.StoreStats
CloneStoreStats returns the statistics information cloned from the store.
func (*StoreInfo) CompareLocation ¶
CompareLocation compares 2 stores' labels and returns at which level their locations are different. It returns -1 if they are at the same location.
func (*StoreInfo) EvictedAsSlowStore ¶
EvictedAsSlowStore returns if the store should be evicted as a slow store.
func (*StoreInfo) GetAddress ¶
GetAddress returns the address of the store.
func (StoreInfo) GetAvailable ¶
func (ss StoreInfo) GetAvailable() uint64
GetAvailable returns the available size of the store.
func (StoreInfo) GetAvgAvailable ¶
func (ss StoreInfo) GetAvgAvailable() uint64
GetAvgAvailable returns available size after the spike changes has been smoothed.
func (StoreInfo) GetBytesRead ¶
func (ss StoreInfo) GetBytesRead() uint64
GetBytesRead returns the bytes read for the store during this period.
func (StoreInfo) GetBytesWritten ¶
func (ss StoreInfo) GetBytesWritten() uint64
GetBytesWritten returns the bytes written for the store during this period.
func (StoreInfo) GetCapacity ¶
func (ss StoreInfo) GetCapacity() uint64
GetCapacity returns the capacity size of the store.
func (StoreInfo) GetKeysRead ¶
func (ss StoreInfo) GetKeysRead() uint64
GetKeysRead returns the keys read for the store during this period.
func (StoreInfo) GetKeysWritten ¶
func (ss StoreInfo) GetKeysWritten() uint64
GetKeysWritten returns the keys written for the store during this period.
func (*StoreInfo) GetLabelValue ¶
GetLabelValue returns a label's value (if exists).
func (*StoreInfo) GetLabels ¶
func (s *StoreInfo) GetLabels() []*metapb.StoreLabel
GetLabels returns the labels of the store.
func (*StoreInfo) GetLastHeartbeatTS ¶
GetLastHeartbeatTS returns the last heartbeat timestamp of the store.
func (*StoreInfo) GetLeaderCount ¶
GetLeaderCount returns the leader count of the store.
func (*StoreInfo) GetLeaderSize ¶
GetLeaderSize returns the leader size of the store.
func (*StoreInfo) GetLeaderWeight ¶
GetLeaderWeight returns the leader weight of the store.
func (*StoreInfo) GetLearnerCount ¶
GetLearnerCount returns the learner count of the store.
func (*StoreInfo) GetMinResolvedTS ¶
GetMinResolvedTS returns min resolved ts.
func (*StoreInfo) GetNodeState ¶
GetNodeState returns the state of the node.
func (*StoreInfo) GetPendingPeerCount ¶
GetPendingPeerCount returns the pending peer count of the store.
func (StoreInfo) GetReceivingSnapCount ¶
func (ss StoreInfo) GetReceivingSnapCount() uint32
GetReceivingSnapCount returns the current receiving snapshot count of the store.
func (*StoreInfo) GetRegionCount ¶
GetRegionCount returns the Region count of the store.
func (*StoreInfo) GetRegionSize ¶
GetRegionSize returns the Region size of the store.
func (*StoreInfo) GetRegionWeight ¶
GetRegionWeight returns the Region weight of the store.
func (StoreInfo) GetSendingSnapCount ¶
func (ss StoreInfo) GetSendingSnapCount() uint32
GetSendingSnapCount returns the current sending snapshot count of the store.
func (*StoreInfo) GetSlowScore ¶
GetSlowScore returns the slow score of the store.
func (*StoreInfo) GetSlowTrend ¶
GetSlowTrend returns the slow trend information of the store.
func (*StoreInfo) GetStartTime ¶
GetStartTime returns the start timestamp.
func (*StoreInfo) GetState ¶
func (s *StoreInfo) GetState() metapb.StoreState
GetState returns the state of the store.
func (*StoreInfo) GetStatusAddress ¶
GetStatusAddress returns the http address of the store.
func (*StoreInfo) GetStoreLimit ¶
func (s *StoreInfo) GetStoreLimit() storelimit.StoreLimit
GetStoreLimit return the limit of a specific store.
func (StoreInfo) GetStoreStats ¶
func (ss StoreInfo) GetStoreStats() *pdpb.StoreStats
GetStoreStats returns the statistics information of the store.
func (StoreInfo) GetUsedSize ¶
func (ss StoreInfo) GetUsedSize() uint64
GetUsedSize returns the used size of the store.
func (*StoreInfo) GetVersion ¶
GetVersion returns the version of the store.
func (*StoreInfo) GetWitnessCount ¶
GetWitnessCount returns the witness count of the store.
func (*StoreInfo) IsAvailable ¶
func (s *StoreInfo) IsAvailable(limitType storelimit.Type, level constant.PriorityLevel) bool
IsAvailable returns if the store bucket of limitation is available
func (*StoreInfo) IsDisconnected ¶
IsDisconnected checks if a store is disconnected, which means PD misses tikv's store heartbeat for a short time, maybe caused by process restart or temporary network failure.
func (*StoreInfo) IsEvictedAsSlowTrend ¶
IsEvictedAsSlowTrend returns if the store should be evicted as a slow store by trend.
func (*StoreInfo) IsLowSpace ¶
IsLowSpace checks if the store is lack of space. Not check if region count less than InitClusterRegionThreshold and available space more than initialMinSpace
func (*StoreInfo) IsPhysicallyDestroyed ¶
IsPhysicallyDestroyed checks if the store's physically destroyed.
func (*StoreInfo) IsPreparing ¶
IsPreparing checks if the store's state is preparing.
func (*StoreInfo) IsRemoving ¶
IsRemoving checks if the store's state is removing.
func (*StoreInfo) IsUnhealthy ¶
IsUnhealthy checks if a store is unhealthy.
func (*StoreInfo) LeaderScore ¶
func (s *StoreInfo) LeaderScore(policy constant.SchedulePolicy, delta int64) float64
LeaderScore returns the store's leader score.
func (*StoreInfo) LimitVersion ¶
LimitVersion returns the limit version of the store.
func (*StoreInfo) NeedAwakenStore ¶
NeedAwakenStore checks whether all hibernated regions in this store should be awaken or not.
func (*StoreInfo) NeedPersist ¶
NeedPersist returns if it needs to save to etcd.
func (*StoreInfo) RegionScore ¶
func (s *StoreInfo) RegionScore(version string, highSpaceRatio, lowSpaceRatio float64, delta int64) float64
RegionScore returns the store's region score. Deviation It is used to control the direction of the deviation considered when calculating the region score. It is set to -1 when it is the source store of balance, 1 when it is the target, and 0 in the rest of cases.
func (*StoreInfo) ResourceCount ¶
func (s *StoreInfo) ResourceCount(kind constant.ResourceKind) uint64
ResourceCount returns count of leader/region in the store.
func (*StoreInfo) ResourceSize ¶
func (s *StoreInfo) ResourceSize(kind constant.ResourceKind) int64
ResourceSize returns size of leader/region in the store
func (*StoreInfo) ResourceWeight ¶
func (s *StoreInfo) ResourceWeight(kind constant.ResourceKind) float64
ResourceWeight returns weight of leader/region in the score
func (*StoreInfo) ShallowClone ¶
func (s *StoreInfo) ShallowClone(opts ...StoreCreateOption) *StoreInfo
ShallowClone creates a copy of current StoreInfo, but not clone 'meta'.
func (*StoreInfo) StorageSize ¶
StorageSize returns store's used storage size reported from tikv.
func (*StoreInfo) WitnessScore ¶
WitnessScore returns the store's witness score.
type StoreSetController ¶
type StoreSetController interface { PauseLeaderTransfer(id uint64) error ResumeLeaderTransfer(id uint64) SlowStoreEvicted(id uint64) error SlowStoreRecovered(id uint64) SlowTrendEvicted(id uint64) error SlowTrendRecovered(id uint64) }
StoreSetController is used to control stores' status.
type StoreSetInformer ¶
type StoreSetInformer interface { GetStores() []*StoreInfo GetStore(id uint64) *StoreInfo GetRegionStores(region *RegionInfo) []*StoreInfo GetNonWitnessVoterStores(region *RegionInfo) []*StoreInfo GetFollowerStores(region *RegionInfo) []*StoreInfo GetLeaderStore(region *RegionInfo) *StoreInfo }
StoreSetInformer provides access to a shared informer of stores.
type StoresInfo ¶
type StoresInfo struct {
// contains filtered or unexported fields
}
StoresInfo contains information about all stores.
func NewStoresInfo ¶
func NewStoresInfo() *StoresInfo
NewStoresInfo create a StoresInfo with map of storeID to StoreInfo
func (*StoresInfo) DeleteStore ¶
func (s *StoresInfo) DeleteStore(store *StoreInfo)
DeleteStore deletes tombstone record form store
func (*StoresInfo) GetMetaStores ¶
func (s *StoresInfo) GetMetaStores() []*metapb.Store
GetMetaStores gets a complete set of metapb.Store.
func (*StoresInfo) GetStore ¶
func (s *StoresInfo) GetStore(storeID uint64) *StoreInfo
GetStore returns a copy of the StoreInfo with the specified storeID.
func (*StoresInfo) GetStoreCount ¶
func (s *StoresInfo) GetStoreCount() int
GetStoreCount returns the total count of storeInfo.
func (*StoresInfo) GetStores ¶
func (s *StoresInfo) GetStores() []*StoreInfo
GetStores gets a complete set of StoreInfo.
func (*StoresInfo) PauseLeaderTransfer ¶
func (s *StoresInfo) PauseLeaderTransfer(storeID uint64) error
PauseLeaderTransfer pauses a StoreInfo with storeID.
func (*StoresInfo) ResetStoreLimit ¶
func (s *StoresInfo) ResetStoreLimit(storeID uint64, limitType storelimit.Type, ratePerSec ...float64)
ResetStoreLimit resets the limit for a specific store.
func (*StoresInfo) ResumeLeaderTransfer ¶
func (s *StoresInfo) ResumeLeaderTransfer(storeID uint64)
ResumeLeaderTransfer cleans a store's pause state. The store can be selected as source or target of TransferLeader again.
func (*StoresInfo) SetLeaderCount ¶
func (s *StoresInfo) SetLeaderCount(storeID uint64, leaderCount int)
SetLeaderCount sets the leader count to a storeInfo.
func (*StoresInfo) SetLeaderSize ¶
func (s *StoresInfo) SetLeaderSize(storeID uint64, leaderSize int64)
SetLeaderSize sets the leader size to a storeInfo.
func (*StoresInfo) SetPendingPeerCount ¶
func (s *StoresInfo) SetPendingPeerCount(storeID uint64, pendingPeerCount int)
SetPendingPeerCount sets the pending count to a storeInfo.
func (*StoresInfo) SetRegionCount ¶
func (s *StoresInfo) SetRegionCount(storeID uint64, regionCount int)
SetRegionCount sets the region count to a storeInfo.
func (*StoresInfo) SetRegionSize ¶
func (s *StoresInfo) SetRegionSize(storeID uint64, regionSize int64)
SetRegionSize sets the region size to a storeInfo.
func (*StoresInfo) SetStore ¶
func (s *StoresInfo) SetStore(store *StoreInfo)
SetStore sets a StoreInfo with storeID.
func (*StoresInfo) SlowStoreEvicted ¶
func (s *StoresInfo) SlowStoreEvicted(storeID uint64) error
SlowStoreEvicted marks a store as a slow store and prevents transferring leader to the store
func (*StoresInfo) SlowStoreRecovered ¶
func (s *StoresInfo) SlowStoreRecovered(storeID uint64)
SlowStoreRecovered cleans the evicted state of a store.
func (*StoresInfo) SlowTrendEvicted ¶
func (s *StoresInfo) SlowTrendEvicted(storeID uint64) error
SlowTrendEvicted marks a store as a slow trend and prevents transferring leader to the store
func (*StoresInfo) SlowTrendRecovered ¶
func (s *StoresInfo) SlowTrendRecovered(storeID uint64)
SlowTrendRecovered cleans the evicted by trend state of a store.
func (*StoresInfo) UpdateStoreStatus ¶
func (s *StoresInfo) UpdateStoreStatus(storeID uint64, leaderCount, regionCount, witnessCount, learnerCount, pendingPeerCount int, leaderSize int64, regionSize int64)
UpdateStoreStatus updates the information of the store.