cluster

package
v4.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2020 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// PluginLoad means action for load plugin
	PluginLoad = "PluginLoad"
	// PluginUnload means action for unload plugin
	PluginUnload = "PluginUnload"
)
View Source
const NumberOfEntries = 30

NumberOfEntries is the max number of StatEntry that preserved, it is the history of a store's heartbeats. The interval of store heartbeats from TiKV is 10s, so we can preserve 30 entries per store which is about 5 minutes.

View Source
const StaleEntriesTimeout = 300 * time.Second

StaleEntriesTimeout is the time before an entry is deleted as stale. It is about 30 entries * 10s

Variables

View Source
var ErrNotBootstrapped = errors.New("TiKV cluster not bootstrapped, please start TiKV first")

ErrNotBootstrapped is error info for cluster not bootstrapped.

View Source
var ThreadsCollected = []string{"grpc-server-"}

ThreadsCollected filters the threads to take into the calculation of CPU usage.

Functions

func CheckHealth

func CheckHealth(client *http.Client, members []*pdpb.Member) map[uint64]*pdpb.Member

CheckHealth checks if members are healthy.

func GetMembers

func GetMembers(etcdClient *clientv3.Client) ([]*pdpb.Member, error)

GetMembers return a slice of Members.

func IsClientURL added in v4.0.2

func IsClientURL(addr string, etcdClient *clientv3.Client) bool

IsClientURL returns whether addr is a ClientUrl of any member.

func IsCompatible

func IsCompatible(clusterVersion, v semver.Version) bool

IsCompatible checks if the clusterVersion is compatible with the specified version.

func MinSupportedVersion

func MinSupportedVersion(v Feature) *semver.Version

MinSupportedVersion returns the minimum support version for the specified feature.

func MustParseVersion

func MustParseVersion(v string) *semver.Version

MustParseVersion wraps ParseVersion and will panic if error is not nil.

func ParseVersion

func ParseVersion(v string) (*semver.Version, error)

ParseVersion wraps semver.NewVersion and handles compatibility issues.

Types

type CPUEntries

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

CPUEntries saves a history of store statistics

func NewCPUEntries

func NewCPUEntries(size int) *CPUEntries

NewCPUEntries returns the StateEntries with a fixed size

func (*CPUEntries) Append

func (s *CPUEntries) Append(stat *StatEntry, threads ...string) bool

Append a StatEntry, it accepts an optional threads as a filter of CPU usage

func (*CPUEntries) CPU

func (s *CPUEntries) CPU() float64

CPU returns the cpu usage

type Feature

type Feature int

Feature supported features.

const (
	Base Feature = iota
	Version2_0
	// RegionMerge supports the adjacent regions to be merged.
	// and PD will periodically check if there is enough small
	// region to be merged. if there is, will send the corresponding
	// merge command to the TiKV.
	RegionMerge
	// BatchSplit can speed up the region split.
	// and PD will response the BatchSplit request.
	BatchSplit
)

Features list. The cluster provides corresponding new features if the cluster version greater than or equal to the required minimum version of the feature.

type LoadState

type LoadState int

LoadState indicates the load of a cluster or store

const (
	LoadStateNone LoadState = iota
	LoadStateIdle
	LoadStateLow
	LoadStateNormal
	LoadStateHigh
)

LoadStates that supported, None means no state determined

func (LoadState) String

func (s LoadState) String() string

String representation of LoadState

type RaftCluster

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

RaftCluster is used for cluster config management. Raft cluster key format: cluster 1 -> /1/raft, value is metapb.Cluster cluster 2 -> /2/raft For cluster 1 store 1 -> /1/raft/s/1, value is metapb.Store region 1 -> /1/raft/r/1, value is metapb.Region

func NewRaftCluster

func NewRaftCluster(ctx context.Context, root string, clusterID uint64, regionSyncer *syncer.RegionSyncer, etcdClient *clientv3.Client, httpClient *http.Client) *RaftCluster

