Documentation ¶
Index ¶
- Constants
- Variables
- func CheckHealth(members []*pdpb.Member) map[uint64]*pdpb.Member
- func GetMembers(etcdClient *clientv3.Client) ([]*pdpb.Member, error)
- func IsCompatible(clusterVersion, v semver.Version) bool
- func MinSupportedVersion(v Feature) *semver.Version
- func MustParseVersion(v string) *semver.Version
- func ParseVersion(v string) (*semver.Version, error)
- type CPUEntries
- type Feature
- type LoadState
- type RaftCluster
- func (c *RaftCluster) AddScheduler(scheduler schedule.Scheduler, args ...string) error
- func (c *RaftCluster) AllocID() (uint64, error)
- func (c *RaftCluster) AttachAvailableFunc(storeID uint64, f func() bool)
- func (c *RaftCluster) BlockStore(storeID uint64) error
- func (c *RaftCluster) BuryStore(storeID uint64, force bool) error
- func (c *RaftCluster) CheckLabelProperty(typ string, labels []*metapb.StoreLabel) bool
- func (c *RaftCluster) CheckReadStatus(region *core.RegionInfo) []*statistics.HotPeerStat
- func (c *RaftCluster) CheckWriteStatus(region *core.RegionInfo) []*statistics.HotPeerStat
- func (c *RaftCluster) DropCacheRegion(id uint64)
- func (c *RaftCluster) FitRegion(region *core.RegionInfo) *placement.RegionFit
- func (c *RaftCluster) GetAdjacentRegions(region *core.RegionInfo) (*core.RegionInfo, *core.RegionInfo)
- func (c *RaftCluster) GetAverageRegionSize() int64
- func (c *RaftCluster) GetCacheCluster() *core.BasicCluster
- func (c *RaftCluster) GetConfig() *metapb.Cluster
- func (c *RaftCluster) GetConfigCheck() bool
- func (c *RaftCluster) GetCoordinator() *coordinator
- func (c *RaftCluster) GetFollowerStores(region *core.RegionInfo) []*core.StoreInfo
- func (c *RaftCluster) GetHeartbeatStreams() opt.HeartbeatStreams
- func (c *RaftCluster) GetHighSpaceRatio() float64
- func (c *RaftCluster) GetHotReadRegions() *statistics.StoreHotPeersInfos
- func (c *RaftCluster) GetHotRegionCacheHitsThreshold() int
- func (c *RaftCluster) GetHotRegionScheduleLimit() uint64
- func (c *RaftCluster) GetHotWriteRegions() *statistics.StoreHotPeersInfos
- func (c *RaftCluster) GetKeyType() core.KeyType
- func (c *RaftCluster) GetLeaderScheduleLimit() uint64
- func (c *RaftCluster) GetLeaderSchedulePolicy() core.SchedulePolicy
- func (c *RaftCluster) GetLeaderStore(region *core.RegionInfo) *core.StoreInfo
- func (c *RaftCluster) GetLocationLabels() []string
- func (c *RaftCluster) GetLowSpaceRatio() float64
- func (c *RaftCluster) GetMaxMergeRegionKeys() uint64
- func (c *RaftCluster) GetMaxMergeRegionSize() uint64
- func (c *RaftCluster) GetMaxPendingPeerCount() uint64
- func (c *RaftCluster) GetMaxReplicas() int
- func (c *RaftCluster) GetMaxSnapshotCount() uint64
- func (c *RaftCluster) GetMaxStoreDownTime() time.Duration
- func (c *RaftCluster) GetMergeChecker() *checker.MergeChecker
- func (c *RaftCluster) GetMergeScheduleLimit() uint64
- func (c *RaftCluster) GetMetaRegions() []*metapb.Region
- func (c *RaftCluster) GetMetaStores() []*metapb.Store
- func (c *RaftCluster) GetOperatorController() *schedule.OperatorController
- func (c *RaftCluster) GetOpt() *config.ScheduleOption
- func (c *RaftCluster) GetPatrolRegionInterval() time.Duration
- func (c *RaftCluster) GetPrevRegionByKey(regionKey []byte) (*metapb.Region, *metapb.Peer)
- func (c *RaftCluster) GetRegion(regionID uint64) *core.RegionInfo
- func (c *RaftCluster) GetRegionByID(regionID uint64) (*metapb.Region, *metapb.Peer)
- func (c *RaftCluster) GetRegionByKey(regionKey []byte) (*metapb.Region, *metapb.Peer)
- func (c *RaftCluster) GetRegionCount() int
- func (c *RaftCluster) GetRegionInfoByKey(regionKey []byte) *core.RegionInfo
- func (c *RaftCluster) GetRegionScatter() *schedule.RegionScatterer
- func (c *RaftCluster) GetRegionScheduleLimit() uint64
- func (c *RaftCluster) GetRegionStats(startKey, endKey []byte) *statistics.RegionStats
- func (c *RaftCluster) GetRegionStatsByType(typ statistics.RegionStatisticType) []*core.RegionInfo
- func (c *RaftCluster) GetRegionStores(region *core.RegionInfo) []*core.StoreInfo
- func (c *RaftCluster) GetRegionSyncer() *syncer.RegionSyncer
- func (c *RaftCluster) GetRegions() []*core.RegionInfo
- func (c *RaftCluster) GetReplicaScheduleLimit() uint64
- func (c *RaftCluster) GetReplicationConfig() *config.ReplicationConfig
- func (c *RaftCluster) GetRuleManager() *placement.RuleManager
- func (c *RaftCluster) GetSchedulerMaxWaitingOperator() uint64
- func (c *RaftCluster) GetSchedulers() map[string]*scheduleController
- func (c *RaftCluster) GetSplitMergeInterval() time.Duration
- func (c *RaftCluster) GetStorage() *core.Storage
- func (c *RaftCluster) GetStore(storeID uint64) *core.StoreInfo
- func (c *RaftCluster) GetStoreBalanceRate() float64
- func (c *RaftCluster) GetStoreCount() int
- func (c *RaftCluster) GetStoreLimiter() *StoreLimiter
- func (c *RaftCluster) GetStoreRegionCount(storeID uint64) int
- func (c *RaftCluster) GetStoreRegions(storeID uint64) []*core.RegionInfo
- func (c *RaftCluster) GetStores() []*core.StoreInfo
- func (c *RaftCluster) GetStoresBytesReadStat() map[uint64]float64
- func (c *RaftCluster) GetStoresBytesWriteStat() map[uint64]float64
- func (c *RaftCluster) GetStoresKeysReadStat() map[uint64]float64
- func (c *RaftCluster) GetStoresKeysWriteStat() map[uint64]float64
- func (c *RaftCluster) GetStoresStats() *statistics.StoresStats
- func (c *RaftCluster) GetStrictlyMatchLabel() bool
- func (c *RaftCluster) GetTolerantSizeRatio() float64
- func (c *RaftCluster) HandleAskBatchSplit(request *pdpb.AskBatchSplitRequest) (*pdpb.AskBatchSplitResponse, error)
- func (c *RaftCluster) HandleAskSplit(request *pdpb.AskSplitRequest) (*pdpb.AskSplitResponse, error)
- func (c *RaftCluster) HandleBatchReportSplit(request *pdpb.ReportBatchSplitRequest) (*pdpb.ReportBatchSplitResponse, error)
- func (c *RaftCluster) HandleRegionHeartbeat(region *core.RegionInfo) error
- func (c *RaftCluster) HandleReportSplit(request *pdpb.ReportSplitRequest) (*pdpb.ReportSplitResponse, error)
- func (c *RaftCluster) HandleStoreHeartbeat(stats *pdpb.StoreStats) error
- func (c *RaftCluster) InitCluster(id id.Allocator, opt *config.ScheduleOption, storage *core.Storage, ...)
- func (c *RaftCluster) IsCrossTableMergeEnabled() bool
- func (c *RaftCluster) IsDebugMetricsEnabled() bool
- func (c *RaftCluster) IsFeatureSupported(f Feature) bool
- func (c *RaftCluster) IsLocationReplacementEnabled() bool
- func (c *RaftCluster) IsMakeUpReplicaEnabled() bool
- func (c *RaftCluster) IsOneWayMergeEnabled() bool
- func (c *RaftCluster) IsPlacementRulesEnabled() bool
- func (c *RaftCluster) IsRegionHot(region *core.RegionInfo) bool
- func (c *RaftCluster) IsRemoveDownReplicaEnabled() bool
- func (c *RaftCluster) IsRemoveExtraReplicaEnabled() bool
- func (c *RaftCluster) IsReplaceOfflineReplicaEnabled() bool
- func (c *RaftCluster) IsRunning() bool
- func (c *RaftCluster) LoadClusterInfo() (*RaftCluster, error)
- func (c *RaftCluster) LoadClusterStatus() (*Status, error)
- func (c *RaftCluster) OnStoreVersionChange() *semver.Version
- func (c *RaftCluster) PauseOrResumeScheduler(name string, t int64) error
- func (c *RaftCluster) PutConfig(meta *metapb.Cluster) error
- func (c *RaftCluster) PutStore(store *metapb.Store) error
- func (c *RaftCluster) RandFollowerRegion(storeID uint64, ranges []core.KeyRange, opts ...core.RegionOption) *core.RegionInfo
- func (c *RaftCluster) RandHotRegionFromStore(store uint64, kind statistics.FlowKind) *core.RegionInfo
- func (c *RaftCluster) RandLeaderRegion(storeID uint64, ranges []core.KeyRange, opts ...core.RegionOption) *core.RegionInfo
- func (c *RaftCluster) RandLearnerRegion(storeID uint64, ranges []core.KeyRange, opts ...core.RegionOption) *core.RegionInfo
- func (c *RaftCluster) RandPendingRegion(storeID uint64, ranges []core.KeyRange, opts ...core.RegionOption) *core.RegionInfo
- func (c *RaftCluster) RegionReadStats() map[uint64][]*statistics.HotPeerStat
- func (c *RaftCluster) RegionWriteStats() map[uint64][]*statistics.HotPeerStat
- func (c *RaftCluster) RemoveScheduler(name string) error
- func (c *RaftCluster) RemoveStore(storeID uint64) error
- func (c *RaftCluster) RemoveTombStoneRecords() error
- func (c *RaftCluster) ScanRegions(startKey, endKey []byte, limit int) []*core.RegionInfo
- func (c *RaftCluster) SetConfigCheck()
- func (c *RaftCluster) SetStorage(s *core.Storage)
- func (c *RaftCluster) SetStoreState(storeID uint64, state metapb.StoreState) error
- func (c *RaftCluster) SetStoreWeight(storeID uint64, leaderWeight, regionWeight float64) error
- func (c *RaftCluster) Start(s Server) error
- func (c *RaftCluster) Stop()
- func (c *RaftCluster) UnblockStore(storeID uint64)
- func (c *RaftCluster) UpdateStoreLabels(storeID uint64, labels []*metapb.StoreLabel) error
- func (c *RaftCluster) ValidRequestRegion(reqRegion *metapb.Region) error
- type Server
- type StatEntries
- type StatEntry
- type State
- type Status
- type StoreLimiter
Constants ¶
const ( // PluginLoad means action for load plugin PluginLoad = "PluginLoad" // PluginUnload means action for unload plugin PluginUnload = "PluginUnload" )
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.
const StaleEntriesTimeout = 300 * time.Second
StaleEntriesTimeout is the time before an entry is deleted as stale. It is about 30 entries * 10s
Variables ¶
var ( // ErrNotBootstrapped is error info for cluster not bootstrapped. ErrNotBootstrapped = errors.New("TiKV cluster not bootstrapped, please start TiKV first") // ErrSchedulerExisted is error info for scheduler has already existed. ErrSchedulerExisted = errors.New("scheduler existed") // ErrSchedulerNotFound is error info for scheduler is not found. ErrSchedulerNotFound = errors.New("scheduler not found") )
var DialClient = &http.Client{ Timeout: clientTimeout, Transport: &http.Transport{ DisableKeepAlives: true, }, }
DialClient used to dial http request.
var ThreadsCollected = []string{"grpc-server-"}
ThreadsCollected filters the threads to take into the calculation of CPU usage.
Functions ¶
func CheckHealth ¶
CheckHealth checks if members are healthy.
func GetMembers ¶
GetMembers return a slice of Members.
func IsCompatible ¶
IsCompatible checks if the clusterVersion is compatible with the specified version.
func MinSupportedVersion ¶
MinSupportedVersion returns the minimum support version for the specified feature.
func MustParseVersion ¶
MustParseVersion wraps ParseVersion and will panic if error is not nil.
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
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
LoadStates that supported, None means no state determined
type RaftCluster ¶
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, client *clientv3.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) AttachAvailableFunc ¶
func (c *RaftCluster) AttachAvailableFunc(storeID uint64, 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) 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) GetConfig ¶
func (c *RaftCluster) GetConfig() *metapb.Cluster
GetConfig gets config from cluster.
func (*RaftCluster) GetConfigCheck ¶
func (c *RaftCluster) GetConfigCheck() bool
GetConfigCheck returns a configCheck flag.
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.ScheduleOption
GetOpt returns the scheduling options.
func (*RaftCluster) GetPatrolRegionInterval ¶
func (c *RaftCluster) GetPatrolRegionInterval() time.Duration
GetPatrolRegionInterval returns the interval of patroling region.
func (*RaftCluster) GetPrevRegionByKey ¶
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) GetRegionByID ¶
GetRegionByID gets region and leader peer by regionID from cluster.
func (*RaftCluster) GetRegionByKey ¶
GetRegionByKey gets region and leader peer by region key from cluster.
func (*RaftCluster) GetRegionCount ¶
func (c *RaftCluster) GetRegionCount() int
GetRegionCount returns total count of regions
func (*RaftCluster) GetRegionInfoByKey ¶
func (c *RaftCluster) GetRegionInfoByKey(regionKey []byte) *core.RegionInfo
GetRegionInfoByKey gets regionInfo by region key from cluster.
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) GetRuleManager ¶
func (c *RaftCluster) GetRuleManager() *placement.RuleManager
GetRuleManager returns the rule manager reference.
func (*RaftCluster) GetSchedulerMaxWaitingOperator ¶
func (c *RaftCluster) GetSchedulerMaxWaitingOperator() uint64
GetSchedulerMaxWaitingOperator returns the number of the max waiting operators.
func (*RaftCluster) GetSchedulers ¶
func (c *RaftCluster) GetSchedulers() map[string]*scheduleController
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) GetStoreBalanceRate ¶
func (c *RaftCluster) GetStoreBalanceRate() float64
GetStoreBalanceRate returns the balance rate of a store.
func (*RaftCluster) GetStoreCount ¶
func (c *RaftCluster) GetStoreCount() int
GetStoreCount returns the count of stores.
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.ScheduleOption, storage *core.Storage, basicCluster *core.BasicCluster, cb func())
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) 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() *semver.Version
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) error
PutStore puts a store.
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) 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) SetConfigCheck ¶
func (c *RaftCluster) SetConfigCheck()
SetConfigCheck sets a flag for preventing outdated config.
func (*RaftCluster) SetStorage ¶
func (c *RaftCluster) SetStorage(s *core.Storage)
SetStorage set the storage for test purpose.
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) 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) error
UpdateStoreLabels updates a store's location labels.
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 GetScheduleOption() *config.ScheduleOption GetStorage() *core.Storage GetHBStreams() opt.HeartbeatStreams GetRaftCluster() *RaftCluster GetBasicCluster() *core.BasicCluster GetSchedulersCallback() func() }
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 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
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(c *schedule.OperatorController) *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 *schedule.StoreLimitScene)
ReplaceStoreLimitScene replaces the store limit values for different scenes
func (*StoreLimiter) StoreLimitScene ¶
func (s *StoreLimiter) StoreLimitScene() *schedule.StoreLimitScene
StoreLimitScene returns the current limit for different scenes