Documentation ¶
Index ¶
- Constants
- Variables
- func CheckHealth(client *http.Client, members []*pdpb.Member) map[uint64]*pdpb.Member
- func GetMembers(etcdClient *clientv3.Client) ([]*pdpb.Member, error)
- func IsClientURL(addr string, etcdClient *clientv3.Client) bool
- type CPUEntries
- type DiagnosticResult
- type LoadState
- type RaftCluster
- func (c *RaftCluster) AddScheduler(scheduler schedule.Scheduler, args ...string) error
- func (c *RaftCluster) AddStoreLimit(store *metapb.Store)
- func (c *RaftCluster) AddSuspectKeyRange(start, end []byte)
- func (c *RaftCluster) AddSuspectRegions(regionIDs ...uint64)
- func (c *RaftCluster) BucketsStats(degree int, regions ...uint64) map[uint64][]*buckets.BucketStat
- func (c *RaftCluster) BuryStore(storeID uint64, forceBury bool) error
- func (c *RaftCluster) ClearSuspectKeyRanges()
- func (c *RaftCluster) Context() context.Context
- func (c *RaftCluster) DeleteStoreLabel(storeID uint64, labelKey string) error
- func (c *RaftCluster) DropCacheAllRegion()
- func (c *RaftCluster) DropCacheRegion(id uint64)
- func (c *RaftCluster) GetAdjacentRegions(region *core.RegionInfo) (*core.RegionInfo, *core.RegionInfo)
- func (c *RaftCluster) GetAllStoresLimit() map[uint64]config.StoreLimitConfig
- func (c *RaftCluster) GetAllocator() id.Allocator
- func (c *RaftCluster) GetAverageRegionSize() int64
- func (c *RaftCluster) GetBasicCluster() *core.BasicCluster
- func (c *RaftCluster) GetClusterVersion() string
- func (c *RaftCluster) GetCoordinator() *coordinator
- func (c *RaftCluster) GetEtcdClient() *clientv3.Client
- func (c *RaftCluster) GetExternalTS() uint64
- func (c *RaftCluster) GetFollowerStores(region *core.RegionInfo) []*core.StoreInfo
- func (c *RaftCluster) GetHotPeerStat(rw statistics.RWType, regionID, storeID uint64) *statistics.HotPeerStat
- func (c *RaftCluster) GetHotReadRegions(storeIDs ...uint64) *statistics.StoreHotPeersInfos
- func (c *RaftCluster) GetHotStat() *statistics.HotStat
- func (c *RaftCluster) GetHotWriteRegions(storeIDs ...uint64) *statistics.StoreHotPeersInfos
- func (c *RaftCluster) GetLeaderStore(region *core.RegionInfo) *core.StoreInfo
- func (c *RaftCluster) GetLeaderStoreByRegionID(regionID uint64) *core.StoreInfo
- func (c *RaftCluster) GetMergeChecker() *checker.MergeChecker
- func (c *RaftCluster) GetMetaCluster() *metapb.Cluster
- func (c *RaftCluster) GetMetaRegions() []*metapb.Region
- func (c *RaftCluster) GetMetaStores() []*metapb.Store
- func (c *RaftCluster) GetMinResolvedTS() uint64
- func (c *RaftCluster) GetNonWitnessVoterStores(region *core.RegionInfo) []*core.StoreInfo
- func (c *RaftCluster) GetOfflineRegionStatsByType(typ statistics.RegionStatisticType) []*core.RegionInfo
- func (c *RaftCluster) GetOperatorController() *schedule.OperatorController
- func (c *RaftCluster) GetOpts() sc.Config
- func (c *RaftCluster) GetPDServerConfig() *config.PDServerConfig
- func (c *RaftCluster) GetPausedSchedulerDelayAt(name string) (int64, error)
- func (c *RaftCluster) GetPausedSchedulerDelayUntil(name string) (int64, error)
- func (c *RaftCluster) GetPrevRegionByKey(regionKey []byte) *core.RegionInfo
- func (c *RaftCluster) GetProgressByAction(action string) (process, ls, cs float64, err error)
- func (c *RaftCluster) GetProgressByID(storeID string) (action string, process, ls, cs float64, err error)
- func (c *RaftCluster) GetRangeCount(startKey, endKey []byte) *statistics.RegionStats
- func (c *RaftCluster) GetRangeHoles() [][]string
- func (c *RaftCluster) GetRegion(regionID uint64) *core.RegionInfo
- func (c *RaftCluster) GetRegionByKey(regionKey []byte) *core.RegionInfo
- func (c *RaftCluster) GetRegionCount() int
- func (c *RaftCluster) GetRegionLabeler() *labeler.RegionLabeler
- func (c *RaftCluster) GetRegionScatter() *schedule.RegionScatterer
- func (c *RaftCluster) GetRegionSplitter() *schedule.RegionSplitter
- 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) GetReplicationConfig() *config.ReplicationConfig
- func (c *RaftCluster) GetReplicationMode() *replication.ModeManager
- func (c *RaftCluster) GetRuleChecker() *checker.RuleChecker
- func (c *RaftCluster) GetRuleManager() *placement.RuleManager
- func (c *RaftCluster) GetScheduleConfig() *config.ScheduleConfig
- func (c *RaftCluster) GetSchedulerHandlers() map[string]http.Handler
- func (c *RaftCluster) GetSchedulers() []string
- func (c *RaftCluster) GetStorage() storage.Storage
- func (c *RaftCluster) GetStore(storeID uint64) *core.StoreInfo
- func (c *RaftCluster) GetStoreConfig() sc.StoreConfig
- func (c *RaftCluster) GetStoreCount() int
- func (c *RaftCluster) GetStoreLimitByType(storeID uint64, typ storelimit.Type) float64
- func (c *RaftCluster) GetStoreLimiter() *StoreLimiter
- func (c *RaftCluster) GetStoreMinResolvedTS(storeID uint64) uint64
- func (c *RaftCluster) GetStoreRegionCount(storeID uint64) int
- func (c *RaftCluster) GetStoreRegions(storeID uint64) []*core.RegionInfo
- func (c *RaftCluster) GetStores() []*core.StoreInfo
- func (c *RaftCluster) GetStoresLoads() map[uint64][]float64
- func (c *RaftCluster) GetStoresStats() *statistics.StoresStats
- func (c *RaftCluster) GetSuspectRegions() []uint64
- func (c *RaftCluster) GetUnsafeRecoveryController() *unsafeRecoveryController
- 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) HandleReportBuckets(b *metapb.Buckets) error
- func (c *RaftCluster) HandleReportSplit(request *pdpb.ReportSplitRequest) (*pdpb.ReportSplitResponse, error)
- func (c *RaftCluster) HandleStoreHeartbeat(heartbeat *pdpb.StoreHeartbeatRequest, resp *pdpb.StoreHeartbeatResponse) error
- func (c *RaftCluster) InitCluster(id id.Allocator, opt *config.PersistOptions, storage storage.Storage, ...)
- func (c *RaftCluster) IsCheckerPaused(name string) (bool, error)
- func (c *RaftCluster) IsPrepared() bool
- func (c *RaftCluster) IsRegionHot(region *core.RegionInfo) bool
- func (c *RaftCluster) IsRunning() bool
- func (c *RaftCluster) IsSchedulerAllowed(name string) (bool, error)
- func (c *RaftCluster) IsSchedulerDisabled(name string) (bool, error)
- func (c *RaftCluster) IsSchedulerExisted(name string) (bool, error)
- func (c *RaftCluster) IsSchedulerPaused(name string) (bool, error)
- func (c *RaftCluster) LoadClusterInfo() (*RaftCluster, error)
- func (c *RaftCluster) LoadClusterStatus() (*Status, error)
- func (c *RaftCluster) NeedAwakenAllRegionsInStore(storeID uint64) (needAwaken bool, slowStoreIDs []uint64)
- func (c *RaftCluster) OnStoreVersionChange()
- func (c *RaftCluster) PauseLeaderTransfer(storeID uint64) error
- func (c *RaftCluster) PauseOrResumeChecker(name string, t int64) error
- func (c *RaftCluster) PauseOrResumeScheduler(name string, t int64) error
- func (c *RaftCluster) PopOneSuspectKeyRange() ([2][]byte, bool)
- func (c *RaftCluster) PutMetaCluster(meta *metapb.Cluster) error
- func (c *RaftCluster) PutStore(store *metapb.Store) error
- func (c *RaftCluster) RandFollowerRegions(storeID uint64, ranges []core.KeyRange) []*core.RegionInfo
- func (c *RaftCluster) RandLeaderRegions(storeID uint64, ranges []core.KeyRange) []*core.RegionInfo
- func (c *RaftCluster) RandLearnerRegions(storeID uint64, ranges []core.KeyRange) []*core.RegionInfo
- func (c *RaftCluster) RandPendingRegions(storeID uint64, ranges []core.KeyRange) []*core.RegionInfo
- func (c *RaftCluster) RandWitnessRegions(storeID uint64, ranges []core.KeyRange) []*core.RegionInfo
- func (c *RaftCluster) ReadyToServe(storeID uint64) error
- func (c *RaftCluster) RecordOpStepWithTTL(regionID uint64)
- 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, physicallyDestroyed bool) error
- func (c *RaftCluster) RemoveStoreLimit(storeID uint64)
- func (c *RaftCluster) RemoveSuspectRegion(id uint64)
- func (c *RaftCluster) RemoveTombStoneRecords() error
- func (c *RaftCluster) ResumeLeaderTransfer(storeID uint64)
- func (c *RaftCluster) ScanRegions(startKey, endKey []byte, limit int) []*core.RegionInfo
- func (c *RaftCluster) SetAllStoresLimit(typ storelimit.Type, ratePerMin float64) error
- func (c *RaftCluster) SetAllStoresLimitTTL(typ storelimit.Type, ratePerMin float64, ttl time.Duration)
- func (c *RaftCluster) SetExternalTS(timestamp uint64) error
- func (c *RaftCluster) SetHotPendingInfluenceMetrics(storeLabel, rwTy, dim string, load float64)
- func (c *RaftCluster) SetMinResolvedTS(storeID, minResolvedTS uint64) error
- func (c *RaftCluster) SetPDServerConfig(cfg *config.PDServerConfig)
- func (c *RaftCluster) SetPrepared()
- func (c *RaftCluster) SetScheduleConfig(cfg *config.ScheduleConfig)
- func (c *RaftCluster) SetStorage(s storage.Storage)
- func (c *RaftCluster) SetStoreLimit(storeID uint64, typ storelimit.Type, ratePerMin float64) error
- func (c *RaftCluster) SetStoreWeight(storeID uint64, leaderWeight, regionWeight float64) error
- func (c *RaftCluster) SlowStoreEvicted(storeID uint64) error
- func (c *RaftCluster) SlowStoreRecovered(storeID uint64)
- func (c *RaftCluster) SlowTrendEvicted(storeID uint64) error
- func (c *RaftCluster) SlowTrendRecovered(storeID uint64)
- func (c *RaftCluster) Start(s Server) error
- func (c *RaftCluster) Stop()
- func (c *RaftCluster) UpStore(storeID uint64) error
- func (c *RaftCluster) UpdateStoreLabels(storeID uint64, labels []*metapb.StoreLabel, force bool) error
- func (c *RaftCluster) ValidRequestRegion(reqRegion *metapb.Region) error
- type Server
- type StageOutput
- 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 ( // DefaultMinResolvedTSPersistenceInterval is the default value of min resolved ts persistence interval. // If interval in config is zero, it means not to persist resolved ts and check config with this DefaultMinResolvedTSPersistenceInterval DefaultMinResolvedTSPersistenceInterval = config.DefaultMinResolvedTSPersistenceInterval )
var DiagnosableSummaryFunc = map[string]plan.Summary{ schedulers.BalanceRegionName: schedulers.BalancePlanSummary, schedulers.BalanceLeaderName: schedulers.BalancePlanSummary, }
DiagnosableSummaryFunc includes all implementations of plan.Summary. And it also includes all schedulers which pd support to diagnose.
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.
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 DiagnosticResult ¶
type DiagnosticResult struct { Name string `json:"name"` Status string `json:"status"` Summary string `json:"summary"` Timestamp uint64 `json:"timestamp"` StoreStatus map[uint64]plan.Status `json:"-"` }
DiagnosticResult is used to save diagnostic result and is also used to output.
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, 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 ¶
func (c *RaftCluster) AddStoreLimit(store *metapb.Store)
AddStoreLimit add a store limit for a given store ID.
func (*RaftCluster) AddSuspectKeyRange ¶
func (c *RaftCluster) AddSuspectKeyRange(start, end []byte)
AddSuspectKeyRange adds the key range with the its ruleID as the key The instance of each keyRange is like following format: [2][]byte: start key/end key
func (*RaftCluster) AddSuspectRegions ¶
func (c *RaftCluster) AddSuspectRegions(regionIDs ...uint64)
AddSuspectRegions adds regions to suspect list.
func (*RaftCluster) BucketsStats ¶
func (c *RaftCluster) BucketsStats(degree int, regions ...uint64) map[uint64][]*buckets.BucketStat
BucketsStats returns hot region's buckets stats.
func (*RaftCluster) BuryStore ¶
func (c *RaftCluster) BuryStore(storeID uint64, forceBury bool) error
BuryStore marks a store as tombstone in cluster. If forceBury is false, the store should be offlined and emptied before calling this func.
func (*RaftCluster) ClearSuspectKeyRanges ¶
func (c *RaftCluster) ClearSuspectKeyRanges()
ClearSuspectKeyRanges clears the suspect keyRanges, only for unit test
func (*RaftCluster) Context ¶
func (c *RaftCluster) Context() context.Context
Context returns the context of RaftCluster.
func (*RaftCluster) DeleteStoreLabel ¶
func (c *RaftCluster) DeleteStoreLabel(storeID uint64, labelKey string) error
DeleteStoreLabel updates a store's location labels
func (*RaftCluster) DropCacheAllRegion ¶
func (c *RaftCluster) DropCacheAllRegion()
DropCacheAllRegion removes all regions from the cache.
func (*RaftCluster) DropCacheRegion ¶
func (c *RaftCluster) DropCacheRegion(id uint64)
DropCacheRegion removes a region from the cache.
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 ¶
func (c *RaftCluster) GetAllStoresLimit() map[uint64]config.StoreLimitConfig
GetAllStoresLimit returns all store limit
func (*RaftCluster) GetAllocator ¶
func (c *RaftCluster) GetAllocator() id.Allocator
GetAllocator returns cluster's id allocator.
func (*RaftCluster) GetAverageRegionSize ¶
func (c *RaftCluster) GetAverageRegionSize() int64
GetAverageRegionSize returns the average region approximate size.
func (*RaftCluster) GetBasicCluster ¶
func (c *RaftCluster) GetBasicCluster() *core.BasicCluster
GetBasicCluster returns the basic cluster.
func (*RaftCluster) GetClusterVersion ¶
func (c *RaftCluster) GetClusterVersion() string
GetClusterVersion returns the current cluster version.
func (*RaftCluster) GetCoordinator ¶
func (c *RaftCluster) GetCoordinator() *coordinator
GetCoordinator returns the coordinator.
func (*RaftCluster) GetEtcdClient ¶
func (c *RaftCluster) GetEtcdClient() *clientv3.Client
GetEtcdClient returns the current etcd client
func (*RaftCluster) GetExternalTS ¶
func (c *RaftCluster) GetExternalTS() uint64
GetExternalTS returns the external timestamp.
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) GetHotPeerStat ¶
func (c *RaftCluster) GetHotPeerStat(rw statistics.RWType, regionID, storeID uint64) *statistics.HotPeerStat
GetHotPeerStat returns hot peer stat with specified regionID and storeID.
func (*RaftCluster) GetHotReadRegions ¶
func (c *RaftCluster) GetHotReadRegions(storeIDs ...uint64) *statistics.StoreHotPeersInfos
GetHotReadRegions gets hot read regions' info.
func (*RaftCluster) GetHotStat ¶
func (c *RaftCluster) GetHotStat() *statistics.HotStat
GetHotStat gets hot stat for test.
func (*RaftCluster) GetHotWriteRegions ¶
func (c *RaftCluster) GetHotWriteRegions(storeIDs ...uint64) *statistics.StoreHotPeersInfos
GetHotWriteRegions gets hot write regions' info.
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) GetLeaderStoreByRegionID ¶
func (c *RaftCluster) GetLeaderStoreByRegionID(regionID uint64) *core.StoreInfo
GetLeaderStoreByRegionID returns the leader store of the given region.
func (*RaftCluster) GetMergeChecker ¶
func (c *RaftCluster) GetMergeChecker() *checker.MergeChecker
GetMergeChecker returns merge checker.
func (*RaftCluster) GetMetaCluster ¶
func (c *RaftCluster) GetMetaCluster() *metapb.Cluster
GetMetaCluster gets meta cluster.
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) GetMinResolvedTS ¶
func (c *RaftCluster) GetMinResolvedTS() uint64
GetMinResolvedTS returns the min resolved ts of the cluster.
func (*RaftCluster) GetNonWitnessVoterStores ¶
func (c *RaftCluster) GetNonWitnessVoterStores(region *core.RegionInfo) []*core.StoreInfo
GetNonWitnessVoterStores returns all stores that contains the region's non-witness voter peer.
func (*RaftCluster) GetOfflineRegionStatsByType ¶
func (c *RaftCluster) GetOfflineRegionStatsByType(typ statistics.RegionStatisticType) []*core.RegionInfo
GetOfflineRegionStatsByType gets the status of the offline region by types.
func (*RaftCluster) GetOperatorController ¶
func (c *RaftCluster) GetOperatorController() *schedule.OperatorController
GetOperatorController returns the operator controller.
func (*RaftCluster) GetOpts ¶
func (c *RaftCluster) GetOpts() sc.Config
GetOpts returns cluster's configuration. There is no need a lock since it won't changed.
func (*RaftCluster) GetPDServerConfig ¶
func (c *RaftCluster) GetPDServerConfig() *config.PDServerConfig
GetPDServerConfig returns pd server configurations.
func (*RaftCluster) GetPausedSchedulerDelayAt ¶
func (c *RaftCluster) GetPausedSchedulerDelayAt(name string) (int64, error)
GetPausedSchedulerDelayAt returns DelayAt of a paused scheduler
func (*RaftCluster) GetPausedSchedulerDelayUntil ¶
func (c *RaftCluster) GetPausedSchedulerDelayUntil(name string) (int64, error)
GetPausedSchedulerDelayUntil returns DelayUntil of a paused scheduler
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) GetProgressByAction ¶
func (c *RaftCluster) GetProgressByAction(action string) (process, ls, cs float64, err error)
GetProgressByAction returns the progress details for a given action.
func (*RaftCluster) GetProgressByID ¶
func (c *RaftCluster) GetProgressByID(storeID string) (action string, process, ls, cs float64, err error)
GetProgressByID returns the progress details for a given store ID.
func (*RaftCluster) GetRangeCount ¶
func (c *RaftCluster) GetRangeCount(startKey, endKey []byte) *statistics.RegionStats
GetRangeCount returns the number of regions in the range.
func (*RaftCluster) GetRangeHoles ¶
func (c *RaftCluster) GetRangeHoles() [][]string
GetRangeHoles returns all range holes, i.e the key ranges without any region info.
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) GetRegionLabeler ¶
func (c *RaftCluster) GetRegionLabeler() *labeler.RegionLabeler
GetRegionLabeler returns the region labeler.
func (*RaftCluster) GetRegionScatter ¶
func (c *RaftCluster) GetRegionScatter() *schedule.RegionScatterer
GetRegionScatter returns the region scatter.
func (*RaftCluster) GetRegionSplitter ¶
func (c *RaftCluster) GetRegionSplitter() *schedule.RegionSplitter
GetRegionSplitter returns the region splitter
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) GetReplicationConfig ¶
func (c *RaftCluster) GetReplicationConfig() *config.ReplicationConfig
GetReplicationConfig returns replication configurations.
func (*RaftCluster) GetReplicationMode ¶
func (c *RaftCluster) GetReplicationMode() *replication.ModeManager
GetReplicationMode returns the ReplicationMode.
func (*RaftCluster) GetRuleChecker ¶
func (c *RaftCluster) GetRuleChecker() *checker.RuleChecker
GetRuleChecker returns rule checker.
func (*RaftCluster) GetRuleManager ¶
func (c *RaftCluster) GetRuleManager() *placement.RuleManager
GetRuleManager returns the rule manager reference.
func (*RaftCluster) GetScheduleConfig ¶
func (c *RaftCluster) GetScheduleConfig() *config.ScheduleConfig
GetScheduleConfig returns scheduling configurations.
func (*RaftCluster) GetSchedulerHandlers ¶
func (c *RaftCluster) GetSchedulerHandlers() map[string]http.Handler
GetSchedulerHandlers gets all scheduler handlers.
func (*RaftCluster) GetSchedulers ¶
func (c *RaftCluster) GetSchedulers() []string
GetSchedulers gets all schedulers.
func (*RaftCluster) GetStorage ¶
func (c *RaftCluster) GetStorage() storage.Storage
GetStorage returns the storage.
func (*RaftCluster) GetStore ¶
func (c *RaftCluster) GetStore(storeID uint64) *core.StoreInfo
GetStore gets store from cluster.
func (*RaftCluster) GetStoreConfig ¶
func (c *RaftCluster) GetStoreConfig() sc.StoreConfig
GetStoreConfig returns the store config.
func (*RaftCluster) GetStoreCount ¶
func (c *RaftCluster) GetStoreCount() int
GetStoreCount returns the count of stores.
func (*RaftCluster) GetStoreLimitByType ¶
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) GetStoreMinResolvedTS ¶
func (c *RaftCluster) GetStoreMinResolvedTS(storeID uint64) uint64
GetStoreMinResolvedTS returns the min resolved ts of the store.
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) GetStoresLoads ¶
func (c *RaftCluster) GetStoresLoads() map[uint64][]float64
GetStoresLoads returns load stats of all stores.
func (*RaftCluster) GetStoresStats ¶
func (c *RaftCluster) GetStoresStats() *statistics.StoresStats
GetStoresStats returns stores' statistics from cluster. And it will be unnecessary to filter unhealthy store, because it has been solved in process heartbeat
func (*RaftCluster) GetSuspectRegions ¶
func (c *RaftCluster) GetSuspectRegions() []uint64
GetSuspectRegions gets all suspect regions.
func (*RaftCluster) GetUnsafeRecoveryController ¶
func (c *RaftCluster) GetUnsafeRecoveryController() *unsafeRecoveryController
GetUnsafeRecoveryController returns the unsafe recovery controller.
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) HandleReportBuckets ¶
func (c *RaftCluster) HandleReportBuckets(b *metapb.Buckets) error
HandleReportBuckets processes buckets 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(heartbeat *pdpb.StoreHeartbeatRequest, resp *pdpb.StoreHeartbeatResponse) error
HandleStoreHeartbeat updates the store status.
func (*RaftCluster) InitCluster ¶
func (c *RaftCluster) InitCluster( id id.Allocator, opt *config.PersistOptions, storage storage.Storage, basicCluster *core.BasicCluster, keyspaceGroupManager *keyspace.GroupManager)
InitCluster initializes the raft cluster.
func (*RaftCluster) IsCheckerPaused ¶
func (c *RaftCluster) IsCheckerPaused(name string) (bool, error)
IsCheckerPaused returns if checker is paused
func (*RaftCluster) IsPrepared ¶
func (c *RaftCluster) IsPrepared() bool
IsPrepared return true if the prepare checker is ready.
func (*RaftCluster) IsRegionHot ¶
func (c *RaftCluster) IsRegionHot(region *core.RegionInfo) bool
IsRegionHot checks if a region is in hot state.
func (*RaftCluster) IsRunning ¶
func (c *RaftCluster) IsRunning() bool
IsRunning return if the cluster is running.
func (*RaftCluster) IsSchedulerAllowed ¶
func (c *RaftCluster) IsSchedulerAllowed(name string) (bool, error)
IsSchedulerAllowed checks if a scheduler is allowed.
func (*RaftCluster) IsSchedulerDisabled ¶
func (c *RaftCluster) IsSchedulerDisabled(name string) (bool, error)
IsSchedulerDisabled checks if a scheduler is disabled.
func (*RaftCluster) IsSchedulerExisted ¶
func (c *RaftCluster) IsSchedulerExisted(name string) (bool, error)
IsSchedulerExisted checks if a scheduler is existed.
func (*RaftCluster) IsSchedulerPaused ¶
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) NeedAwakenAllRegionsInStore ¶
func (c *RaftCluster) NeedAwakenAllRegionsInStore(storeID uint64) (needAwaken bool, slowStoreIDs []uint64)
NeedAwakenAllRegionsInStore checks whether we should do AwakenRegions operation.
func (*RaftCluster) OnStoreVersionChange ¶
func (c *RaftCluster) OnStoreVersionChange()
OnStoreVersionChange changes the version of the cluster when needed.
func (*RaftCluster) PauseLeaderTransfer ¶
func (c *RaftCluster) PauseLeaderTransfer(storeID uint64) error
PauseLeaderTransfer prevents the store from been selected as source or target store of TransferLeader.
func (*RaftCluster) PauseOrResumeChecker ¶
func (c *RaftCluster) PauseOrResumeChecker(name string, t int64) error
PauseOrResumeChecker pauses or resumes checker.
func (*RaftCluster) PauseOrResumeScheduler ¶
func (c *RaftCluster) PauseOrResumeScheduler(name string, t int64) error
PauseOrResumeScheduler pauses or resumes a scheduler.
func (*RaftCluster) PopOneSuspectKeyRange ¶
func (c *RaftCluster) PopOneSuspectKeyRange() ([2][]byte, bool)
PopOneSuspectKeyRange gets one suspect keyRange group. it would return value and true if pop success, or return empty [][2][]byte and false if suspectKeyRanges couldn't pop keyRange group.
func (*RaftCluster) PutMetaCluster ¶
func (c *RaftCluster) PutMetaCluster(meta *metapb.Cluster) error
PutMetaCluster puts meta cluster.
func (*RaftCluster) PutStore ¶
func (c *RaftCluster) PutStore(store *metapb.Store) error
PutStore puts a store.
func (*RaftCluster) RandFollowerRegions ¶
func (c *RaftCluster) RandFollowerRegions(storeID uint64, ranges []core.KeyRange) []*core.RegionInfo
RandFollowerRegions returns some random regions that has a follower on the store.
func (*RaftCluster) RandLeaderRegions ¶
func (c *RaftCluster) RandLeaderRegions(storeID uint64, ranges []core.KeyRange) []*core.RegionInfo
RandLeaderRegions returns some random regions that has leader on the store.
func (*RaftCluster) RandLearnerRegions ¶
func (c *RaftCluster) RandLearnerRegions(storeID uint64, ranges []core.KeyRange) []*core.RegionInfo
RandLearnerRegions returns some random regions that has a learner peer on the store.
func (*RaftCluster) RandPendingRegions ¶
func (c *RaftCluster) RandPendingRegions(storeID uint64, ranges []core.KeyRange) []*core.RegionInfo
RandPendingRegions returns some random regions that has a pending peer on the store.
func (*RaftCluster) RandWitnessRegions ¶
func (c *RaftCluster) RandWitnessRegions(storeID uint64, ranges []core.KeyRange) []*core.RegionInfo
RandWitnessRegions returns some random regions that has a witness peer on the store.
func (*RaftCluster) ReadyToServe ¶
func (c *RaftCluster) ReadyToServe(storeID uint64) error
ReadyToServe change store's node state to Serving.
func (*RaftCluster) RecordOpStepWithTTL ¶
func (c *RaftCluster) RecordOpStepWithTTL(regionID uint64)
RecordOpStepWithTTL records OpStep with TTL
func (*RaftCluster) RegionReadStats ¶
func (c *RaftCluster) RegionReadStats() map[uint64][]*statistics.HotPeerStat
RegionReadStats returns hot region's read stats. The result only includes peers that are hot enough. RegionStats is a thread-safe method
func (*RaftCluster) RegionWriteStats ¶
func (c *RaftCluster) RegionWriteStats() map[uint64][]*statistics.HotPeerStat
RegionWriteStats returns hot region's write stats. The result only includes peers that are hot enough.
func (*RaftCluster) RemoveScheduler ¶
func (c *RaftCluster) RemoveScheduler(name string) error
RemoveScheduler removes a scheduler.
func (*RaftCluster) RemoveStore ¶
func (c *RaftCluster) RemoveStore(storeID uint64, physicallyDestroyed bool) error
RemoveStore marks a store as offline in cluster. State transition: Up -> Offline.
func (*RaftCluster) RemoveStoreLimit ¶
func (c *RaftCluster) RemoveStoreLimit(storeID uint64)
RemoveStoreLimit remove a store limit for a given store ID.
func (*RaftCluster) RemoveSuspectRegion ¶
func (c *RaftCluster) RemoveSuspectRegion(id uint64)
RemoveSuspectRegion removes region from suspect list.
func (*RaftCluster) RemoveTombStoneRecords ¶
func (c *RaftCluster) RemoveTombStoneRecords() error
RemoveTombStoneRecords removes the tombStone Records.
func (*RaftCluster) ResumeLeaderTransfer ¶
func (c *RaftCluster) ResumeLeaderTransfer(storeID uint64)
ResumeLeaderTransfer cleans a store's pause state. The store can be selected as source or target of TransferLeader again.
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 ¶
func (c *RaftCluster) SetAllStoresLimit(typ storelimit.Type, ratePerMin float64) error
SetAllStoresLimit sets all store limit for a given type and rate.
func (*RaftCluster) SetAllStoresLimitTTL ¶
func (c *RaftCluster) SetAllStoresLimitTTL(typ storelimit.Type, ratePerMin float64, ttl time.Duration)
SetAllStoresLimitTTL sets all store limit for a given type and rate with ttl.
func (*RaftCluster) SetExternalTS ¶
func (c *RaftCluster) SetExternalTS(timestamp uint64) error
SetExternalTS sets the external timestamp.
func (*RaftCluster) SetHotPendingInfluenceMetrics ¶
func (c *RaftCluster) SetHotPendingInfluenceMetrics(storeLabel, rwTy, dim string, load float64)
SetHotPendingInfluenceMetrics sets pending influence in hot scheduler.
func (*RaftCluster) SetMinResolvedTS ¶
func (c *RaftCluster) SetMinResolvedTS(storeID, minResolvedTS uint64) error
SetMinResolvedTS sets up a store with min resolved ts.
func (*RaftCluster) SetPDServerConfig ¶
func (c *RaftCluster) SetPDServerConfig(cfg *config.PDServerConfig)
SetPDServerConfig sets the PD configuration.
func (*RaftCluster) SetPrepared ¶
func (c *RaftCluster) SetPrepared()
SetPrepared set the prepare check to prepared. Only for test purpose.
func (*RaftCluster) SetScheduleConfig ¶
func (c *RaftCluster) SetScheduleConfig(cfg *config.ScheduleConfig)
SetScheduleConfig sets the PD scheduling configuration.
func (*RaftCluster) SetStorage ¶
func (c *RaftCluster) SetStorage(s storage.Storage)
SetStorage set the storage for test purpose.
func (*RaftCluster) SetStoreLimit ¶
func (c *RaftCluster) SetStoreLimit(storeID uint64, typ storelimit.Type, ratePerMin float64) error
SetStoreLimit sets a store limit for a given type and rate.
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) SlowStoreEvicted ¶
func (c *RaftCluster) SlowStoreEvicted(storeID uint64) error
SlowStoreEvicted marks a store as a slow store and prevents transferring leader to the store
func (*RaftCluster) SlowStoreRecovered ¶
func (c *RaftCluster) SlowStoreRecovered(storeID uint64)
SlowStoreRecovered cleans the evicted state of a store.
func (*RaftCluster) SlowTrendEvicted ¶
func (c *RaftCluster) SlowTrendEvicted(storeID uint64) error
SlowTrendEvicted marks a store as a slow store by trend and prevents transferring leader to the store
func (*RaftCluster) SlowTrendRecovered ¶
func (c *RaftCluster) SlowTrendRecovered(storeID uint64)
SlowTrendRecovered cleans the evicted by slow trend state of a store.
func (*RaftCluster) UpStore ¶
func (c *RaftCluster) UpStore(storeID uint64) error
UpStore up a store from offline
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, the origin labels will be overwritten with the new one 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.Allocator GetConfig() *config.Config GetPersistOptions() *config.PersistOptions GetStorage() storage.Storage GetHBStreams() *hbstream.HeartbeatStreams GetRaftCluster() *RaftCluster GetBasicCluster() *core.BasicCluster GetMembers() ([]*pdpb.Member, error) ReplicateFileToMember(ctx context.Context, member *pdpb.Member, name string, data []byte) error GetKeyspaceGroupManager() *keyspace.GroupManager IsAPIServiceMode() bool }
Server is the interface for cluster.
type StageOutput ¶
type StageOutput struct { Info string `json:"info,omitempty"` Time string `json:"time,omitempty"` Actions map[string][]string `json:"actions,omitempty"` Details []string `json:"details,omitempty"` }
StageOutput is the information for one stage of the recovery process.
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 calculates 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"` ReplicationStatus string `json:"replication_status"` }
Status saves some state information. NOTE: This type is exported by HTTP API. Please pay more attention when modifying it.
type StoreLimiter ¶
type StoreLimiter struct {
// contains filtered or unexported fields
}
StoreLimiter adjust the store limit dynamically
func NewStoreLimiter ¶
func NewStoreLimiter(opt *config.PersistOptions) *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