NewRaftCluster create a new cluster.

func (*RaftCluster) AddScheduler

func (c *RaftCluster) AddScheduler(scheduler schedule.Scheduler, args ...string) error

AddScheduler adds a scheduler.

func (*RaftCluster) AddStoreLimit added in v4.0.2

func (c *RaftCluster) AddStoreLimit(store *metapb.Store)

AddStoreLimit add a store limit for a given store ID.

func (*RaftCluster) AllocID

func (c *RaftCluster) AllocID() (uint64, error)

AllocID allocs ID.

func (*RaftCluster) AttachAvailableFunc

func (c *RaftCluster) AttachAvailableFunc(storeID uint64, limitType storelimit.Type, f func() bool)

AttachAvailableFunc attaches an available function to a specific store.

func (*RaftCluster) BlockStore

func (c *RaftCluster) BlockStore(storeID uint64) error

BlockStore stops balancer from selecting the store.

func (*RaftCluster) BuryStore

func (c *RaftCluster) BuryStore(storeID uint64, force bool) error

BuryStore marks a store as tombstone in cluster. State transition: Case 1: Up -> Tombstone (if force is true); Case 2: Offline -> Tombstone.

func (*RaftCluster) CheckLabelProperty

func (c *RaftCluster) CheckLabelProperty(typ string, labels []*metapb.StoreLabel) bool

CheckLabelProperty is used to check label property.

func (*RaftCluster) CheckReadStatus

func (c *RaftCluster) CheckReadStatus(region *core.RegionInfo) []*statistics.HotPeerStat

CheckReadStatus checks the read status, returns whether need update statistics and item.

func (*RaftCluster) CheckWriteStatus

func (c *RaftCluster) CheckWriteStatus(region *core.RegionInfo) []*statistics.HotPeerStat

CheckWriteStatus checks the write status, returns whether need update statistics and item.

func (*RaftCluster) DropCacheRegion

func (c *RaftCluster) DropCacheRegion(id uint64)

DropCacheRegion removes a region from the cache.

func (*RaftCluster) FitRegion

func (c *RaftCluster) FitRegion(region *core.RegionInfo) *placement.RegionFit

FitRegion tries to fit the region with placement rules.

func (*RaftCluster) GetAdjacentRegions

func (c *RaftCluster) GetAdjacentRegions(region *core.RegionInfo) (*core.RegionInfo, *core.RegionInfo)

GetAdjacentRegions returns regions' information that are adjacent with the specific region ID.

func (*RaftCluster) GetAllStoresLimit added in v4.0.2

func (c *RaftCluster) GetAllStoresLimit() map[uint64]config.StoreLimitConfig

GetAllStoresLimit returns all store limit

func (*RaftCluster) GetAverageRegionSize

func (c *RaftCluster) GetAverageRegionSize() int64

GetAverageRegionSize returns the average region approximate size.

func (*RaftCluster) GetCacheCluster

func (c *RaftCluster) GetCacheCluster() *core.BasicCluster

GetCacheCluster gets the cached cluster.

func (*RaftCluster) GetComponentManager

func (c *RaftCluster) GetComponentManager() *component.Manager

GetComponentManager returns component manager.

func (*RaftCluster) GetConfig

func (c *RaftCluster) GetConfig() *metapb.Cluster

GetConfig gets config from cluster.

func (*RaftCluster) GetCoordinator

func (c *RaftCluster) GetCoordinator() *coordinator

GetCoordinator returns the coordinator.

func (*RaftCluster) GetFollowerStores

func (c *RaftCluster) GetFollowerStores(region *core.RegionInfo) []*core.StoreInfo

GetFollowerStores returns all stores that contains the region's follower peer.

func (*RaftCluster) GetHeartbeatStreams

func (c *RaftCluster) GetHeartbeatStreams() opt.HeartbeatStreams

