statistics

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// TopNN is the threshold which means we can get hot threshold from store.
	TopNN = 60
	// HotThresholdRatio is used to calculate hot thresholds
	HotThresholdRatio = 0.8
	// WriteReportInterval indicates the interval between write interval
	WriteReportInterval = RegionHeartBeatReportInterval
	// ReadReportInterval indicates the interval between read stats report
	ReadReportInterval = StoreHeartBeatReportInterval

	// HotRegionReportMinInterval is used for the simulator and test
	HotRegionReportMinInterval = 3

	// HotRegionAntiCount is default value for antiCount
	HotRegionAntiCount = 2
)
View Source
const (
	// BytePriority indicates hot-region-scheduler prefer byte dim
	BytePriority = "byte"
	// KeyPriority indicates hot-region-scheduler prefer key dim
	KeyPriority = "key"
	// QueryPriority indicates hot-region-scheduler prefer query dim
	QueryPriority = "query"
)
View Source
const (
	ByteDim int = iota
	KeyDim
	QueryDim
	DimLen
)

Indicator dims.

View Source
const (

	// RegionsStatsObserveInterval is the interval for obtaining statistics from RegionTree
	RegionsStatsObserveInterval = 30 * time.Second
	// RegionsStatsRollingWindowsSize is default size of median filter for data from regionStats
	RegionsStatsRollingWindowsSize = 9
)
View Source
const (
	// StoreHeartBeatReportInterval is the heartbeat report interval of a store.
	StoreHeartBeatReportInterval = 10
	// RegionHeartBeatReportInterval is the heartbeat report interval of a region.
	RegionHeartBeatReportInterval = 60
	// DefaultAotSize is default size of average over time.
	DefaultAotSize = 1
	// DefaultWriteMfSize is default size of write median filter.
	DefaultWriteMfSize = 5
	// DefaultReadMfSize is default size of read median filter.
	DefaultReadMfSize = 5
)

Variables

View Source
var Denoising = true

Denoising is an option to calculate flow base on the real heartbeats. Should only turn off by the simulator and the test.

View Source
var (

	// HistorySampleDuration  is the duration for saving history load.
	HistorySampleDuration = 5 * time.Minute
)
View Source
var MinHotThresholds = [RegionStatCount]float64{
	RegionReadBytes:     8 * units.KiB,
	RegionReadKeys:      128,
	RegionReadQueryNum:  128,
	RegionWriteBytes:    1 * units.KiB,
	RegionWriteKeys:     32,
	RegionWriteQueryNum: 32,
}

MinHotThresholds is the threshold at which this dimension is recorded as a hot spot.

View Source
var (

	// StoreLimitGauge is used to record the current store limit.
	StoreLimitGauge = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: "pd",
			Subsystem: "cluster",
			Name:      "store_limit",
			Help:      "Status of the store limit.",
		}, []string{"store", "type"})
)
View Source
var ThresholdsUpdateInterval = 8 * time.Second

ThresholdsUpdateInterval is the default interval to update thresholds. the refresh interval should be less than store heartbeat interval to keep the next calculate must use the latest threshold.

Functions

func DimToString

func DimToString(dim int) string

DimToString return string according to dim.

func ForeachRegionStats

func ForeachRegionStats(f func(RWType, int, RegionStatKind))

ForeachRegionStats foreach all region stats of read and write.

func GetRegionLabelIsolation

func GetRegionLabelIsolation(stores []*core.StoreInfo, labels []string) string

GetRegionLabelIsolation returns the isolation level of the region.

func NewHotPeerCache

func NewHotPeerCache(ctx context.Context, kind RWType) *hotPeerCache

NewHotPeerCache creates a hotPeerCache

func NewStoreStatisticsMap

func NewStoreStatisticsMap(opt *config.PersistOptions, storeConfig *config.StoreConfig) *storeStatisticsMap

NewStoreStatisticsMap creates a new storeStatisticsMap.

func StringToDim

func StringToDim(name string) int

