core

package
v0.0.0-...-335f5af Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2017 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

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

func NewStoreInfo(store *metapb.Store) *StoreInfo

NewStoreInfo creates StoreInfo with meta data.

func (*StoreInfo) AvailableRatio

func (s *StoreInfo) AvailableRatio() float64

AvailableRatio is store's freeSpace/capacity.

func (*StoreInfo) Block

func (s *StoreInfo) Block()

Block stops balancer from selecting the store.

func (*StoreInfo) Clone

func (s *StoreInfo) Clone() *StoreInfo

Clone creates a copy of current StoreInfo.

func (*StoreInfo) CompareLocation

func (s *StoreInfo) CompareLocation(other *StoreInfo, labels []string) int

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

func (s *StoreInfo) DownTime() time.Duration

DownTime returns the time elapsed since last heartbeat.

func (*StoreInfo) GetLabelValue

func (s *StoreInfo) GetLabelValue(key string) string

GetLabelValue returns a label's value (if exists).

func (*StoreInfo) GetStartTS

func (s *StoreInfo) GetStartTS() time.Time

GetStartTS returns the start timestamp.

func (*StoreInfo) GetUptime

func (s *StoreInfo) GetUptime() time.Duration

GetUptime returns the uptime.

func (*StoreInfo) IsBlocked

func (s *StoreInfo) IsBlocked() bool

IsBlocked returns if the store is blocked.

func (*StoreInfo) IsDown

func (s *StoreInfo) IsDown() bool

IsDown returns whether the store is down

func (*StoreInfo) IsOffline

func (s *StoreInfo) IsOffline() bool

IsOffline checks if the store's state is Offline.

func (*StoreInfo) IsTombstone

func (s *StoreInfo) IsTombstone() bool

IsTombstone checks if the store's state is Tombstone.

func (*StoreInfo) IsUp

func (s *StoreInfo) IsUp() bool

IsUp checks if the store's state is Up.

func (*StoreInfo) LeaderScore

func (s *StoreInfo) LeaderScore() float64

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

func (s *StoreInfo) RegionScore() float64

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

func (s *StoreInfo) StorageSize() uint64

StorageSize returns store's used storage size reported from tikv.

func (*StoreInfo) Unblock

func (s *StoreInfo) Unblock()

Unblock allows balancer to select the store.

Jump to

Keyboard shortcuts

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