GetHeartbeatStreams returns the heartbeat streams.

func (*RaftCluster) GetHighSpaceRatio

func (c *RaftCluster) GetHighSpaceRatio() float64

GetHighSpaceRatio returns the high space ratio.

func (*RaftCluster) GetHotReadRegions

func (c *RaftCluster) GetHotReadRegions() *statistics.StoreHotPeersInfos

GetHotReadRegions gets hot read regions' info.

func (*RaftCluster) GetHotRegionCacheHitsThreshold

func (c *RaftCluster) GetHotRegionCacheHitsThreshold() int

GetHotRegionCacheHitsThreshold gets the threshold of hitting hot region cache.

func (*RaftCluster) GetHotRegionScheduleLimit

func (c *RaftCluster) GetHotRegionScheduleLimit() uint64

GetHotRegionScheduleLimit returns the limit for hot region schedule.

func (*RaftCluster) GetHotWriteRegions

func (c *RaftCluster) GetHotWriteRegions() *statistics.StoreHotPeersInfos

GetHotWriteRegions gets hot write regions' info.

func (*RaftCluster) GetKeyType

func (c *RaftCluster) GetKeyType() core.KeyType

GetKeyType is to get key type.

func (*RaftCluster) GetLeaderScheduleLimit

func (c *RaftCluster) GetLeaderScheduleLimit() uint64

GetLeaderScheduleLimit returns the limit for leader schedule.

func (*RaftCluster) GetLeaderSchedulePolicy

func (c *RaftCluster) GetLeaderSchedulePolicy() core.SchedulePolicy

GetLeaderSchedulePolicy is to get leader schedule policy.

func (*RaftCluster) GetLeaderStore

func (c *RaftCluster) GetLeaderStore(region *core.RegionInfo) *core.StoreInfo

GetLeaderStore returns all stores that contains the region's leader peer.

func (*RaftCluster) GetLocationLabels

func (c *RaftCluster) GetLocationLabels() []string

GetLocationLabels returns the location labels for each region

func (*RaftCluster) GetLowSpaceRatio

func (c *RaftCluster) GetLowSpaceRatio() float64

GetLowSpaceRatio returns the low space ratio.

func (*RaftCluster) GetMaxMergeRegionKeys

func (c *RaftCluster) GetMaxMergeRegionKeys() uint64

GetMaxMergeRegionKeys returns the max number of keys.

func (*RaftCluster) GetMaxMergeRegionSize

func (c *RaftCluster) GetMaxMergeRegionSize() uint64

GetMaxMergeRegionSize returns the max region size.

func (*RaftCluster) GetMaxPendingPeerCount

func (c *RaftCluster) GetMaxPendingPeerCount() uint64

GetMaxPendingPeerCount returns the number of the max pending peers.

func (*RaftCluster) GetMaxReplicas

func (c *RaftCluster) GetMaxReplicas() int

GetMaxReplicas returns the number of replicas.

func (*RaftCluster) GetMaxSnapshotCount

func (c *RaftCluster) GetMaxSnapshotCount() uint64

GetMaxSnapshotCount returns the number of the max snapshot which is allowed to send.

func (*RaftCluster) GetMaxStoreDownTime

func (c *RaftCluster) GetMaxStoreDownTime() time.Duration

GetMaxStoreDownTime returns the max down time of a store.

func (*RaftCluster) GetMergeChecker

func (c *RaftCluster) GetMergeChecker() *checker.MergeChecker

GetMergeChecker returns merge checker.

func (*RaftCluster) GetMergeScheduleLimit

func (c *RaftCluster) GetMergeScheduleLimit() uint64

GetMergeScheduleLimit returns the limit for merge schedule.

func (*RaftCluster) GetMetaRegions

func (c *RaftCluster) GetMetaRegions() []*metapb.Region

GetMetaRegions gets regions from cluster.

func (*RaftCluster) GetMetaStores