StringToDim return dim according to string.

func SummaryStoreInfos

func SummaryStoreInfos(stores []*core.StoreInfo) map[uint64]*StoreSummaryInfo

SummaryStoreInfos return a mapping from store to summary information.

func SummaryStoresLoad

func SummaryStoresLoad(
	storeInfos map[uint64]*StoreSummaryInfo,
	storesLoads map[uint64][]float64,
	storesHistoryLoads *StoreHistoryLoads,
	storeHotPeers map[uint64][]*HotPeerStat,
	isTraceRegionFlow bool,
	rwTy RWType,
	kind constant.ResourceKind,
) map[uint64]*StoreLoadDetail

SummaryStoresLoad Load information of all available stores. it will filter the hot peer and calculate the current and future stat(rate,count) for each store

func UpdateStoreHeartbeatMetrics

func UpdateStoreHeartbeatMetrics(store *core.StoreInfo)

UpdateStoreHeartbeatMetrics is used to update store heartbeat interval metrics

Types

type ActionType

type ActionType int

ActionType indicates the action type for the stat item.

const (
	Add ActionType = iota
	Remove
	Update
	ActionTypeLen
)

Flags for action type.

func (ActionType) String

func (t ActionType) String() string

type FlowItemTask

type FlowItemTask interface {
	// contains filtered or unexported methods
}

FlowItemTask indicates the task in flowItem queue

func NewCheckExpiredItemTask

func NewCheckExpiredItemTask(region *core.RegionInfo) FlowItemTask

NewCheckExpiredItemTask creates task to collect expired items

func NewCheckPeerTask

func NewCheckPeerTask(peerInfo *core.PeerInfo, regionInfo *core.RegionInfo) FlowItemTask

NewCheckPeerTask creates task to update peerInfo

func NewCollectUnReportedPeerTask

func NewCollectUnReportedPeerTask(storeID uint64, regions map[uint64]*core.RegionInfo, interval uint64) FlowItemTask

NewCollectUnReportedPeerTask creates task to collect unreported peers

type HotCache

type HotCache struct {
	// contains filtered or unexported fields
}

HotCache is a cache hold hot regions.

func NewHotCache

func NewHotCache(ctx context.Context) *HotCache

NewHotCache creates a new hot spot cache.

func (*HotCache) CheckReadAsync

func (w *HotCache) CheckReadAsync(task FlowItemTask) bool

CheckReadAsync puts the flowItem into queue, and check it asynchronously

func (*HotCache) CheckReadPeerSync

func (w *HotCache) CheckReadPeerSync(peer *core.PeerInfo, region *core.RegionInfo) *HotPeerStat

CheckReadPeerSync checks the read status, returns update items. This is used for mockcluster, for test purpose.

func (*HotCache) CheckWriteAsync

func (w *HotCache) CheckWriteAsync(task FlowItemTask) bool

CheckWriteAsync puts the flowItem into queue, and check it asynchronously

func (*HotCache) CheckWritePeerSync

func (w *HotCache) CheckWritePeerSync(peer *core.PeerInfo, region *core.RegionInfo) *HotPeerStat

CheckWritePeerSync checks the write status, returns update items. This is used for mockcluster, for test purpose.

func (*HotCache) CollectMetrics

func (w *HotCache) CollectMetrics()

CollectMetrics collects the hot cache metrics.

func (*HotCache) ExpiredReadItems

func (w *HotCache) ExpiredReadItems(region *core.RegionInfo) []*HotPeerStat

ExpiredReadItems returns the read items which are already expired. This is used for mockcluster, for test purpose.

func (*HotCache) ExpiredWriteItems

func (w *HotCache) ExpiredWriteItems(region *core.RegionInfo) []*HotPeerStat

ExpiredWriteItems returns the write items which are already expired. This is used for mockcluster, for test purpose.

func (*HotCache) GetHotPeerStat

func (w *HotCache) GetHotPeerStat(kind RWType, regionID, storeID uint64) *HotPeerStat

