Documentation ¶
Index ¶
- Constants
- Variables
- func DiffRegionKeyInfo(origin *RegionInfo, other *RegionInfo) string
- func DiffRegionPeersInfo(origin *RegionInfo, other *RegionInfo) string
- func MergeRegions(regions []*metapb.Region) []*metapb.Region
- func NewRegion(start, end []byte) *metapb.Region
- func SplitRegions(regions []*metapb.Region) []*metapb.Region
- type HotRegionsStat
- type IDAllocator
- type KV
- func (kv *KV) ClusterStatePath(option string) string
- func (kv *KV) DeleteRegion(region *metapb.Region) error
- func (kv *KV) LoadConfig(cfg interface{}) (bool, error)
- func (kv *KV) LoadMeta(meta *metapb.Cluster) (bool, error)
- func (kv *KV) LoadRegion(regionID uint64, region *metapb.Region) (bool, error)
- func (kv *KV) LoadRegions(regions *RegionsInfo, rangeLimit int) error
- func (kv *KV) LoadStore(storeID uint64, store *metapb.Store) (bool, error)
- func (kv *KV) LoadStores(stores *StoresInfo, rangeLimit int) error
- func (kv *KV) SaveConfig(cfg interface{}) error
- func (kv *KV) SaveMeta(meta *metapb.Cluster) error
- func (kv *KV) SaveRegion(region *metapb.Region) error
- func (kv *KV) SaveStore(store *metapb.Store) error
- func (kv *KV) SaveStoreWeight(storeID uint64, leader, region float64) error
- type KVBase
- type MockIDAllocator
- type PriorityLevel
- type RegionInfo
- func (r *RegionInfo) AddPeer(peer *metapb.Peer)
- func (r *RegionInfo) Clone() *RegionInfo
- 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) GetDownVoter(peerID uint64) *metapb.Peer
- func (r *RegionInfo) GetFollower() *metapb.Peer
- func (r *RegionInfo) GetFollowers() map[uint64]*metapb.Peer
- func (r *RegionInfo) GetLearners() []*metapb.Peer
- func (r *RegionInfo) GetPeer(peerID uint64) *metapb.Peer
- func (r *RegionInfo) GetPendingLearner(peerID uint64) *metapb.Peer
- func (r *RegionInfo) GetPendingPeer(peerID uint64) *metapb.Peer
- func (r *RegionInfo) GetPendingVoter(peerID uint64) *metapb.Peer
- 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) GetStoreVoter(storeID uint64) *metapb.Peer
- func (r *RegionInfo) GetVoters() []*metapb.Peer
- func (r *RegionInfo) RemoveStorePeer(storeID uint64)
- type RegionOption
- type RegionStat
- type RegionStats
- type RegionsInfo
- func (r *RegionsInfo) AddRegion(region *RegionInfo) []*metapb.Region
- func (r *RegionsInfo) GetAdjacentRegions(region *RegionInfo) (*RegionInfo, *RegionInfo)
- func (r *RegionsInfo) GetFollower(storeID uint64, regionID uint64) *RegionInfo
- func (r *RegionsInfo) GetLeader(storeID uint64, regionID uint64) *RegionInfo
- func (r *RegionsInfo) GetMetaRegions() []*metapb.Region
- func (r *RegionsInfo) GetRegion(regionID uint64) *RegionInfo
- func (r *RegionsInfo) GetRegionCount() int
- func (r *RegionsInfo) GetRegionStats(startKey, endKey []byte) *RegionStats
- func (r *RegionsInfo) GetRegions() []*RegionInfo
- 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) 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) Length() int
- func (r *RegionsInfo) RandFollowerRegion(storeID uint64, opts ...RegionOption) *RegionInfo
- func (r *RegionsInfo) RandLeaderRegion(storeID uint64, opts ...RegionOption) *RegionInfo
- func (r *RegionsInfo) RandRegion(opts ...RegionOption) *RegionInfo
- func (r *RegionsInfo) RemoveRegion(region *RegionInfo)
- func (r *RegionsInfo) ScanRange(startKey []byte, limit int) []*RegionInfo
- func (r *RegionsInfo) SearchRegion(regionKey []byte) *RegionInfo
- func (r *RegionsInfo) SetRegion(region *RegionInfo) []*metapb.Region
- func (r *RegionsInfo) TreeLength() int
- type RegionsStat
- type ResourceKind
- type StoreHotRegionInfos
- type StoreHotRegionsStat
- type StoreInfo
- func (s *StoreInfo) AvailableRatio() float64
- func (s *StoreInfo) Block()
- func (s *StoreInfo) Clone() *StoreInfo
- func (s *StoreInfo) CompareLocation(other *StoreInfo, labels []string) int
- func (s *StoreInfo) DownTime() time.Duration
- func (s *StoreInfo) GetLabelValue(key string) string
- func (s *StoreInfo) GetStartTS() time.Time
- func (s *StoreInfo) GetUptime() time.Duration
- func (s *StoreInfo) IsBlocked() bool
- func (s *StoreInfo) IsDisconnected() bool
- func (s *StoreInfo) IsLowSpace() bool
- func (s *StoreInfo) IsOffline() bool
- func (s *StoreInfo) IsTombstone() bool
- func (s *StoreInfo) IsUnhealth() bool
- func (s *StoreInfo) IsUp() bool
- func (s *StoreInfo) LeaderScore() float64
- func (s *StoreInfo) MergeLabels(labels []*metapb.StoreLabel)
- func (s *StoreInfo) RegionScore() float64
- func (s *StoreInfo) ResourceCount(kind ResourceKind) uint64
- func (s *StoreInfo) ResourceScore(kind ResourceKind) float64
- func (s *StoreInfo) ResourceSize(kind ResourceKind) int64
- func (s *StoreInfo) ResourceWeight(kind ResourceKind) float64
- func (s *StoreInfo) StorageSize() uint64
- func (s *StoreInfo) Unblock()
- type StoresInfo
- func (s *StoresInfo) BlockStore(storeID uint64) error
- 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) GetStoresReadStat() map[uint64]uint64
- func (s *StoresInfo) GetStoresWriteStat() map[uint64]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) TotalReadBytes() uint64
- func (s *StoresInfo) TotalWrittenBytes() uint64
- func (s *StoresInfo) UnblockStore(storeID uint64)
Constants ¶
const ( // LeaderKind indicates the leader kind resource LeaderKind = iota // RegionKind indicates the region kind resource RegionKind )
const EmptyRegionApproximateSize = 1
EmptyRegionApproximateSize is the region approximate size of an empty region (heartbeat size <= 1MB).
Variables ¶
var ( // ErrStoreNotFound is for log of store no found ErrStoreNotFound = func(storeID uint64) error { return errors.Errorf("store %v not found", storeID) } // ErrStoreIsBlocked is for log of store is blocked ErrStoreIsBlocked = func(storeID uint64) error { return errors.Errorf("store %v is blocked", storeID) } )
Functions ¶
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 MergeRegions ¶
MergeRegions merge a set of metapb.Region by regionKey
Types ¶
type HotRegionsStat ¶
type HotRegionsStat struct { TotalFlowBytes uint64 `json:"total_flow_bytes"` RegionsCount int `json:"regions_count"` RegionsStat RegionsStat `json:"statistics"` }
HotRegionsStat records all hot regions statistics
type IDAllocator ¶
IDAllocator is the allocator to generate unique ID.
type KV ¶
type KV struct {
KVBase
}
KV wraps all kv operations, keep it stateless.
func (*KV) ClusterStatePath ¶
ClusterStatePath returns the path to save an option.
func (*KV) DeleteRegion ¶
DeleteRegion deletes one region from KV.
func (*KV) LoadConfig ¶
LoadConfig loads config from configPath then unmarshal it to cfg.
func (*KV) LoadRegion ¶
LoadRegion loads one regoin from KV.
func (*KV) LoadRegions ¶
func (kv *KV) LoadRegions(regions *RegionsInfo, rangeLimit int) error
LoadRegions loads all regions from KV to RegionsInfo.
func (*KV) LoadStores ¶
func (kv *KV) LoadStores(stores *StoresInfo, rangeLimit int) error
LoadStores loads all stores from KV to StoresInfo.
func (*KV) SaveConfig ¶
SaveConfig stores marshalable cfg to the configPath.
func (*KV) SaveRegion ¶
SaveRegion saves one region to KV.
type KVBase ¶
type KVBase interface { Load(key string) (string, error) LoadRange(key, endKey string, limit int) ([]string, error) Save(key, value string) error Delete(key string) error }
KVBase is an abstract interface for load/save pd cluster data.
type MockIDAllocator ¶
type MockIDAllocator struct {
// contains filtered or unexported fields
}
MockIDAllocator mocks IDAllocator and it is only used for test.
func NewMockIDAllocator ¶
func NewMockIDAllocator() *MockIDAllocator
NewMockIDAllocator create a new MockIDAllocator
func (*MockIDAllocator) Alloc ¶
func (alloc *MockIDAllocator) Alloc() (uint64, error)
Alloc return a new id
type PriorityLevel ¶
type PriorityLevel int
PriorityLevel lower level means higher priority
const ( HighPriority PriorityLevel = iota NormalPriority LowPriority )
Built-in priority level
type RegionInfo ¶
type RegionInfo struct { *metapb.Region Learners []*metapb.Peer Voters []*metapb.Peer Leader *metapb.Peer DownPeers []*pdpb.PeerStats PendingPeers []*metapb.Peer WrittenBytes uint64 ReadBytes uint64 ApproximateSize int64 }
RegionInfo records detail region info.
func NewRegionInfo ¶
func NewRegionInfo(region *metapb.Region, leader *metapb.Peer) *RegionInfo
NewRegionInfo creates RegionInfo with region's meta and leader peer.
func RegionFromHeartbeat ¶
func RegionFromHeartbeat(heartbeat *pdpb.RegionHeartbeatRequest) *RegionInfo
RegionFromHeartbeat constructs a Region from region heartbeat.
func (*RegionInfo) AddPeer ¶
func (r *RegionInfo) AddPeer(peer *metapb.Peer)
AddPeer adds the peer in region info for test use.
func (*RegionInfo) Clone ¶
func (r *RegionInfo) Clone() *RegionInfo
Clone returns a copy of current regionInfo.
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) GetDownVoter ¶
func (r *RegionInfo) GetDownVoter(peerID uint64) *metapb.Peer
GetDownVoter returns the down voter with specified peer id.
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) GetLearners ¶
func (r *RegionInfo) GetLearners() []*metapb.Peer
GetLearners returns the learners.
func (*RegionInfo) GetPeer ¶
func (r *RegionInfo) GetPeer(peerID uint64) *metapb.Peer
GetPeer returns the peer with specified peer id.
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) GetPendingVoter ¶
func (r *RegionInfo) GetPendingVoter(peerID uint64) *metapb.Peer
GetPendingVoter returns the pending voter with specified peer id.
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) GetStoreVoter ¶
func (r *RegionInfo) GetStoreVoter(storeID uint64) *metapb.Peer
GetStoreVoter returns the voter in specified store.
func (*RegionInfo) GetVoters ¶
func (r *RegionInfo) GetVoters() []*metapb.Peer
GetVoters returns the voters.
func (*RegionInfo) RemoveStorePeer ¶
func (r *RegionInfo) RemoveStorePeer(storeID uint64)
RemoveStorePeer removes the peer in specified store for test use.
type RegionOption ¶
type RegionOption func(region *RegionInfo) bool
RegionOption used to select region
type RegionStat ¶
type RegionStat struct { RegionID uint64 `json:"region_id"` FlowBytes uint64 `json:"flow_bytes"` // HotDegree records the hot region update times HotDegree int `json:"hot_degree"` // LastUpdateTime used to calculate average write LastUpdateTime time.Time `json:"last_update_time"` StoreID uint64 `json:"-"` // AntiCount used to eliminate some noise when remove region in cache AntiCount int // Version used to check the region split times Version uint64 }
RegionStat records each hot region's statistics
type RegionStats ¶
type RegionStats struct { Count int `json:"count"` EmptyCount int `json:"empty_count"` StorageSize int64 `json:"storage_size"` StoreLeaderCount map[uint64]int `json:"store_leader_count"` StorePeerCount map[uint64]int `json:"store_peer_count"` StoreLeaderSize map[uint64]int64 `json:"store_leader_size"` StorePeerSize map[uint64]int64 `json:"store_peer_size"` }
RegionStats records a list of regions' statistics and distribution status.
func (*RegionStats) Observe ¶
func (s *RegionStats) Observe(r *RegionInfo)
Observe adds a region's statistics into RegionStats.
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) AddRegion ¶
func (r *RegionsInfo) AddRegion(region *RegionInfo) []*metapb.Region
AddRegion add RegionInfo to regionTree and regionMap, also update leadres and followers by region peers
func (*RegionsInfo) GetAdjacentRegions ¶
func (r *RegionsInfo) GetAdjacentRegions(region *RegionInfo) (*RegionInfo, *RegionInfo)
GetAdjacentRegions returns region's info that is adjacent with specific region
func (*RegionsInfo) GetFollower ¶
func (r *RegionsInfo) GetFollower(storeID uint64, regionID uint64) *RegionInfo
GetFollower return follower RegionInfo by storeID and regionID(now only used in test)
func (*RegionsInfo) GetLeader ¶
func (r *RegionsInfo) GetLeader(storeID uint64, regionID uint64) *RegionInfo
GetLeader return 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) GetRegion ¶
func (r *RegionsInfo) GetRegion(regionID uint64) *RegionInfo
GetRegion return the RegionInfo with regionID
func (*RegionsInfo) GetRegionCount ¶
func (r *RegionsInfo) GetRegionCount() int
GetRegionCount gets the total count of RegionInfo of regionMap
func (*RegionsInfo) GetRegionStats ¶
func (r *RegionsInfo) GetRegionStats(startKey, endKey []byte) *RegionStats
GetRegionStats scans regions that inside range [startKey, endKey) and sums up their statistics.
func (*RegionsInfo) GetRegions ¶
func (r *RegionsInfo) GetRegions() []*RegionInfo
GetRegions get a set of RegionInfo from regionMap
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) 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 and follower RegionInfo by storeID
func (*RegionsInfo) GetStoreRegionSize ¶
func (r *RegionsInfo) GetStoreRegionSize(storeID uint64) int64
GetStoreRegionSize get total size of store's regions
func (*RegionsInfo) Length ¶
func (r *RegionsInfo) Length() int
Length return the RegionsInfo length
func (*RegionsInfo) RandFollowerRegion ¶
func (r *RegionsInfo) RandFollowerRegion(storeID uint64, opts ...RegionOption) *RegionInfo
RandFollowerRegion get a store's follower region by random
func (*RegionsInfo) RandLeaderRegion ¶
func (r *RegionsInfo) RandLeaderRegion(storeID uint64, opts ...RegionOption) *RegionInfo
RandLeaderRegion get a store's leader region by random
func (*RegionsInfo) RandRegion ¶
func (r *RegionsInfo) RandRegion(opts ...RegionOption) *RegionInfo
RandRegion get a region by random
func (*RegionsInfo) RemoveRegion ¶
func (r *RegionsInfo) RemoveRegion(region *RegionInfo)
RemoveRegion remove RegionInfo from regionTree and regionMap
func (*RegionsInfo) ScanRange ¶
func (r *RegionsInfo) ScanRange(startKey []byte, limit int) []*RegionInfo
ScanRange scans region with start key, until number greater than limit.
func (*RegionsInfo) SearchRegion ¶
func (r *RegionsInfo) SearchRegion(regionKey []byte) *RegionInfo
SearchRegion search RegionInfo from regionTree
func (*RegionsInfo) SetRegion ¶
func (r *RegionsInfo) SetRegion(region *RegionInfo) []*metapb.Region
SetRegion set the RegionInfo with regionID
func (*RegionsInfo) TreeLength ¶
func (r *RegionsInfo) TreeLength() int
TreeLength return the RegionsInfo tree length(now only used in test)
type RegionsStat ¶
type RegionsStat []RegionStat
RegionsStat is a list of a group region state type
func (RegionsStat) Len ¶
func (m RegionsStat) Len() int
func (RegionsStat) Less ¶
func (m RegionsStat) Less(i, j int) bool
func (RegionsStat) Swap ¶
func (m RegionsStat) Swap(i, j int)
type ResourceKind ¶
type ResourceKind int
ResourceKind distinguishes different kinds of resources.
func (ResourceKind) String ¶
func (k ResourceKind) String() string
type StoreHotRegionInfos ¶
type StoreHotRegionInfos struct { AsPeer StoreHotRegionsStat `json:"as_peer"` AsLeader StoreHotRegionsStat `json:"as_leader"` }
StoreHotRegionInfos : used to get human readable description for hot regions.
type StoreHotRegionsStat ¶
type StoreHotRegionsStat map[uint64]*HotRegionsStat
StoreHotRegionsStat used to record the hot region statistics group by store
type StoreInfo ¶
type StoreInfo struct { *metapb.Store Stats *pdpb.StoreStats LeaderCount int RegionCount int LeaderSize int64 RegionSize int64 PendingPeerCount int LastHeartbeatTS time.Time LeaderWeight float64 RegionWeight float64 // contains filtered or unexported fields }
StoreInfo contains information about a store.
func NewStoreInfo ¶
NewStoreInfo creates StoreInfo with meta data.
func (*StoreInfo) AvailableRatio ¶
AvailableRatio is store's freeSpace/capacity.
func (*StoreInfo) Block ¶
func (s *StoreInfo) Block()
Block stops balancer from selecting 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) GetLabelValue ¶
GetLabelValue returns a label's value (if exists).
func (*StoreInfo) GetStartTS ¶
GetStartTS returns the start timestamp.
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) IsLowSpace ¶
IsLowSpace checks if the store is lack of space.
func (*StoreInfo) IsTombstone ¶
IsTombstone checks if the store's state is Tombstone.
func (*StoreInfo) IsUnhealth ¶
IsUnhealth checks if a store is unhealth.
func (*StoreInfo) LeaderScore ¶
LeaderScore returns the store's leader score: leaderCount / leaderWeight.
func (*StoreInfo) MergeLabels ¶
func (s *StoreInfo) MergeLabels(labels []*metapb.StoreLabel)
MergeLabels merges the passed in labels with origins, overriding duplicated ones.
func (*StoreInfo) RegionScore ¶
RegionScore returns the store's region score: regionSize / regionWeight.
func (*StoreInfo) ResourceCount ¶
func (s *StoreInfo) ResourceCount(kind ResourceKind) uint64
ResourceCount reutrns count of leader/region in the store.
func (*StoreInfo) ResourceScore ¶
func (s *StoreInfo) ResourceScore(kind ResourceKind) float64
ResourceScore reutrns score of leader/region in the store.
func (*StoreInfo) ResourceSize ¶
func (s *StoreInfo) ResourceSize(kind ResourceKind) int64
ResourceSize returns size of leader/region in the store
func (*StoreInfo) ResourceWeight ¶
func (s *StoreInfo) ResourceWeight(kind ResourceKind) float64
ResourceWeight returns weight of leader/region in the score
func (*StoreInfo) StorageSize ¶
StorageSize returns store's used storage size reported from tikv.
type StoresInfo ¶
type StoresInfo struct {
// contains filtered or unexported fields
}
StoresInfo is a map of storeID to StoreInfo
func NewStoresInfo ¶
func NewStoresInfo() *StoresInfo
NewStoresInfo create a StoresInfo with map of storeID to StoreInfo
func (*StoresInfo) BlockStore ¶
func (s *StoresInfo) BlockStore(storeID uint64) error
BlockStore block a StoreInfo with storeID
func (*StoresInfo) GetMetaStores ¶
func (s *StoresInfo) GetMetaStores() []*metapb.Store
GetMetaStores get a complete set of metapb.Store
func (*StoresInfo) GetStore ¶
func (s *StoresInfo) GetStore(storeID uint64) *StoreInfo
GetStore return a StoreInfo with storeID
func (*StoresInfo) GetStoreCount ¶
func (s *StoresInfo) GetStoreCount() int
GetStoreCount return the total count of storeInfo
func (*StoresInfo) GetStores ¶
func (s *StoresInfo) GetStores() []*StoreInfo
GetStores get a complete set of StoreInfo
func (*StoresInfo) GetStoresReadStat ¶
func (s *StoresInfo) GetStoresReadStat() map[uint64]uint64
GetStoresReadStat return the read stat of all StoreInfo
func (*StoresInfo) GetStoresWriteStat ¶
func (s *StoresInfo) GetStoresWriteStat() map[uint64]uint64
GetStoresWriteStat return the write stat of all StoreInfo
func (*StoresInfo) SetLeaderCount ¶
func (s *StoresInfo) SetLeaderCount(storeID uint64, leaderCount int)
SetLeaderCount set the leader count to a storeInfo
func (*StoresInfo) SetLeaderSize ¶
func (s *StoresInfo) SetLeaderSize(storeID uint64, leaderSize int64)
SetLeaderSize set the leader count 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 set the region count to a storeInfo
func (*StoresInfo) SetRegionSize ¶
func (s *StoresInfo) SetRegionSize(storeID uint64, regionSize int64)
SetRegionSize set the region count to a storeInfo
func (*StoresInfo) SetStore ¶
func (s *StoresInfo) SetStore(store *StoreInfo)
SetStore set a StoreInfo with storeID
func (*StoresInfo) TotalReadBytes ¶
func (s *StoresInfo) TotalReadBytes() uint64
TotalReadBytes return the total read bytes of all StoreInfo
func (*StoresInfo) TotalWrittenBytes ¶
func (s *StoresInfo) TotalWrittenBytes() uint64
TotalWrittenBytes return the total written bytes of all StoreInfo
func (*StoresInfo) UnblockStore ¶
func (s *StoresInfo) UnblockStore(storeID uint64)
UnblockStore unblock a StoreInfo with storeID