func (c *RaftCluster) GetMetaStores() []*metapb.Store

GetMetaStores gets stores from cluster.

func (*RaftCluster) GetOperatorController

func (c *RaftCluster) GetOperatorController() *schedule.OperatorController

GetOperatorController returns the operator controller.

func (*RaftCluster) GetOpt

func (c *RaftCluster) GetOpt() *config.PersistOptions

GetOpt returns the scheduling options.

func (*RaftCluster) GetPatrolRegionInterval

func (c *RaftCluster) GetPatrolRegionInterval() time.Duration

GetPatrolRegionInterval returns the interval of patroling region.

func (*RaftCluster) GetPrevRegionByKey

func (c *RaftCluster) GetPrevRegionByKey(regionKey []byte) *core.RegionInfo

GetPrevRegionByKey gets previous region and leader peer by the region key from cluster.

func (*RaftCluster) GetRegion

func (c *RaftCluster) GetRegion(regionID uint64) *core.RegionInfo

GetRegion searches for a region by ID.

func (*RaftCluster) GetRegionByKey

func (c *RaftCluster) GetRegionByKey(regionKey []byte) *core.RegionInfo

GetRegionByKey gets regionInfo by region key from cluster.

func (*RaftCluster) GetRegionCount

func (c *RaftCluster) GetRegionCount() int

GetRegionCount returns total count of regions

func (*RaftCluster) GetRegionScatter

func (c *RaftCluster) GetRegionScatter() *schedule.RegionScatterer

GetRegionScatter returns the region scatter.

func (*RaftCluster) GetRegionScheduleLimit

func (c *RaftCluster) GetRegionScheduleLimit() uint64

GetRegionScheduleLimit returns the limit for region schedule.

func (*RaftCluster) GetRegionStats

func (c *RaftCluster) GetRegionStats(startKey, endKey []byte) *statistics.RegionStats

GetRegionStats returns region statistics from cluster.

func (*RaftCluster) GetRegionStatsByType

func (c *RaftCluster) GetRegionStatsByType(typ statistics.RegionStatisticType) []*core.RegionInfo

GetRegionStatsByType gets the status of the region by types.

func (*RaftCluster) GetRegionStores

func (c *RaftCluster) GetRegionStores(region *core.RegionInfo) []*core.StoreInfo

GetRegionStores returns all stores that contains the region's peer.

func (*RaftCluster) GetRegionSyncer

func (c *RaftCluster) GetRegionSyncer() *syncer.RegionSyncer

GetRegionSyncer returns the region syncer.

func (*RaftCluster) GetRegions

func (c *RaftCluster) GetRegions() []*core.RegionInfo

GetRegions returns all regions' information in detail.

func (*RaftCluster) GetReplicaScheduleLimit

func (c *RaftCluster) GetReplicaScheduleLimit() uint64

GetReplicaScheduleLimit returns the limit for replica schedule.

func (*RaftCluster) GetReplicationConfig

func (c *RaftCluster) GetReplicationConfig() *config.ReplicationConfig

GetReplicationConfig get the replication config.

func (*RaftCluster) GetReplicationMode

func (c *RaftCluster) GetReplicationMode() *replication.ModeManager

GetReplicationMode returns the ReplicationMode.

func (*RaftCluster) GetRuleManager

func (c *RaftCluster) GetRuleManager() *placement.RuleManager

GetRuleManager returns the rule manager reference.

func (*RaftCluster) GetSchedulerHandlers added in v4.0.3

func (c *RaftCluster) GetSchedulerHandlers() map[string]http.Handler

GetSchedulerHandlers gets all scheduler handlers.

func (*RaftCluster) GetSchedulerMaxWaitingOperator

func (c *RaftCluster) GetSchedulerMaxWaitingOperator() uint64

GetSchedulerMaxWaitingOperator returns the number of the max waiting operators.

func (*RaftCluster) GetSchedulers