GetHotPeerStat returns hot peer stat with specified regionID and storeID.

func (*HotCache) GetThresholds

func (w *HotCache) GetThresholds(kind RWType, storeID uint64) []float64

GetThresholds returns thresholds. This is used for test purpose.

func (*HotCache) IsRegionHot

func (w *HotCache) IsRegionHot(region *core.RegionInfo, minHotDegree int) bool

IsRegionHot checks if the region is hot.

func (*HotCache) RegionStats

func (w *HotCache) RegionStats(kind RWType, minHotDegree int) map[uint64][]*HotPeerStat

RegionStats returns hot items according to kind

func (*HotCache) ResetMetrics

func (w *HotCache) ResetMetrics()

ResetMetrics resets the hot cache metrics.

func (*HotCache) Update

func (w *HotCache) Update(item *HotPeerStat, kind RWType)

Update updates the cache. This is used for mockcluster, for test purpose.

type HotPeerStat

type HotPeerStat struct {
	StoreID  uint64 `json:"store_id"`
	RegionID uint64 `json:"region_id"`
	// HotDegree records the times for the region considered as hot spot during each report.
	HotDegree int `json:"hot_degree"`
	// AntiCount used to eliminate some noise when remove region in cache.
	AntiCount int `json:"anti_count"`
	// Loads contains only Kind-related statistics and is DimLen in length.
	Loads []float64 `json:"loads"`
	// contains filtered or unexported fields
}

HotPeerStat records each hot peer's statistics

func (*HotPeerStat) Clone

func (stat *HotPeerStat) Clone() *HotPeerStat

Clone clones the HotPeerStat.

func (*HotPeerStat) GetActionType

func (stat *HotPeerStat) GetActionType() ActionType

GetActionType returns the item action type.

func (*HotPeerStat) GetLoad

func (stat *HotPeerStat) GetLoad(dim int) float64

GetLoad returns denoising load if possible.

func (*HotPeerStat) GetLoads

func (stat *HotPeerStat) GetLoads() []float64

GetLoads returns denoising loads if possible.

func (*HotPeerStat) GetStores

func (stat *HotPeerStat) GetStores() []uint64

GetStores returns the stores of all peers in the region.

func (*HotPeerStat) ID

func (stat *HotPeerStat) ID() uint64

ID returns region ID. Implementing TopNItem.

func (*HotPeerStat) IsLeader

func (stat *HotPeerStat) IsLeader() bool

IsLeader indicates the item belong to the leader.

func (*HotPeerStat) IsNeedCoolDownTransferLeader

func (stat *HotPeerStat) IsNeedCoolDownTransferLeader(minHotDegree int, rwTy RWType) bool

IsNeedCoolDownTransferLeader use cooldown time after transfer leader to avoid unnecessary schedule

func (*HotPeerStat) Less

func (stat *HotPeerStat) Less(dim int, than TopNItem) bool

Less compares two HotPeerStat.Implementing TopNItem.

func (*HotPeerStat) Log

func (stat *HotPeerStat) Log(str string)

Log is used to output some info

type HotPeerStatShow

type HotPeerStatShow struct {
	StoreID        uint64    `json:"store_id"`
	Stores         []uint64  `json:"stores"`
	IsLeader       bool      `json:"is_leader"`
	IsLearner      bool      `json:"is_learner"`
	RegionID       uint64    `json:"region_id"`
	HotDegree      int       `json:"hot_degree"`
	ByteRate       float64   `json:"flow_bytes"`
	KeyRate        float64   `json:"flow_keys"`
	QueryRate      float64   `json:"flow_query"`
	AntiCount      int       `json:"anti_count"`
	LastUpdateTime time.Time `json:"last_update_time"`
}

HotPeerStatShow records the hot region statistics for output

func (*HotPeerStatShow) UpdateHotPeerStatShow

func (h *HotPeerStatShow) UpdateHotPeerStatShow(region *core.RegionInfo)

