Documentation ¶
Index ¶
- Constants
- func CollectTiFlashStatus(statusAddress string, keyspaceID tikv.KeyspaceID, tableID int64, ...) error
- func ComputeTiFlashStatus(reader *bufio.Reader, regionReplica *map[int64]int) error
- func GetTiFlashTableIDFromEndKey(endKey string) int64
- type FrameItem
- type Helper
- func (h *Helper) DeletePlacementRule(group string, ruleID string) error
- func (h *Helper) FetchHotRegion(rw string) (map[uint64]RegionMetric, error)
- func (h *Helper) FetchRegionTableIndex(metrics map[uint64]RegionMetric, allSchemas []*model.DBInfo) ([]HotTableIndex, error)
- func (*Helper) FilterMemDBs(oldSchemas []*model.DBInfo) (schemas []*model.DBInfo)
- func (*Helper) FindTableIndexOfRegion(allSchemas []*model.DBInfo, hotRange *RegionFrameRange) *FrameItem
- func (h *Helper) GetGroupRules(group string) ([]placement.Rule, error)
- func (h *Helper) GetMvccByEncodedKey(encodedKey kv.Key) (*kvrpcpb.MvccGetByKeyResponse, error)
- func (h *Helper) GetMvccByEncodedKeyWithTS(encodedKey kv.Key, startTS uint64) (*kvrpcpb.MvccGetByKeyResponse, error)
- func (h *Helper) GetMvccByStartTs(startTS uint64, startKey, endKey kv.Key) (*MvccKV, error)
- func (h *Helper) GetPDAddr() ([]string, error)
- func (h *Helper) GetPDRegionStats(tableID int64, stats *PDRegionStats, noIndexStats bool) error
- func (h *Helper) GetRegionByKey(k []byte) (*RegionInfo, error)
- func (h *Helper) GetRegionInfoByID(regionID uint64) (*RegionInfo, error)
- func (h *Helper) GetRegionsInfo() (*RegionsInfo, error)
- func (h *Helper) GetRegionsInfoByRange(sk, ek []byte) (*RegionsInfo, error)
- func (h *Helper) GetRegionsTableInfo(regionsInfo *RegionsInfo, schemas []*model.DBInfo) map[int64][]TableInfo
- func (h *Helper) GetStoreRegionsInfo(storeID uint64) (*RegionsInfo, error)
- func (h *Helper) GetStoresStat() (*StoresStat, error)
- func (*Helper) GetTablesInfoWithKeyRange(schemas []*model.DBInfo) []TableInfoWithKeyRange
- func (*Helper) ParseRegionsTableInfos(regionsInfo []*RegionInfo, tables []TableInfoWithKeyRange) map[int64][]TableInfo
- func (h *Helper) PostAccelerateSchedule(tableID int64) error
- func (h *Helper) ScrapeHotInfo(rw string, allSchemas []*model.DBInfo) ([]HotTableIndex, error)
- func (h *Helper) SetPlacementRule(rule placement.Rule) error
- type HotRegionsStat
- type HotTableIndex
- type MvccKV
- type PDRegionStats
- type RegionEpoch
- type RegionFrameRange
- type RegionInfo
- type RegionMetric
- type RegionPeer
- type RegionPeerStat
- type RegionStat
- type RegionsInfo
- type ReplicationStatus
- type Storage
- type StoreBaseStat
- type StoreDetailStat
- type StoreHotRegionInfos
- type StoreLabel
- type StoreStat
- type StoresStat
- type TableInfo
- type TableInfoWithKeyRange
- type TblIndex
Constants ¶
const MaxBackoffTimeoutForMvccGet = 5000
MaxBackoffTimeoutForMvccGet is a derived value from previous implementation possible experiencing value 5000ms.
Variables ¶
This section is empty.
Functions ¶
func CollectTiFlashStatus ¶
func CollectTiFlashStatus(statusAddress string, keyspaceID tikv.KeyspaceID, tableID int64, regionReplica *map[int64]int) error
CollectTiFlashStatus query sync status of one table from TiFlash store. `regionReplica` is a map from RegionID to count of TiFlash Replicas in this region.
func ComputeTiFlashStatus ¶
ComputeTiFlashStatus is helper function for CollectTiFlashStatus.
func GetTiFlashTableIDFromEndKey ¶
GetTiFlashTableIDFromEndKey computes tableID from pd rule's endKey.
Types ¶
type FrameItem ¶
type FrameItem struct { DBName string `json:"db_name"` TableName string `json:"table_name"` TableID int64 `json:"table_id"` IsRecord bool `json:"is_record"` RecordID int64 `json:"record_id,omitempty"` IndexName string `json:"index_name,omitempty"` IndexID int64 `json:"index_id,omitempty"` IndexValues []string `json:"index_values,omitempty"` }
FrameItem includes a index's or record's meta data with table's info.
func NewFrameItemFromRegionKey ¶
NewFrameItemFromRegionKey creates a FrameItem with region's startKey or endKey, returns err when key is illegal.
type Helper ¶
type Helper struct { Store Storage RegionCache *tikv.RegionCache }
Helper is a middleware to get some information from tikv/pd. It can be used for TiDB's http api or mem table.
func (*Helper) DeletePlacementRule ¶
DeletePlacementRule is to delete placement rule for certain group.
func (*Helper) FetchHotRegion ¶
func (h *Helper) FetchHotRegion(rw string) (map[uint64]RegionMetric, error)
FetchHotRegion fetches the hot region information from PD's http api.
func (*Helper) FetchRegionTableIndex ¶
func (h *Helper) FetchRegionTableIndex(metrics map[uint64]RegionMetric, allSchemas []*model.DBInfo) ([]HotTableIndex, error)
FetchRegionTableIndex constructs a map that maps a table to its hot region information by the given raw hot RegionMetric metrics.
func (*Helper) FilterMemDBs ¶
FilterMemDBs filters memory databases in the input schemas.
func (*Helper) FindTableIndexOfRegion ¶
func (*Helper) FindTableIndexOfRegion(allSchemas []*model.DBInfo, hotRange *RegionFrameRange) *FrameItem
FindTableIndexOfRegion finds what table is involved in this hot region. And constructs the new frame item for future use.
func (*Helper) GetGroupRules ¶
GetGroupRules to get all placement rule in a certain group.
func (*Helper) GetMvccByEncodedKey ¶
GetMvccByEncodedKey get the MVCC value by the specific encoded key.
func (*Helper) GetMvccByEncodedKeyWithTS ¶
func (h *Helper) GetMvccByEncodedKeyWithTS(encodedKey kv.Key, startTS uint64) (*kvrpcpb.MvccGetByKeyResponse, error)
GetMvccByEncodedKeyWithTS get the MVCC value by the specific encoded key, if lock is encountered it would be resolved.
func (*Helper) GetMvccByStartTs ¶
GetMvccByStartTs gets Mvcc info by startTS from tikv.
func (*Helper) GetPDRegionStats ¶
func (h *Helper) GetPDRegionStats(tableID int64, stats *PDRegionStats, noIndexStats bool) error
GetPDRegionStats get the RegionStats by tableID.
func (*Helper) GetRegionByKey ¶
func (h *Helper) GetRegionByKey(k []byte) (*RegionInfo, error)
GetRegionByKey gets regioninfo by key
func (*Helper) GetRegionInfoByID ¶
func (h *Helper) GetRegionInfoByID(regionID uint64) (*RegionInfo, error)
GetRegionInfoByID gets the region information of the region ID by using PD's api.
func (*Helper) GetRegionsInfo ¶
func (h *Helper) GetRegionsInfo() (*RegionsInfo, error)
GetRegionsInfo gets the region information of current store by using PD's api.
func (*Helper) GetRegionsInfoByRange ¶
func (h *Helper) GetRegionsInfoByRange(sk, ek []byte) (*RegionsInfo, error)
GetRegionsInfoByRange scans region by key range
func (*Helper) GetRegionsTableInfo ¶
func (h *Helper) GetRegionsTableInfo(regionsInfo *RegionsInfo, schemas []*model.DBInfo) map[int64][]TableInfo
GetRegionsTableInfo returns a map maps region id to its tables or indices. Assuming tables or indices key ranges never intersect. Regions key ranges can intersect.
func (*Helper) GetStoreRegionsInfo ¶
func (h *Helper) GetStoreRegionsInfo(storeID uint64) (*RegionsInfo, error)
GetStoreRegionsInfo gets the region in given store.
func (*Helper) GetStoresStat ¶
func (h *Helper) GetStoresStat() (*StoresStat, error)
GetStoresStat gets the TiKV store information by accessing PD's api.
func (*Helper) GetTablesInfoWithKeyRange ¶
func (*Helper) GetTablesInfoWithKeyRange(schemas []*model.DBInfo) []TableInfoWithKeyRange
GetTablesInfoWithKeyRange returns a slice containing tableInfos with key ranges of all tables in schemas.
func (*Helper) ParseRegionsTableInfos ¶
func (*Helper) ParseRegionsTableInfos(regionsInfo []*RegionInfo, tables []TableInfoWithKeyRange) map[int64][]TableInfo
ParseRegionsTableInfos parses the tables or indices in regions according to key range.
func (*Helper) PostAccelerateSchedule ¶
PostAccelerateSchedule sends `regions/accelerate-schedule` request.
func (*Helper) ScrapeHotInfo ¶
ScrapeHotInfo gets the needed hot region information by the url given.
type HotRegionsStat ¶
type HotRegionsStat struct {
RegionsStat []RegionStat `json:"statistics"`
}
HotRegionsStat records echo store's hot region. it's the response of PD.
type HotTableIndex ¶
type HotTableIndex struct { RegionID uint64 `json:"region_id"` RegionMetric *RegionMetric `json:"region_metric"` DbName string `json:"db_name"` TableName string `json:"table_name"` TableID int64 `json:"table_id"` IndexName string `json:"index_name"` IndexID int64 `json:"index_id"` }
HotTableIndex contains region and its table/index info.
type MvccKV ¶
type MvccKV struct { Key string `json:"key"` RegionID uint64 `json:"region_id"` Value *kvrpcpb.MvccGetByKeyResponse `json:"value"` }
MvccKV wraps the key's mvcc info in tikv.
type PDRegionStats ¶
type PDRegionStats struct { Count int `json:"count"` EmptyCount int `json:"empty_count"` StorageSize int64 `json:"storage_size"` StorageKeys int64 `json:"storage_keys"` StoreLeaderCount map[uint64]int `json:"store_leader_count"` StorePeerCount map[uint64]int `json:"store_peer_count"` }
PDRegionStats is the json response from PD.
type RegionEpoch ¶
RegionEpoch stores the information about its epoch.
type RegionFrameRange ¶
type RegionFrameRange struct { First *FrameItem // start frame of the region Last *FrameItem // end frame of the region // contains filtered or unexported fields }
RegionFrameRange contains a frame range info which the region covered.
func NewRegionFrameRange ¶
func NewRegionFrameRange(region *tikv.KeyLocation) (idxRange *RegionFrameRange, err error)
NewRegionFrameRange init a NewRegionFrameRange with region info.
func (*RegionFrameRange) GetIndexFrame ¶
func (r *RegionFrameRange) GetIndexFrame(tableID, indexID int64, dbName, tableName, indexName string) *FrameItem
GetIndexFrame returns the indnex frame of a table. If the table's indices are not covered by this frame range, it returns nil.
func (*RegionFrameRange) GetRecordFrame ¶
func (r *RegionFrameRange) GetRecordFrame(tableID int64, dbName, tableName string, isCommonHandle bool) (f *FrameItem)
GetRecordFrame returns the record frame of a table. If the table's records are not covered by this frame range, it returns nil.
type RegionInfo ¶
type RegionInfo struct { ID int64 `json:"id"` StartKey string `json:"start_key"` EndKey string `json:"end_key"` Epoch RegionEpoch `json:"epoch"` Peers []RegionPeer `json:"peers"` Leader RegionPeer `json:"leader"` DownPeers []RegionPeerStat `json:"down_peers"` PendingPeers []RegionPeer `json:"pending_peers"` WrittenBytes uint64 `json:"written_bytes"` ReadBytes uint64 `json:"read_bytes"` ApproximateSize int64 `json:"approximate_size"` ApproximateKeys int64 `json:"approximate_keys"` ReplicationStatus *ReplicationStatus `json:"replication_status,omitempty"` }
RegionInfo stores the information of one region.
type RegionMetric ¶
type RegionMetric struct { FlowBytes uint64 `json:"flow_bytes"` MaxHotDegree int `json:"max_hot_degree"` Count int `json:"region_count"` }
RegionMetric presents the final metric output entry.
type RegionPeer ¶
type RegionPeer struct { ID int64 `json:"id"` StoreID int64 `json:"store_id"` IsLearner bool `json:"is_learner"` }
RegionPeer stores information of one peer.
type RegionPeerStat ¶
type RegionPeerStat struct { Peer RegionPeer `json:"peer"` DownSec int64 `json:"down_seconds"` }
RegionPeerStat stores one field `DownSec` which indicates how long it's down than `RegionPeer`.
type RegionStat ¶
type RegionStat struct { RegionID uint64 `json:"region_id"` FlowBytes float64 `json:"flow_bytes"` HotDegree int `json:"hot_degree"` }
RegionStat records each hot region's statistics it's the response of PD.
type RegionsInfo ¶
type RegionsInfo struct { Count int64 `json:"count"` Regions []RegionInfo `json:"regions"` }
RegionsInfo stores the information of regions.
func (*RegionsInfo) Merge ¶
func (r *RegionsInfo) Merge(other *RegionsInfo) *RegionsInfo
Merge merged 2 regionsInfo into one
type ReplicationStatus ¶
ReplicationStatus represents the replication mode status of the region.
type Storage ¶
type Storage interface { Begin(opts ...tikv.TxnOption) (kv.Transaction, error) GetSnapshot(ver kv.Version) kv.Snapshot GetClient() kv.Client GetMPPClient() kv.MPPClient Close() error UUID() string CurrentVersion(txnScope string) (kv.Version, error) CurrentTimestamp(txnScop string) (uint64, error) GetOracle() oracle.Oracle SupportDeleteRange() (supported bool) Name() string Describe() string ShowStatus(ctx context.Context, key string) (interface{}, error) GetMemCache() kv.MemManager GetRegionCache() *tikv.RegionCache SendReq(bo *tikv.Backoffer, req *tikvrpc.Request, regionID tikv.RegionVerID, timeout time.Duration) (*tikvrpc.Response, error) GetLockResolver() *txnlock.LockResolver GetSafePointKV() tikv.SafePointKV UpdateSPCache(cachedSP uint64, cachedTime time.Time) SetOracle(oracle oracle.Oracle) SetTiKVClient(client tikv.Client) GetTiKVClient() tikv.Client Closed() <-chan struct{} GetMinSafeTS(txnScope string) uint64 GetLockWaits() ([]*deadlockpb.WaitForEntry, error) GetCodec() tikv.Codec }
Storage represents a storage that connects TiKV. Methods copied from kv.Storage and tikv.Storage due to limitation of go1.13.
type StoreBaseStat ¶
type StoreBaseStat struct { ID int64 `json:"id"` Address string `json:"address"` State int64 `json:"state"` StateName string `json:"state_name"` Version string `json:"version"` Labels []StoreLabel `json:"labels"` StatusAddress string `json:"status_address"` GitHash string `json:"git_hash"` StartTimestamp int64 `json:"start_timestamp"` }
StoreBaseStat stores the basic information of one store.
type StoreDetailStat ¶
type StoreDetailStat struct { Capacity string `json:"capacity"` Available string `json:"available"` LeaderCount int64 `json:"leader_count"` LeaderWeight float64 `json:"leader_weight"` LeaderScore float64 `json:"leader_score"` LeaderSize int64 `json:"leader_size"` RegionCount int64 `json:"region_count"` RegionWeight float64 `json:"region_weight"` RegionScore float64 `json:"region_score"` RegionSize int64 `json:"region_size"` StartTs time.Time `json:"start_ts"` LastHeartbeatTs time.Time `json:"last_heartbeat_ts"` Uptime string `json:"uptime"` }
StoreDetailStat stores the detail information of one store.
type StoreHotRegionInfos ¶
type StoreHotRegionInfos struct { AsPeer map[uint64]*HotRegionsStat `json:"as_peer"` AsLeader map[uint64]*HotRegionsStat `json:"as_leader"` }
StoreHotRegionInfos records all hog region stores. it's the response of PD.
type StoreLabel ¶
StoreLabel stores the information of one store label.
type StoreStat ¶
type StoreStat struct { Store StoreBaseStat `json:"store"` Status StoreDetailStat `json:"status"` }
StoreStat stores information of one store.
type StoresStat ¶
StoresStat stores all information get from PD's api.
type TableInfo ¶
type TableInfo struct { DB *model.DBInfo Table *model.TableInfo IsPartition bool Partition *model.PartitionDefinition IsIndex bool Index *model.IndexInfo }
TableInfo stores the information of a table or an index
type TableInfoWithKeyRange ¶
TableInfoWithKeyRange stores table or index informations with its key range.
func NewIndexWithKeyRange ¶
func NewIndexWithKeyRange(db *model.DBInfo, table *model.TableInfo, index *model.IndexInfo) TableInfoWithKeyRange
NewIndexWithKeyRange constructs TableInfoWithKeyRange for given index, it is exported only for test.
func NewTableWithKeyRange ¶
func NewTableWithKeyRange(db *model.DBInfo, table *model.TableInfo) TableInfoWithKeyRange
NewTableWithKeyRange constructs TableInfoWithKeyRange for given table, it is exported only for test.