func (c *RaftCluster) GetSchedulers() []string

GetSchedulers gets all schedulers.

func (*RaftCluster) GetSplitMergeInterval

func (c *RaftCluster) GetSplitMergeInterval() time.Duration

GetSplitMergeInterval returns the interval between finishing split and starting to merge.

func (*RaftCluster) GetStorage

func (c *RaftCluster) GetStorage() *core.Storage

GetStorage returns the storage.

func (*RaftCluster) GetStore

func (c *RaftCluster) GetStore(storeID uint64) *core.StoreInfo

GetStore gets store from cluster.

func (*RaftCluster) GetStoreCount

func (c *RaftCluster) GetStoreCount() int

GetStoreCount returns the count of stores.

func (*RaftCluster) GetStoreLimitByType added in v4.0.2

func (c *RaftCluster) GetStoreLimitByType(storeID uint64, typ storelimit.Type) float64

GetStoreLimitByType returns the store limit for a given store ID and type.

func (*RaftCluster) GetStoreLimiter

func (c *RaftCluster) GetStoreLimiter() *StoreLimiter

GetStoreLimiter returns the dynamic adjusting limiter

func (*RaftCluster) GetStoreRegionCount

func (c *RaftCluster) GetStoreRegionCount(storeID uint64) int

GetStoreRegionCount returns the number of regions for a given store.

func (*RaftCluster) GetStoreRegions

func (c *RaftCluster) GetStoreRegions(storeID uint64) []*core.RegionInfo

GetStoreRegions returns all regions' information with a given storeID.

func (*RaftCluster) GetStores

func (c *RaftCluster) GetStores() []*core.StoreInfo

GetStores returns all stores in the cluster.

func (*RaftCluster) GetStoresBytesReadStat

func (c *RaftCluster) GetStoresBytesReadStat() map[uint64]float64

GetStoresBytesReadStat returns the bytes read stat of all StoreInfo.

func (*RaftCluster) GetStoresBytesWriteStat

func (c *RaftCluster) GetStoresBytesWriteStat() map[uint64]float64

GetStoresBytesWriteStat returns the bytes write stat of all StoreInfo.

func (*RaftCluster) GetStoresKeysReadStat

func (c *RaftCluster) GetStoresKeysReadStat() map[uint64]float64

GetStoresKeysReadStat returns the bytes read stat of all StoreInfo.

func (*RaftCluster) GetStoresKeysWriteStat

func (c *RaftCluster) GetStoresKeysWriteStat() map[uint64]float64

GetStoresKeysWriteStat returns the bytes write stat of all StoreInfo.

func (*RaftCluster) GetStoresStats

func (c *RaftCluster) GetStoresStats() *statistics.StoresStats

GetStoresStats returns stores' statistics from cluster.

func (*RaftCluster) GetStrictlyMatchLabel

func (c *RaftCluster) GetStrictlyMatchLabel() bool

GetStrictlyMatchLabel returns if the strictly label check is enabled.

func (*RaftCluster) GetTolerantSizeRatio

func (c *RaftCluster) GetTolerantSizeRatio() float64

GetTolerantSizeRatio gets the tolerant size ratio.

func (*RaftCluster) HandleAskBatchSplit

func (c *RaftCluster) HandleAskBatchSplit(request *pdpb.AskBatchSplitRequest) (*pdpb.AskBatchSplitResponse, error)

HandleAskBatchSplit handles the batch split request.

func (*RaftCluster) HandleAskSplit

func (c *RaftCluster) HandleAskSplit(request *pdpb.AskSplitRequest) (*pdpb.AskSplitResponse, error)

HandleAskSplit handles the split request.

func (*RaftCluster) HandleBatchReportSplit

func (c *RaftCluster) HandleBatchReportSplit(request *pdpb.ReportBatchSplitRequest) (*pdpb.ReportBatchSplitResponse, error)

HandleBatchReportSplit handles the batch report split request.