UpdateHotPeerStatShow updates the region information, such as `IsLearner` and `LastUpdateTime`.

type HotPeersStat

type HotPeersStat struct {
	StoreByteRate  float64           `json:"store_bytes"`
	StoreKeyRate   float64           `json:"store_keys"`
	StoreQueryRate float64           `json:"store_query"`
	TotalBytesRate float64           `json:"total_flow_bytes"`
	TotalKeysRate  float64           `json:"total_flow_keys"`
	TotalQueryRate float64           `json:"total_flow_query"`
	Count          int               `json:"regions_count"`
	Stats          []HotPeerStatShow `json:"statistics"`
}

HotPeersStat records all hot regions statistics

type HotStat

type HotStat struct {
	*HotCache
	*StoresStats
}

HotStat contains cluster's hotspot statistics.

func NewHotStat

func NewHotStat(ctx context.Context) *HotStat

NewHotStat creates the container to hold cluster's hotspot statistics.

type Influence

type Influence struct {
	Loads []float64
	Count float64
}

Influence records operator influence.

type LabelStatistics

type LabelStatistics struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

LabelStatistics is the statistics of the level of labels.

func NewLabelStatistics

func NewLabelStatistics() *LabelStatistics

NewLabelStatistics creates a new LabelStatistics.

func (*LabelStatistics) ClearDefunctRegion

func (l *LabelStatistics) ClearDefunctRegion(regionID uint64)

ClearDefunctRegion is used to handle the overlap region.

func (*LabelStatistics) Collect

func (l *LabelStatistics) Collect()

Collect collects the metrics of the label status.

func (*LabelStatistics) GetLabelCounter

func (l *LabelStatistics) GetLabelCounter() map[string]int

GetLabelCounter is only used for tests.

func (*LabelStatistics) Observe

func (l *LabelStatistics) Observe(region *core.RegionInfo, stores []*core.StoreInfo, labels []string)

Observe records the current label status.

func (*LabelStatistics) Reset

func (l *LabelStatistics) Reset()

Reset resets the metrics of the label status.

type RWType

type RWType int

RWType is a identify hot region types.

const (
	Write RWType = iota
	Read
	RWTypeLen
)

Flags for r/w type.

func (RWType) DefaultAntiCount

func (rw RWType) DefaultAntiCount() int

DefaultAntiCount returns the default anti count of read or write.

func (RWType) GetLoadRatesFromPeer

func (rw RWType) GetLoadRatesFromPeer(peer *core.PeerInfo) []float64

GetLoadRatesFromPeer gets the load rates of the read or write type from PeerInfo.

func (RWType) Inverse

func (rw RWType) Inverse() RWType

Inverse returns the opposite of kind.

func (RWType) RegionStats

func (rw RWType) RegionStats() []RegionStatKind

RegionStats returns hot items according to kind

func (RWType) ReportInterval

func (rw RWType) ReportInterval() int

ReportInterval returns the report interval of read or write.

func (RWType) SetFullLoadRates

func (rw RWType) SetFullLoadRates(full []float64, loads []float64)

SetFullLoadRates set load rates to full as read or write type.

func (RWType) String

func (rw RWType) String() string

type RegionInfo

type RegionInfo struct {
	*core.RegionInfo
	// contains filtered or unexported fields
}

RegionInfo is used to record the status of region.

type RegionStatInformer

type RegionStatInformer interface {
	GetHotPeerStat(rw RWType, regionID, storeID uint64) *HotPeerStat
	IsRegionHot(region *core.RegionInfo) bool
	// RegionWriteStats return the storeID -> write stat of peers on this store.
	// The result only includes peers that are hot enough.
	RegionWriteStats() map[uint64][]*HotPeerStat
	// RegionReadStats return the storeID -> read stat of peers on this store.
	// The result only includes peers that are hot enough.
	RegionReadStats() map[uint64][]*HotPeerStat
}

RegionStatInformer provides access to a shared informer of statistics.

type RegionStatKind

type RegionStatKind int

