Documentation ¶
Index ¶
- type HotRegionsStat
- type RegionInfo
- func (r *RegionInfo) Clone() *RegionInfo
- func (r *RegionInfo) GetDownPeer(peerID uint64) *metapb.Peer
- func (r *RegionInfo) GetFollower() *metapb.Peer
- func (r *RegionInfo) GetFollowers() map[uint64]*metapb.Peer
- func (r *RegionInfo) GetPeer(peerID uint64) *metapb.Peer
- func (r *RegionInfo) GetPendingPeer(peerID uint64) *metapb.Peer
- func (r *RegionInfo) GetStoreIds() map[uint64]struct{}
- func (r *RegionInfo) GetStorePeer(storeID uint64) *metapb.Peer
- func (r *RegionInfo) RemoveStorePeer(storeID uint64)
- type RegionStat
- type RegionsStat
- type ResourceKind
- type StoreHotRegionInfos
- 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) IsDown() bool
- func (s *StoreInfo) IsOffline() bool
- func (s *StoreInfo) IsTombstone() 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) StorageSize() uint64
- func (s *StoreInfo) Unblock()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HotRegionsStat ¶
type HotRegionsStat struct { WrittenBytes uint64 `json:"total_written_bytes"` RegionsCount int `json:"regions_count"` RegionsStat RegionsStat `json:"statistics"` }
HotRegionsStat records all hot regions statistics
type RegionInfo ¶
type RegionInfo struct { *metapb.Region Leader *metapb.Peer DownPeers []*pdpb.PeerStats PendingPeers []*metapb.Peer WrittenBytes uint64 }
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 (*RegionInfo) Clone ¶
func (r *RegionInfo) Clone() *RegionInfo
Clone returns a copy of current regionInfo.
func (*RegionInfo) GetDownPeer ¶
func (r *RegionInfo) GetDownPeer(peerID uint64) *metapb.Peer
GetDownPeer returns the down peers 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) GetPeer ¶
func (r *RegionInfo) GetPeer(peerID uint64) *metapb.Peer
GetPeer returns the 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) GetStoreIds ¶
func (r *RegionInfo) GetStoreIds() map[uint64]struct{}
GetStoreIds returns a map indicate the region distributed.
func (*RegionInfo) GetStorePeer ¶
func (r *RegionInfo) GetStorePeer(storeID uint64) *metapb.Peer
GetStorePeer returns the peer in specified store.
func (*RegionInfo) RemoveStorePeer ¶
func (r *RegionInfo) RemoveStorePeer(storeID uint64)
RemoveStorePeer removes the peer in specified store.
type RegionStat ¶
type RegionStat struct { RegionID uint64 `json:"region_id"` WrittenBytes uint64 `json:"written_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 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.
const ( // UnKnownKind indicates the unknown kind resource UnKnownKind ResourceKind = iota // AdminKind indicates that specify by admin AdminKind // LeaderKind indicates the leader kind resource LeaderKind // RegionKind indicates the region kind resource RegionKind // PriorityKind indicates the priority kind resource PriorityKind // OtherKind indicates the other kind resource OtherKind )
func ParseResourceKind ¶
func ParseResourceKind(name string) ResourceKind
ParseResourceKind convert string to ResourceKind
func (ResourceKind) String ¶
func (k ResourceKind) String() string
type StoreHotRegionInfos ¶
type StoreHotRegionInfos struct { AsPeer map[uint64]*HotRegionsStat `json:"as_peer"` AsLeader map[uint64]*HotRegionsStat `json:"as_leader"` }
StoreHotRegionInfos : used to get human readable description for hot regions.
type StoreInfo ¶
type StoreInfo struct { *metapb.Store Stats *pdpb.StoreStats LeaderCount int RegionCount 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) IsTombstone ¶
IsTombstone checks if the store's state is Tombstone.
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: regionCount / 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) StorageSize ¶
StorageSize returns store's used storage size reported from tikv.