func (*RaftCluster) HandleRegionHeartbeat

func (c *RaftCluster) HandleRegionHeartbeat(region *core.RegionInfo) error

HandleRegionHeartbeat processes RegionInfo reports from client.

func (*RaftCluster) HandleReportSplit

func (c *RaftCluster) HandleReportSplit(request *pdpb.ReportSplitRequest) (*pdpb.ReportSplitResponse, error)

HandleReportSplit handles the report split request.

func (*RaftCluster) HandleStoreHeartbeat

func (c *RaftCluster) HandleStoreHeartbeat(stats *pdpb.StoreStats) error

HandleStoreHeartbeat updates the store status.

func (*RaftCluster) InitCluster

func (c *RaftCluster) InitCluster(id id.Allocator, opt *config.PersistOptions, storage *core.Storage, basicCluster *core.BasicCluster)

InitCluster initializes the raft cluster.

func (*RaftCluster) IsCrossTableMergeEnabled

func (c *RaftCluster) IsCrossTableMergeEnabled() bool

IsCrossTableMergeEnabled returns if across table merge is enabled.

func (*RaftCluster) IsDebugMetricsEnabled

func (c *RaftCluster) IsDebugMetricsEnabled() bool

IsDebugMetricsEnabled mocks method

func (*RaftCluster) IsFeatureSupported

func (c *RaftCluster) IsFeatureSupported(f Feature) bool

IsFeatureSupported checks if the feature is supported by current cluster.

func (*RaftCluster) IsLocationReplacementEnabled

func (c *RaftCluster) IsLocationReplacementEnabled() bool

IsLocationReplacementEnabled returns if location replace is enabled.

func (*RaftCluster) IsMakeUpReplicaEnabled

func (c *RaftCluster) IsMakeUpReplicaEnabled() bool

IsMakeUpReplicaEnabled returns if make up replica is enabled.

func (*RaftCluster) IsOneWayMergeEnabled

func (c *RaftCluster) IsOneWayMergeEnabled() bool

IsOneWayMergeEnabled returns if a region can only be merged into the next region of it.

func (*RaftCluster) IsPlacementRulesEnabled

func (c *RaftCluster) IsPlacementRulesEnabled() bool

IsPlacementRulesEnabled returns if the placement rules feature is enabled.

func (*RaftCluster) IsRegionHot

func (c *RaftCluster) IsRegionHot(region *core.RegionInfo) bool

IsRegionHot checks if a region is in hot state.

func (*RaftCluster) IsRemoveDownReplicaEnabled

func (c *RaftCluster) IsRemoveDownReplicaEnabled() bool

IsRemoveDownReplicaEnabled returns if remove down replica is enabled.

func (*RaftCluster) IsRemoveExtraReplicaEnabled

func (c *RaftCluster) IsRemoveExtraReplicaEnabled() bool

IsRemoveExtraReplicaEnabled returns if remove extra replica is enabled.

func (*RaftCluster) IsReplaceOfflineReplicaEnabled

func (c *RaftCluster) IsReplaceOfflineReplicaEnabled() bool

IsReplaceOfflineReplicaEnabled returns if replace offline replica is enabled.

func (*RaftCluster) IsRunning

func (c *RaftCluster) IsRunning() bool

IsRunning return if the cluster is running.

func (*RaftCluster) IsSchedulerPaused added in v4.0.3

func (c *RaftCluster) IsSchedulerPaused(name string) (bool, error)

IsSchedulerPaused checks if a scheduler is paused.

func (*RaftCluster) LoadClusterInfo

func (c *RaftCluster) LoadClusterInfo() (*RaftCluster, error)

LoadClusterInfo loads cluster related info.

func (*RaftCluster) LoadClusterStatus

func (c *RaftCluster) LoadClusterStatus() (*Status, error)

LoadClusterStatus loads the cluster status.

func (*RaftCluster) OnStoreVersionChange