RegionStatKind represents the statistics type of region.

const (
	RegionReadBytes RegionStatKind = iota
	RegionReadKeys
	RegionReadQueryNum
	RegionWriteBytes
	RegionWriteKeys
	RegionWriteQueryNum

	RegionStatCount
)

Different region statistics kinds.

func (RegionStatKind) String

func (k RegionStatKind) String() string

type RegionStatisticType

type RegionStatisticType uint32

RegionStatisticType represents the type of the region's status.

const (
	MissPeer RegionStatisticType = 1 << iota
	ExtraPeer
	DownPeer
	PendingPeer
	OfflinePeer
	LearnerPeer
	EmptyRegion
	OversizedRegion
	UndersizedRegion
	WitnessLeader
)

region status type

type RegionStatistics

type RegionStatistics struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

RegionStatistics is used to record the status of regions.

func NewRegionStatistics

func NewRegionStatistics(conf sc.Config, ruleManager *placement.RuleManager, storeConfigManager *config.StoreConfigManager) *RegionStatistics

NewRegionStatistics creates a new RegionStatistics.

func (*RegionStatistics) ClearDefunctRegion

func (r *RegionStatistics) ClearDefunctRegion(regionID uint64)

ClearDefunctRegion is used to handle the overlap region.

func (*RegionStatistics) Collect

func (r *RegionStatistics) Collect()

Collect collects the metrics of the regions' status.

func (*RegionStatistics) GetOfflineRegionStatsByType

func (r *RegionStatistics) GetOfflineRegionStatsByType(typ RegionStatisticType) []*core.RegionInfo

GetOfflineRegionStatsByType gets the status of the offline region by types. The regions here need to be cloned, otherwise, it may cause data race problems.

func (*RegionStatistics) GetRegionStatsByType

func (r *RegionStatistics) GetRegionStatsByType(typ RegionStatisticType) []*core.RegionInfo

GetRegionStatsByType gets the status of the region by types. The regions here need to be cloned, otherwise, it may cause data race problems.

func (*RegionStatistics) IsRegionStatsType

func (r *RegionStatistics) IsRegionStatsType(regionID uint64, typ RegionStatisticType) bool

IsRegionStatsType returns whether the status of the region is the given type.

func (*RegionStatistics) Observe

func (r *RegionStatistics) Observe(region *core.RegionInfo, stores []*core.StoreInfo)

Observe records the current regions' status.

func (*RegionStatistics) RegionStatsNeedUpdate

func (r *RegionStatistics) RegionStatsNeedUpdate(region *core.RegionInfo) bool

RegionStatsNeedUpdate checks whether the region's status need to be updated due to some special state types.

func (*RegionStatistics) Reset

func (r *RegionStatistics) Reset()

Reset resets the metrics of the regions' status.

type RegionStats

type RegionStats struct {
	Count            int              `json:"count"`
	EmptyCount       int              `json:"empty_count"`
	StorageSize      int64            `json:"storage_size"`
	StorageKeys      int64            `json:"storage_keys"`
	StoreLeaderCount map[uint64]int   `json:"store_leader_count"`
	StorePeerCount   map[uint64]int   `json:"store_peer_count"`
	StoreLeaderSize  map[uint64]int64 `json:"store_leader_size"`
	StoreLeaderKeys  map[uint64]int64 `json:"store_leader_keys"`
	StorePeerSize    map[uint64]int64 `json:"store_peer_size"`
	StorePeerKeys    map[uint64]int64 `json:"store_peer_keys"`
}

RegionStats records a list of regions' statistics and distribution status.

func GetRegionStats

func GetRegionStats(regions []*core.RegionInfo) *RegionStats

GetRegionStats sums regions' statistics.

func (*RegionStats) Observe

func (s *RegionStats) Observe(r *core.RegionInfo)

Observe adds a region's statistics into RegionStats.

type RollingStoreStats

type RollingStoreStats struct {
	syncutil.RWMutex
	// contains filtered or unexported fields
}