func (c *RaftCluster) OnStoreVersionChange()

OnStoreVersionChange changes the version of the cluster when needed.

func (*RaftCluster) PauseOrResumeScheduler

func (c *RaftCluster) PauseOrResumeScheduler(name string, t int64) error

PauseOrResumeScheduler pauses or resumes a scheduler.

func (*RaftCluster) PutConfig

func (c *RaftCluster) PutConfig(meta *metapb.Cluster) error

PutConfig puts config into cluster.

func (*RaftCluster) PutStore

func (c *RaftCluster) PutStore(store *metapb.Store, force bool) error

PutStore puts a store. If 'force' is true, then overwrite the store's labels.

func (*RaftCluster) RandFollowerRegion

func (c *RaftCluster) RandFollowerRegion(storeID uint64, ranges []core.KeyRange, opts ...core.RegionOption) *core.RegionInfo

RandFollowerRegion returns a random region that has a follower on the store.

func (*RaftCluster) RandHotRegionFromStore

func (c *RaftCluster) RandHotRegionFromStore(store uint64, kind statistics.FlowKind) *core.RegionInfo

RandHotRegionFromStore randomly picks a hot region in specified store.

func (*RaftCluster) RandLeaderRegion

func (c *RaftCluster) RandLeaderRegion(storeID uint64, ranges []core.KeyRange, opts ...core.RegionOption) *core.RegionInfo

RandLeaderRegion returns a random region that has leader on the store.

func (*RaftCluster) RandLearnerRegion

func (c *RaftCluster) RandLearnerRegion(storeID uint64, ranges []core.KeyRange, opts ...core.RegionOption) *core.RegionInfo

RandLearnerRegion returns a random region that has a learner peer on the store.

func (*RaftCluster) RandPendingRegion

func (c *RaftCluster) RandPendingRegion(storeID uint64, ranges []core.KeyRange, opts ...core.RegionOption) *core.RegionInfo

RandPendingRegion returns a random region that has a pending peer on the store.

func (*RaftCluster) RegionReadStats

func (c *RaftCluster) RegionReadStats() map[uint64][]*statistics.HotPeerStat

RegionReadStats returns hot region's read stats.

func (*RaftCluster) RegionWriteStats

func (c *RaftCluster) RegionWriteStats() map[uint64][]*statistics.HotPeerStat

RegionWriteStats returns hot region's write stats.

func (*RaftCluster) RemoveScheduler

func (c *RaftCluster) RemoveScheduler(name string) error

RemoveScheduler removes a scheduler.

func (*RaftCluster) RemoveStore

func (c *RaftCluster) RemoveStore(storeID uint64) error

RemoveStore marks a store as offline in cluster. State transition: Up -> Offline.

func (*RaftCluster) RemoveStoreLimit added in v4.0.2

func (c *RaftCluster) RemoveStoreLimit(storeID uint64)

RemoveStoreLimit remove a store limit for a given store ID.

func (*RaftCluster) RemoveTombStoneRecords

func (c *RaftCluster) RemoveTombStoneRecords() error

RemoveTombStoneRecords removes the tombStone Records.

func (*RaftCluster) ScanRegions

func (c *RaftCluster) ScanRegions(startKey, endKey []byte, limit int) []*core.RegionInfo

ScanRegions scans region with start key, until the region contains endKey, or total number greater than limit.

func (*RaftCluster) SetAllStoresLimit added in v4.0.2

func (c *RaftCluster) SetAllStoresLimit(typ storelimit.Type, ratePerMin float64)

SetAllStoresLimit sets all store limit for a given type and rate.

func (*RaftCluster) SetStorage

func (c *RaftCluster) SetStorage(s *core.Storage)

SetStorage set the storage for test purpose.

func (*RaftCluster) SetStoreLimit added in v4.0.2

func (c *RaftCluster) SetStoreLimit(storeID uint64, typ storelimit.Type, ratePerMin float64)

SetStoreLimit sets a store limit for a given type and rate.

func (*RaftCluster) SetStoreState

func (c *RaftCluster) SetStoreState(storeID uint64, state metapb.StoreState) error

SetStoreState sets up a store's state.

func (*RaftCluster) SetStoreWeight

func (c *RaftCluster) SetStoreWeight(storeID uint64, leaderWeight, regionWeight float64) error

SetStoreWeight sets up a store's leader/region balance weight.

func (*RaftCluster) Start

func (c *RaftCluster) Start(s Server) error

Start starts a cluster.

func (*RaftCluster) Stop

func (c *RaftCluster) Stop()

Stop stops the cluster.

func (*RaftCluster) UnblockStore

func (c *RaftCluster) UnblockStore(storeID uint64)

UnblockStore allows balancer to select the store.

func (*RaftCluster) UpdateStoreLabels

func (c *RaftCluster) UpdateStoreLabels(storeID uint64, labels []*metapb.StoreLabel, force bool) error

UpdateStoreLabels updates a store's location labels If 'force' is true, then update the store's labels forcibly.

func (*RaftCluster) ValidRequestRegion

func (c *RaftCluster) ValidRequestRegion(reqRegion *metapb.Region) error

ValidRequestRegion is used to decide if the region is valid.

type Server

type Server interface {
	GetAllocator() *id.AllocatorImpl
	GetConfig() *config.Config
	GetPersistOptions() *config.PersistOptions
	GetStorage() *core.Storage
	GetHBStreams() opt.HeartbeatStreams
	GetRaftCluster() *RaftCluster
	GetBasicCluster() *core.BasicCluster
	ReplicateFileToAllMembers(ctx context.Context, name string, data []byte) error
}

Server is the interface for cluster.

type StatEntries

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

StatEntries saves the StatEntries for each store in the cluster

func NewStatEntries

func NewStatEntries(size int) *StatEntries

NewStatEntries returns a statistics object for the cluster

func (*StatEntries) Append

func (cst *StatEntries) Append(stat *StatEntry) bool

Append an store StatEntry

func (*StatEntries) CPU

func (cst *StatEntries) CPU(excludes ...uint64) float64

CPU returns the cpu usage of the cluster

type StatEntry

type StatEntry pdpb.StoreStats

StatEntry is an entry of store statistics

type State

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

State collects information from store heartbeat and caculates the load state of the cluster

func NewState

func NewState() *State

NewState return the LoadState object which collects information from store heartbeats and gives the current state of the cluster

func (*State) Collect

func (cs *State) Collect(stat *StatEntry)

Collect statistics from store heartbeat

func (*State) State

func (cs *State) State(excludes ...uint64) LoadState

State returns the state of the cluster, excludes is the list of store ID to be excluded

type Status

type Status struct {
	RaftBootstrapTime time.Time `json:"raft_bootstrap_time,omitempty"`
	IsInitialized     bool      `json:"is_initialized"`
}

Status saves some state information.

type StoreLimiter

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

StoreLimiter adjust the store limit dynamically

func NewStoreLimiter

func NewStoreLimiter(opt opt.Options) *StoreLimiter

NewStoreLimiter builds a store limiter object using the operator controller

func (*StoreLimiter) Collect

func (s *StoreLimiter) Collect(stats *pdpb.StoreStats)

Collect the store statistics and update the cluster state

func (*StoreLimiter) ReplaceStoreLimitScene

func (s *StoreLimiter) ReplaceStoreLimitScene(scene *storelimit.Scene, limitType storelimit.Type)

ReplaceStoreLimitScene replaces the store limit values for different scenes

func (*StoreLimiter) StoreLimitScene

func (s *StoreLimiter) StoreLimitScene(limitType storelimit.Type) *storelimit.Scene

StoreLimitScene returns the current limit for different scenes

Jump to

Keyboard shortcuts

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