RollingStoreStats are multiple sets of recent historical records with specified windows size.

func (*RollingStoreStats) GetInstantLoad

func (r *RollingStoreStats) GetInstantLoad(k StoreStatKind) float64

GetInstantLoad returns store's instant load.

func (*RollingStoreStats) GetLoad

func (r *RollingStoreStats) GetLoad(k StoreStatKind) float64

GetLoad returns store's load.

func (*RollingStoreStats) Observe

func (r *RollingStoreStats) Observe(stats *pdpb.StoreStats)

Observe records current statistics.

func (*RollingStoreStats) ObserveRegionsStats

func (r *RollingStoreStats) ObserveRegionsStats(writeBytesRate, writeKeysRate float64)

ObserveRegionsStats records current statistics from region stats.

func (*RollingStoreStats) Set

func (r *RollingStoreStats) Set(stats *pdpb.StoreStats)

Set sets the statistics (for test).

func (*RollingStoreStats) SetRegionsStats

func (r *RollingStoreStats) SetRegionsStats(writeBytesRate, writeKeysRate float64)

SetRegionsStats sets the statistics from region stats (for test).

type SlowStat

type SlowStat struct {
	*SlowStoresStats
}

SlowStat contains cluster's slow nodes' statistics.

func NewSlowStat

func NewSlowStat(ctx context.Context) *SlowStat

NewSlowStat creates the container to hold slow nodes' statistics.

type SlowStoresStats

type SlowStoresStats struct {
	syncutil.RWMutex
	// contains filtered or unexported fields
}

SlowStoresStats is a cached statistics for the slow store.

func NewSlowStoresStats

func NewSlowStoresStats() *SlowStoresStats

NewSlowStoresStats creates a new slowStoresStats cache.

func (*SlowStoresStats) ExistsSlowStores

func (s *SlowStoresStats) ExistsSlowStores() bool

ExistsSlowStores returns whether there exists slow stores in this cluster.

func (*SlowStoresStats) ObserveSlowStoreStatus

func (s *SlowStoresStats) ObserveSlowStoreStatus(storeID uint64, isSlow bool)

ObserveSlowStoreStatus updates SlowStoreStats with a given store ID.

func (*SlowStoresStats) RemoveSlowStoreStatus

func (s *SlowStoresStats) RemoveSlowStoreStatus(storeID uint64)

RemoveSlowStoreStatus removes SlowStoreStats with a given store ID.

type StoreHistoryLoads

type StoreHistoryLoads struct {
	// contains filtered or unexported fields
}

StoreHistoryLoads records the history load of a store.

func NewStoreHistoryLoads

func NewStoreHistoryLoads(dim int) *StoreHistoryLoads

NewStoreHistoryLoads creates a StoreHistoryLoads.

func (*StoreHistoryLoads) Add

func (s *StoreHistoryLoads) Add(storeID uint64, rwTp RWType, kind constant.ResourceKind, loads []float64)

Add adds the store load to the history.

func (*StoreHistoryLoads) Get

func (s *StoreHistoryLoads) Get(storeID uint64, rwTp RWType, kind constant.ResourceKind) [][]float64

Get returns the store loads from the history, not one time point.

type StoreHotPeersInfos

type StoreHotPeersInfos struct {
	AsPeer   StoreHotPeersStat `json:"as_peer"`
	AsLeader StoreHotPeersStat `json:"as_leader"`
}

StoreHotPeersInfos is used to get human-readable description for hot regions. NOTE: This type is exported by HTTP API. Please pay more attention when modifying it.

func CollectHotPeerInfos

func CollectHotPeerInfos(stores []*core.StoreInfo, regionStats map[uint64][]*HotPeerStat) *StoreHotPeersInfos

CollectHotPeerInfos only returns TotalBytesRate,TotalKeysRate,TotalQueryRate,Count

func GetHotStatus

func GetHotStatus(stores []*core.StoreInfo, storesLoads map[uint64][]float64, regionStats map[uint64][]*HotPeerStat, typ RWType, isTraceRegionFlow bool) *StoreHotPeersInfos

GetHotStatus returns the hot status for a given type. NOTE: This function is exported by HTTP API. It does not contain `isLearner` and `LastUpdateTime` field. If need, please call `updateRegionInfo`.

type StoreHotPeersStat

type StoreHotPeersStat map[uint64]*HotPeersStat

StoreHotPeersStat is used to record the hot region statistics group by store. NOTE: This type is exported by HTTP API. Please pay more attention when modifying it.

type StoreLoad

type StoreLoad struct {
	Loads        []float64
	Count        float64
	HistoryLoads [][]float64
}

StoreLoad records the current load.

func MaxLoad

func MaxLoad(a, b *StoreLoad) *StoreLoad

MaxLoad return the max store load.

func MinLoad

func MinLoad(a, b *StoreLoad) *StoreLoad

MinLoad return the min store load.

func (StoreLoad) ToLoadPred

func (load StoreLoad) ToLoadPred(rwTy RWType, infl *Influence) *StoreLoadPred

ToLoadPred returns the current load and future predictive load.

type StoreLoadDetail

type StoreLoadDetail struct {
	*StoreSummaryInfo
	LoadPred *StoreLoadPred
	HotPeers []*HotPeerStat
}

StoreLoadDetail records store load information.

func (*StoreLoadDetail) IsUniform

func (li *StoreLoadDetail) IsUniform(dim int, threshold float64) bool

IsUniform returns true if the stores are uniform.

func (*StoreLoadDetail) ToHotPeersStat

func (li *StoreLoadDetail) ToHotPeersStat() *HotPeersStat

ToHotPeersStat abstracts load information to HotPeersStat.

type StoreLoadPred

type StoreLoadPred struct {
	Current StoreLoad
	Future  StoreLoad
	Expect  StoreLoad
	Stddev  StoreLoad
}

StoreLoadPred is a prediction of a store.

func (*StoreLoadPred) Diff

func (lp *StoreLoadPred) Diff() *StoreLoad

Diff return the difference between min and max.

func (*StoreLoadPred) Max

func (lp *StoreLoadPred) Max() *StoreLoad

Max returns the max load between current and future.

func (*StoreLoadPred) Min

func (lp *StoreLoadPred) Min() *StoreLoad

Min returns the min load between current and future.

func (*StoreLoadPred) Pending

func (lp *StoreLoadPred) Pending() *StoreLoad

Pending returns the pending load.

type StoreStatInformer

type StoreStatInformer interface {
	GetStoresLoads() map[uint64][]float64
}

StoreStatInformer provides access to a shared informer of statistics.

type StoreStatKind

type StoreStatKind int

StoreStatKind represents the statistics type of store.

const (
	StoreReadBytes StoreStatKind = iota
	StoreReadKeys
	StoreWriteBytes
	StoreWriteKeys
	StoreReadQuery
	StoreWriteQuery
	StoreCPUUsage
	StoreDiskReadRate
	StoreDiskWriteRate

	StoreRegionsWriteBytes // Same as StoreWriteBytes, but it is counted by RegionHeartbeat.
	StoreRegionsWriteKeys  // Same as StoreWriteKeys, but it is counted by RegionHeartbeat.

	StoreStatCount
)

Different store statistics kinds.

func (StoreStatKind) String

func (k StoreStatKind) String() string

type StoreSummaryInfo

type StoreSummaryInfo struct {
	*core.StoreInfo

	PendingSum *Influence
	// contains filtered or unexported fields
}

StoreSummaryInfo records the summary information of store.

func (*StoreSummaryInfo) AddInfluence

func (s *StoreSummaryInfo) AddInfluence(infl *Influence, w float64)

AddInfluence adds influence to pending sum.

func (*StoreSummaryInfo) IsTiFlash

func (s *StoreSummaryInfo) IsTiFlash() bool

IsTiFlash returns true if the store is TiFlash.

func (*StoreSummaryInfo) SetEngineAsTiFlash

func (s *StoreSummaryInfo) SetEngineAsTiFlash()

SetEngineAsTiFlash set whether store is TiFlash, it is only used in tests.

type StoresStats

type StoresStats struct {
	syncutil.RWMutex
	// contains filtered or unexported fields
}

StoresStats is a cache hold hot regions.

func NewStoresStats

func NewStoresStats() *StoresStats

NewStoresStats creates a new hot spot cache.

func (*StoresStats) FilterUnhealthyStore

func (s *StoresStats) FilterUnhealthyStore(cluster core.StoreSetInformer)

FilterUnhealthyStore filter unhealthy store

func (*StoresStats) GetOrCreateRollingStoreStats

func (s *StoresStats) GetOrCreateRollingStoreStats(storeID uint64) *RollingStoreStats

GetOrCreateRollingStoreStats gets or creates RollingStoreStats with a given store ID.

func (*StoresStats) GetRollingStoreStats

func (s *StoresStats) GetRollingStoreStats(storeID uint64) *RollingStoreStats

GetRollingStoreStats gets RollingStoreStats with a given store ID.

func (*StoresStats) GetStoresLoads

func (s *StoresStats) GetStoresLoads() map[uint64][]float64

GetStoresLoads returns all stores loads.

func (*StoresStats) Observe

func (s *StoresStats) Observe(storeID uint64, stats *pdpb.StoreStats)

Observe records the current store status with a given store.

func (*StoresStats) ObserveRegionsStats

func (s *StoresStats) ObserveRegionsStats(storeIDs []uint64, writeBytesRates, writeKeysRates []float64)

ObserveRegionsStats records the current stores status from region stats.

func (*StoresStats) RemoveRollingStoreStats

func (s *StoresStats) RemoveRollingStoreStats(storeID uint64)

RemoveRollingStoreStats removes RollingStoreStats with a given store ID.

func (*StoresStats) Set

func (s *StoresStats) Set(storeID uint64, stats *pdpb.StoreStats)

Set sets the store statistics (for test).

func (*StoresStats) SetRegionsStats

func (s *StoresStats) SetRegionsStats(storeIDs []uint64, writeBytesRates, writeKeysRates []float64)

SetRegionsStats sets the store statistics from region stats (for test).

type TopN

type TopN struct {
	// contains filtered or unexported fields
}

TopN maintains the N largest items of multiple dimensions.

func NewTopN

func NewTopN(k, n int, ttl time.Duration) *TopN

NewTopN returns a k-dimensional TopN with given TTL. NOTE: panic if k <= 0 or n <= 0.

func (*TopN) Get

func (tn *TopN) Get(id uint64) TopNItem

Get returns the item with given id, nil if there is no such item.

func (*TopN) GetAll

func (tn *TopN) GetAll() []TopNItem

GetAll returns all items.

func (*TopN) GetAllTopN

func (tn *TopN) GetAllTopN(k int) []TopNItem

GetAllTopN returns the top N items of the `k`th dimension.

func (*TopN) GetTopNMin

func (tn *TopN) GetTopNMin(k int) TopNItem

GetTopNMin returns the min item in top N of the `k`th dimension.

func (*TopN) Len

func (tn *TopN) Len() int

Len returns number of all items.

func (*TopN) Put

func (tn *TopN) Put(item TopNItem) (isUpdate bool)

Put inserts item or updates the old item if it exists.

func (*TopN) Remove

func (tn *TopN) Remove(id uint64) (item TopNItem)

Remove deletes the item by given ID and returns it.

func (*TopN) RemoveExpired

func (tn *TopN) RemoveExpired()

RemoveExpired deletes all expired items.

type TopNItem

type TopNItem interface {
	// ID is used to check identity.
	ID() uint64
	// Less tests whether the current item is less than the given argument in the `k`th dimension.
	Less(k int, than TopNItem) bool
}

TopNItem represents a single object in TopN.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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