infosync

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2023 License: Apache-2.0 Imports: 51 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ServerInformationPath store server information such as IP, port and so on.
	ServerInformationPath = "/tidb/server/info"
	// ServerMinStartTSPath store the server min start timestamp.
	ServerMinStartTSPath = "/tidb/server/minstartts"
	// TiFlashTableSyncProgressPath store the tiflash table replica sync progress.
	TiFlashTableSyncProgressPath = "/tiflash/table/sync"

	// ReportInterval is interval of infoSyncerKeeper reporting min startTS.
	ReportInterval = 30 * time.Second
	// TopologyInformationPath means etcd path for storing topology info.
	TopologyInformationPath = "/topology/tidb"
	// TopologySessionTTL is ttl for topology, ant it's the ETCD session's TTL in seconds.
	TopologySessionTTL = 45
	// TopologyTimeToRefresh means time to refresh etcd.
	TopologyTimeToRefresh = 30 * time.Second
	// TopologyPrometheus means address of prometheus.
	TopologyPrometheus = "/topology/prometheus"
	// TablePrometheusCacheExpiry is the expiry time for prometheus address cache.
	TablePrometheusCacheExpiry = 10 * time.Second
	// RequestRetryInterval is the sleep time before next retry for http request
	RequestRetryInterval = 200 * time.Millisecond
	// SyncBundlesMaxRetry is the max retry times for sync placement bundles
	SyncBundlesMaxRetry = 3
)

Variables

View Source
var (
	// ErrHTTPServiceError means we got a http response with a status code which is not '2xx'
	ErrHTTPServiceError = dbterror.ClassDomain.NewStdErr(
		errno.ErrHTTPServiceError, mysql.Message("HTTP request failed with status %s", nil),
	)
)
View Source
var ErrPrometheusAddrIsNotSet = dbterror.ClassDomain.NewStd(errno.ErrPrometheusAddrIsNotSet)

ErrPrometheusAddrIsNotSet is the error that Prometheus address is not set in PD and etcd

Functions

func CalculateTiFlashProgress

func CalculateTiFlashProgress(tableID int64, replicaCount uint64, TiFlashStores map[int64]helper.StoreStat) (float64, error)

CalculateTiFlashProgress calculates TiFlash replica progress

func CheckTiKVVersion

func CheckTiKVVersion(store kv.Storage, minVersion semver.Version) error

CheckTiKVVersion is used to check the tikv version.

func CleanTiFlashProgressCache

func CleanTiFlashProgressCache()

CleanTiFlashProgressCache clean progress cache

func CloseTiFlashManager

func CloseTiFlashManager(ctx context.Context)

CloseTiFlashManager closes TiFlash manager.

func ConfigureTiFlashPDForPartitions

func ConfigureTiFlashPDForPartitions(accel bool, definitions *[]model.PartitionDefinition, count uint64, locationLabels *[]string, tableID int64) error

ConfigureTiFlashPDForPartitions configures pd rule for all partition in partitioned tables.

func ConfigureTiFlashPDForTable

func ConfigureTiFlashPDForTable(id int64, count uint64, locationLabels *[]string) error

ConfigureTiFlashPDForTable configures pd rule for unpartitioned tables.

func DeleteInternalSession

func DeleteInternalSession(se interface{})

DeleteInternalSession is the entry function for delete an internal session from SessionManager.

func DeleteTiFlashPlacementRule

func DeleteTiFlashPlacementRule(ctx context.Context, group string, ruleID string) error

DeleteTiFlashPlacementRule is to delete placement rule for certain group.

func DeleteTiFlashTableSyncProgress

func DeleteTiFlashTableSyncProgress(tableInfo *model.TableInfo) error

DeleteTiFlashTableSyncProgress is used to delete the tiflash table replica sync progress.

func GetAllLabelRules

func GetAllLabelRules(ctx context.Context) ([]*label.Rule, error)

GetAllLabelRules gets all label rules from PD.

func GetAllRuleBundles

func GetAllRuleBundles(ctx context.Context) ([]*placement.Bundle, error)

GetAllRuleBundles is used to get all rule bundles from PD. It is used to load full rules from PD while fullload infoschema.

func GetAllServerInfo

func GetAllServerInfo(ctx context.Context) (map[string]*ServerInfo, error)

GetAllServerInfo gets all servers static information from etcd.

func GetEtcdClient

func GetEtcdClient() *clientv3.Client

GetEtcdClient is only used for test.

func GetLabelRules

func GetLabelRules(ctx context.Context, ruleIDs []string) (map[string]*label.Rule, error)

GetLabelRules gets the label rules according to the given IDs from PD.

func GetPDScheduleConfig

func GetPDScheduleConfig(ctx context.Context) (map[string]interface{}, error)

GetPDScheduleConfig gets the schedule information from pd

func GetPrometheusAddr

func GetPrometheusAddr() (string, error)

GetPrometheusAddr gets prometheus Address

func GetRuleBundle

func GetRuleBundle(ctx context.Context, name string) (*placement.Bundle, error)

GetRuleBundle is used to get one specific rule bundle from PD.

func GetTiFlashGroupRules

func GetTiFlashGroupRules(ctx context.Context, group string) ([]placement.TiFlashRule, error)

GetTiFlashGroupRules to get all placement rule in a certain group.

func GetTiFlashProgressFromCache

func GetTiFlashProgressFromCache(tableID int64) (float64, bool)

GetTiFlashProgressFromCache gets tiflash replica progress from tiflashProgressCache

func GetTiFlashRegionCountFromPD

func GetTiFlashRegionCountFromPD(ctx context.Context, tableID int64, regionCount *int) error

GetTiFlashRegionCountFromPD is a helper function calling `/stats/region`.

func GetTiFlashStoresStat

func GetTiFlashStoresStat(ctx context.Context) (*helper.StoresStat, error)

GetTiFlashStoresStat gets the TiKV store information by accessing PD's api.

func MakeNewRule

func MakeNewRule(ID int64, Count uint64, LocationLabels []string) *placement.TiFlashRule

MakeNewRule creates a pd rule for TiFlash.

func MustGetTiFlashProgress

func MustGetTiFlashProgress(tableID int64, replicaCount uint64, tiFlashStores *map[int64]helper.StoreStat) (float64, error)

MustGetTiFlashProgress gets tiflash replica progress from tiflashProgressCache, if cache not exist, it calculates progress from PD and TiFlash and inserts progress into cache.

func PostTiFlashAccelerateSchedule

func PostTiFlashAccelerateSchedule(ctx context.Context, tableID int64) error

PostTiFlashAccelerateSchedule sends `regions/accelerate-schedule` request.

func PutLabelRule

func PutLabelRule(ctx context.Context, rule *label.Rule) error

PutLabelRule synchronizes the label rule to PD.

func PutRuleBundles

func PutRuleBundles(ctx context.Context, bundles []*placement.Bundle) error

PutRuleBundles is used to post specific rule bundles to PD.

func PutRuleBundlesWithDefaultRetry

func PutRuleBundlesWithDefaultRetry(ctx context.Context, bundles []*placement.Bundle) (err error)

PutRuleBundlesWithDefaultRetry will retry for default times

func PutRuleBundlesWithRetry

func PutRuleBundlesWithRetry(ctx context.Context, bundles []*placement.Bundle, maxRetry int, interval time.Duration) (err error)

PutRuleBundlesWithRetry will retry for specified times when PutRuleBundles failed

func SetEtcdClient

func SetEtcdClient(etcdCli *clientv3.Client)

SetEtcdClient is only used for test.

func SetMockTiFlash

func SetMockTiFlash(tiflash *MockTiFlash)

SetMockTiFlash can only be used in tests to set MockTiFlash

func SetPDScheduleConfig

func SetPDScheduleConfig(ctx context.Context, config map[string]interface{}) error

SetPDScheduleConfig sets the schedule information for pd

func SetTiFlashGroupConfig

func SetTiFlashGroupConfig(ctx context.Context) error

SetTiFlashGroupConfig is a helper function to set tiflash rule group config

func SetTiFlashPlacementRule

func SetTiFlashPlacementRule(ctx context.Context, rule placement.TiFlashRule) error

SetTiFlashPlacementRule is a helper function to set placement rule. It is discouraged to use SetTiFlashPlacementRule directly, use `ConfigureTiFlashPDForTable`/`ConfigureTiFlashPDForPartitions` instead.

func StoreInternalSession

func StoreInternalSession(se interface{})

StoreInternalSession is the entry function for store an internal session to SessionManager.

func UpdateLabelRules

func UpdateLabelRules(ctx context.Context, patch *label.RulePatch) error

UpdateLabelRules synchronizes the label rule to PD.

func UpdateTiFlashProgressCache

func UpdateTiFlashProgressCache(tableID int64, progress float64) error

UpdateTiFlashProgressCache updates tiflashProgressCache

Types

type InfoSyncer

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

InfoSyncer stores server info to etcd when the tidb-server starts and delete when tidb-server shuts down.

func GlobalInfoSyncerInit

func GlobalInfoSyncerInit(ctx context.Context, id string, serverIDGetter func() uint64, etcdCli *clientv3.Client, skipRegisterToDashBoard bool) (*InfoSyncer, error)

GlobalInfoSyncerInit return a new InfoSyncer. It is exported for testing.

func (*InfoSyncer) Done

func (is *InfoSyncer) Done() <-chan struct{}

Done returns a channel that closes when the info syncer is no longer being refreshed.

func (*InfoSyncer) GetAllTiDBTopology

func (is *InfoSyncer) GetAllTiDBTopology(ctx context.Context) ([]*TopologyInfo, error)

GetAllTiDBTopology gets all tidb topology

func (*InfoSyncer) GetMinStartTS

func (is *InfoSyncer) GetMinStartTS() uint64

GetMinStartTS get min start timestamp. Export for testing.

func (*InfoSyncer) GetSessionManager

func (is *InfoSyncer) GetSessionManager() util2.SessionManager

GetSessionManager get the session manager.

func (*InfoSyncer) RemoveMinStartTS

func (is *InfoSyncer) RemoveMinStartTS()

RemoveMinStartTS removes self server min start timestamp from etcd.

func (*InfoSyncer) RemoveServerInfo

func (is *InfoSyncer) RemoveServerInfo()

RemoveServerInfo remove self server static information from etcd.

func (*InfoSyncer) ReportMinStartTS

func (is *InfoSyncer) ReportMinStartTS(store kv.Storage)

ReportMinStartTS reports self server min start timestamp to ETCD.

func (*InfoSyncer) Restart

func (is *InfoSyncer) Restart(ctx context.Context) error

Restart restart the info syncer with new session leaseID and store server info to etcd again.

func (*InfoSyncer) RestartTopology

func (is *InfoSyncer) RestartTopology(ctx context.Context) error

RestartTopology restart the topology syncer with new session leaseID and store server info to etcd again.

func (*InfoSyncer) SetSessionManager

func (is *InfoSyncer) SetSessionManager(manager util2.SessionManager)

SetSessionManager set the session manager for InfoSyncer.

func (*InfoSyncer) StoreServerInfo

func (is *InfoSyncer) StoreServerInfo(ctx context.Context) error

StoreServerInfo stores self server static information to etcd.

func (*InfoSyncer) StoreTopologyInfo

func (is *InfoSyncer) StoreTopologyInfo(ctx context.Context) error

StoreTopologyInfo stores the topology of tidb to etcd.

func (*InfoSyncer) TopologyDone

func (is *InfoSyncer) TopologyDone() <-chan struct{}

TopologyDone returns a channel that closes when the topology syncer is no longer being refreshed.

type LabelRuleManager

type LabelRuleManager interface {
	PutLabelRule(ctx context.Context, rule *label.Rule) error
	UpdateLabelRules(ctx context.Context, patch *label.RulePatch) error
	GetAllLabelRules(ctx context.Context) ([]*label.Rule, error)
	GetLabelRules(ctx context.Context, ruleIDs []string) (map[string]*label.Rule, error)
}

LabelRuleManager manages label rules

type MockTiFlash

type MockTiFlash struct {
	sync.Mutex

	StatusAddr                  string
	StatusServer                *httptest.Server
	SyncStatus                  map[int]mockTiFlashTableInfo
	StoreInfo                   map[uint64]helper.StoreBaseStat
	GlobalTiFlashPlacementRules map[string]placement.TiFlashRule
	PdEnabled                   bool
	TiflashDelay                time.Duration
	StartTime                   time.Time
	NotAvailable                bool
	// contains filtered or unexported fields
}

MockTiFlash mocks a TiFlash, with necessary Pd support.

func GetMockTiFlash

func GetMockTiFlash() *MockTiFlash

GetMockTiFlash can only be used in tests to get MockTiFlash

func NewMockTiFlash

func NewMockTiFlash() *MockTiFlash

NewMockTiFlash creates a MockTiFlash with a mocked TiFlash server.

func (*MockTiFlash) AddStore

func (tiflash *MockTiFlash) AddStore(storeID uint64, address string)

AddStore is mock function for adding store info into MockTiFlash.

func (*MockTiFlash) CheckPlacementRule

func (tiflash *MockTiFlash) CheckPlacementRule(rule placement.TiFlashRule) bool

CheckPlacementRule find if a given rule precisely matches already set rules.

func (*MockTiFlash) CleanPlacementRules

func (tiflash *MockTiFlash) CleanPlacementRules()

CleanPlacementRules cleans all placement rules.

func (*MockTiFlash) GetPlacementRule

func (tiflash *MockTiFlash) GetPlacementRule(ruleName string) (*placement.TiFlashRule, bool)

GetPlacementRule find a rule by name.

func (*MockTiFlash) GetRuleGroupIndex

func (tiflash *MockTiFlash) GetRuleGroupIndex() int

GetRuleGroupIndex gets the group index of tiflash

func (*MockTiFlash) GetTableSyncStatus

func (tiflash *MockTiFlash) GetTableSyncStatus(tableID int) (*mockTiFlashTableInfo, bool)

GetTableSyncStatus returns table sync status by given tableID.

func (*MockTiFlash) HandleDeletePlacementRule

func (tiflash *MockTiFlash) HandleDeletePlacementRule(group string, ruleID string)

HandleDeletePlacementRule is mock function for DeleteTiFlashPlacementRule.

func (*MockTiFlash) HandleGetGroupRules

func (tiflash *MockTiFlash) HandleGetGroupRules(group string) ([]placement.TiFlashRule, error)

HandleGetGroupRules is mock function for GetTiFlashGroupRules.

func (*MockTiFlash) HandleGetPDRegionRecordStats

func (tiflash *MockTiFlash) HandleGetPDRegionRecordStats(_ int64) helper.PDRegionStats

HandleGetPDRegionRecordStats is mock function for GetRegionCountFromPD. It currently always returns 1 Region for convenience.

func (*MockTiFlash) HandleGetStoresStat

func (tiflash *MockTiFlash) HandleGetStoresStat() *helper.StoresStat

HandleGetStoresStat is mock function for GetStoresStat. It returns address of our mocked TiFlash server.

func (*MockTiFlash) HandlePostAccelerateSchedule

func (tiflash *MockTiFlash) HandlePostAccelerateSchedule(endKey string) error

HandlePostAccelerateSchedule is mock function for PostAccelerateSchedule

func (*MockTiFlash) HandleSetPlacementRule

func (tiflash *MockTiFlash) HandleSetPlacementRule(rule placement.TiFlashRule) error

HandleSetPlacementRule is mock function for SetTiFlashPlacementRule.

func (*MockTiFlash) HandleSetPlacementRuleBatch

func (tiflash *MockTiFlash) HandleSetPlacementRuleBatch(rules []*placement.TiFlashRule) error

HandleSetPlacementRuleBatch is mock function for batch SetTiFlashPlacementRule.

func (*MockTiFlash) PdSwitch

func (tiflash *MockTiFlash) PdSwitch(enabled bool)

PdSwitch controls if pd is enabled.

func (*MockTiFlash) PlacementRulesLen

func (tiflash *MockTiFlash) PlacementRulesLen() int

PlacementRulesLen gets length of all currently set placement rules.

func (*MockTiFlash) ResetSyncStatus

func (tiflash *MockTiFlash) ResetSyncStatus(tableID int, canAvailable bool)

ResetSyncStatus is mock function for reset sync status.

func (*MockTiFlash) SetRuleGroupIndex

func (tiflash *MockTiFlash) SetRuleGroupIndex(groupIndex int)

SetRuleGroupIndex sets the group index of tiflash

type MockTiFlashError

type MockTiFlashError struct {
	Message string
}

MockTiFlashError represents MockTiFlash error

func (*MockTiFlashError) Error

func (me *MockTiFlashError) Error() string

type PDLabelManager

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

PDLabelManager manages rules with pd

func (*PDLabelManager) GetAllLabelRules

func (lm *PDLabelManager) GetAllLabelRules(ctx context.Context) ([]*label.Rule, error)

GetAllLabelRules implements GetAllLabelRules

func (*PDLabelManager) GetLabelRules

func (lm *PDLabelManager) GetLabelRules(ctx context.Context, ruleIDs []string) (map[string]*label.Rule, error)

GetLabelRules implements GetLabelRules

func (*PDLabelManager) PutLabelRule

func (lm *PDLabelManager) PutLabelRule(ctx context.Context, rule *label.Rule) error

PutLabelRule implements PutLabelRule

func (*PDLabelManager) UpdateLabelRules

func (lm *PDLabelManager) UpdateLabelRules(ctx context.Context, patch *label.RulePatch) error

UpdateLabelRules implements UpdateLabelRules

type PDPlacementManager

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

PDPlacementManager manages placement with pd

func (*PDPlacementManager) GetAllRuleBundles

func (m *PDPlacementManager) GetAllRuleBundles(ctx context.Context) ([]*placement.Bundle, error)

GetAllRuleBundles is used to get all rule bundles from PD. It is used to load full rules from PD while fullload infoschema.

func (*PDPlacementManager) GetRuleBundle

func (m *PDPlacementManager) GetRuleBundle(ctx context.Context, name string) (*placement.Bundle, error)

GetRuleBundle is used to get one specific rule bundle from PD.

func (*PDPlacementManager) PutRuleBundles

func (m *PDPlacementManager) PutRuleBundles(ctx context.Context, bundles []*placement.Bundle) error

PutRuleBundles is used to post specific rule bundles to PD.

type PDScheduleManager

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

PDScheduleManager manages schedule with pd

func (*PDScheduleManager) GetPDScheduleConfig

func (sm *PDScheduleManager) GetPDScheduleConfig(ctx context.Context) (map[string]interface{}, error)

GetPDScheduleConfig get schedule config from pd

func (*PDScheduleManager) SetPDScheduleConfig

func (sm *PDScheduleManager) SetPDScheduleConfig(ctx context.Context, config map[string]interface{}) error

SetPDScheduleConfig set schedule config to pd

type PlacementManager

type PlacementManager interface {
	// GetRuleBundle is used to get one specific rule bundle from PD.
	GetRuleBundle(ctx context.Context, name string) (*placement.Bundle, error)
	// GetAllRuleBundles is used to get all rule bundles from PD. It is used to load full rules from PD while fullload infoschema.
	GetAllRuleBundles(ctx context.Context) ([]*placement.Bundle, error)
	// PutRuleBundles is used to post specific rule bundles to PD.
	PutRuleBundles(ctx context.Context, bundles []*placement.Bundle) error
}

PlacementManager manages placement settings

type PlacementScheduleState

type PlacementScheduleState int

PlacementScheduleState is the returned third-valued state from GetReplicationState(). For convenience, the string of PD is deserialized into an enum first.

const (
	// PlacementScheduleStatePending corresponds to "PENDING" from PD.
	PlacementScheduleStatePending PlacementScheduleState = iota
	// PlacementScheduleStateInProgress corresponds to "INPROGRESS" from PD.
	PlacementScheduleStateInProgress
	// PlacementScheduleStateScheduled corresponds to "REPLICATED" from PD.
	PlacementScheduleStateScheduled
)

func GetReplicationState

func GetReplicationState(ctx context.Context, startKey []byte, endKey []byte) (PlacementScheduleState, error)

GetReplicationState is used to check if regions in the given keyranges are replicated from PD.

func (PlacementScheduleState) String

func (t PlacementScheduleState) String() string

type RuleOp

type RuleOp struct {
	*placement.TiFlashRule            // information of the placement rule to add/delete the operation type
	Action                 RuleOpType `json:"action"`
	DeleteByIDPrefix       bool       `json:"delete_by_id_prefix"` // if action == delete, delete by the prefix of id
}

RuleOp is for batching placement rule actions. The action type is distinguished by the field `Action`.

type RuleOpType

type RuleOpType string

RuleOpType indicates the operation type

const (
	// RuleOpAdd a placement rule, only need to specify the field *Rule
	RuleOpAdd RuleOpType = "add"
	// RuleOpDel a placement rule, only need to specify the field `GroupID`, `ID`, `MatchID`
	RuleOpDel RuleOpType = "del"
)

type ScheduleManager

type ScheduleManager interface {
	GetPDScheduleConfig(ctx context.Context) (map[string]interface{}, error)
	SetPDScheduleConfig(ctx context.Context, config map[string]interface{}) error
}

ScheduleManager manages schedule configs

type ServerInfo

type ServerInfo struct {
	ServerVersionInfo
	ID             string            `json:"ddl_id"`
	IP             string            `json:"ip"`
	Port           uint              `json:"listening_port"`
	StatusPort     uint              `json:"status_port"`
	Lease          string            `json:"lease"`
	BinlogStatus   string            `json:"binlog_status"`
	StartTimestamp int64             `json:"start_timestamp"`
	Labels         map[string]string `json:"labels"`
	// ServerID is a function, to always retrieve latest serverID from `Domain`,
	//   which will be changed on occasions such as connection to PD is restored after broken.
	ServerIDGetter func() uint64 `json:"-"`

	// JSONServerID is `serverID` for json marshal/unmarshal ONLY.
	JSONServerID uint64 `json:"server_id"`
}

ServerInfo is server static information. It will not be updated when tidb-server running. So please only put static information in ServerInfo struct.

func GetServerInfo

func GetServerInfo() (*ServerInfo, error)

GetServerInfo gets self server static information.

func GetServerInfoByID

func GetServerInfoByID(ctx context.Context, id string) (*ServerInfo, error)

GetServerInfoByID gets specified server static information from etcd.

func (*ServerInfo) Marshal

func (info *ServerInfo) Marshal() ([]byte, error)

Marshal `ServerInfo` into bytes.

func (*ServerInfo) Unmarshal

func (info *ServerInfo) Unmarshal(v []byte) error

Unmarshal `ServerInfo` from bytes.

type ServerVersionInfo

type ServerVersionInfo struct {
	Version string `json:"version"`
	GitHash string `json:"git_hash"`
}

ServerVersionInfo is the server version and git_hash.

type TiFlashReplicaManager

type TiFlashReplicaManager interface {
	// SetTiFlashGroupConfig sets the group index of the tiflash placement rule
	SetTiFlashGroupConfig(ctx context.Context) error
	// SetPlacementRule is a helper function to set placement rule.
	SetPlacementRule(ctx context.Context, rule placement.TiFlashRule) error
	// SetPlacementRuleBatch is a helper function to set a batch of placement rules.
	SetPlacementRuleBatch(ctx context.Context, rules []*placement.TiFlashRule) error
	// DeletePlacementRule is to delete placement rule for certain group.
	DeletePlacementRule(ctx context.Context, group string, ruleID string) error
	// GetGroupRules to get all placement rule in a certain group.
	GetGroupRules(ctx context.Context, group string) ([]placement.TiFlashRule, error)
	// PostAccelerateSchedule sends `regions/accelerate-schedule` request.
	PostAccelerateSchedule(ctx context.Context, tableID int64) error
	// PostAccelerateScheduleBatch sends `regions/accelerate-schedule/batch` request.
	PostAccelerateScheduleBatch(ctx context.Context, tableIDs []int64) error
	// GetRegionCountFromPD is a helper function calling `/stats/region`.
	GetRegionCountFromPD(ctx context.Context, tableID int64, regionCount *int) error
	// GetStoresStat gets the TiKV store information by accessing PD's api.
	GetStoresStat(ctx context.Context) (*helper.StoresStat, error)
	// CalculateTiFlashProgress calculates TiFlash replica progress
	CalculateTiFlashProgress(tableID int64, replicaCount uint64, TiFlashStores map[int64]helper.StoreStat) (float64, error)
	// UpdateTiFlashProgressCache updates tiflashProgressCache
	UpdateTiFlashProgressCache(tableID int64, progress float64)
	// GetTiFlashProgressFromCache gets tiflash replica progress from tiflashProgressCache
	GetTiFlashProgressFromCache(tableID int64) (float64, bool)
	// DeleteTiFlashProgressFromCache delete tiflash replica progress from tiflashProgressCache
	DeleteTiFlashProgressFromCache(tableID int64)
	// CleanTiFlashProgressCache clean progress cache
	CleanTiFlashProgressCache()
	// Close is to close TiFlashReplicaManager
	Close(ctx context.Context)
}

TiFlashReplicaManager manages placement settings and replica progress for TiFlash.

type TiFlashReplicaManagerCtx

type TiFlashReplicaManagerCtx struct {
	sync.RWMutex // protect tiflashProgressCache
	// contains filtered or unexported fields
}

TiFlashReplicaManagerCtx manages placement with pd and replica progress for TiFlash.

func (*TiFlashReplicaManagerCtx) CalculateTiFlashProgress

func (m *TiFlashReplicaManagerCtx) CalculateTiFlashProgress(tableID int64, replicaCount uint64, tiFlashStores map[int64]helper.StoreStat) (float64, error)

CalculateTiFlashProgress calculates TiFlash replica progress.

func (*TiFlashReplicaManagerCtx) CleanTiFlashProgressCache

func (m *TiFlashReplicaManagerCtx) CleanTiFlashProgressCache()

CleanTiFlashProgressCache clean progress cache

func (*TiFlashReplicaManagerCtx) Close

Close is called to close TiFlashReplicaManagerCtx.

func (*TiFlashReplicaManagerCtx) DeletePlacementRule

func (m *TiFlashReplicaManagerCtx) DeletePlacementRule(ctx context.Context, group string, ruleID string) error

DeletePlacementRule is to delete placement rule for certain group.

func (*TiFlashReplicaManagerCtx) DeleteTiFlashProgressFromCache

func (m *TiFlashReplicaManagerCtx) DeleteTiFlashProgressFromCache(tableID int64)

DeleteTiFlashProgressFromCache delete tiflash replica progress from tiflashProgressCache

func (*TiFlashReplicaManagerCtx) GetGroupRules

func (m *TiFlashReplicaManagerCtx) GetGroupRules(ctx context.Context, group string) ([]placement.TiFlashRule, error)

GetGroupRules to get all placement rule in a certain group.

func (*TiFlashReplicaManagerCtx) GetRegionCountFromPD

func (m *TiFlashReplicaManagerCtx) GetRegionCountFromPD(ctx context.Context, tableID int64, regionCount *int) error

GetRegionCountFromPD is a helper function calling `/stats/region`.

func (*TiFlashReplicaManagerCtx) GetStoresStat

func (m *TiFlashReplicaManagerCtx) GetStoresStat(ctx context.Context) (*helper.StoresStat, error)

GetStoresStat gets the TiKV store information by accessing PD's api.

func (*TiFlashReplicaManagerCtx) GetTiFlashProgressFromCache

func (m *TiFlashReplicaManagerCtx) GetTiFlashProgressFromCache(tableID int64) (float64, bool)

GetTiFlashProgressFromCache gets tiflash replica progress from tiflashProgressCache

func (*TiFlashReplicaManagerCtx) PostAccelerateSchedule

func (m *TiFlashReplicaManagerCtx) PostAccelerateSchedule(ctx context.Context, tableID int64) error

PostAccelerateSchedule sends `regions/accelerate-schedule` request.

func (*TiFlashReplicaManagerCtx) PostAccelerateScheduleBatch

func (m *TiFlashReplicaManagerCtx) PostAccelerateScheduleBatch(ctx context.Context, tableIDs []int64) error

PostAccelerateScheduleBatch sends `regions/batch-accelerate-schedule` request.

func (*TiFlashReplicaManagerCtx) SetPlacementRule

func (m *TiFlashReplicaManagerCtx) SetPlacementRule(ctx context.Context, rule placement.TiFlashRule) error

SetPlacementRule is a helper function to set placement rule.

func (*TiFlashReplicaManagerCtx) SetPlacementRuleBatch

func (m *TiFlashReplicaManagerCtx) SetPlacementRuleBatch(ctx context.Context, rules []*placement.TiFlashRule) error

SetPlacementRuleBatch is a helper function to set a batch of placement rules.

func (*TiFlashReplicaManagerCtx) SetTiFlashGroupConfig

func (m *TiFlashReplicaManagerCtx) SetTiFlashGroupConfig(ctx context.Context) error

SetTiFlashGroupConfig sets the tiflash's rule group config

func (*TiFlashReplicaManagerCtx) UpdateTiFlashProgressCache

func (m *TiFlashReplicaManagerCtx) UpdateTiFlashProgressCache(tableID int64, progress float64)

UpdateTiFlashProgressCache updates tiflashProgressCache

type TopologyInfo

type TopologyInfo struct {
	ServerVersionInfo
	IP             string            `json:"ip"`
	StatusPort     uint              `json:"status_port"`
	DeployPath     string            `json:"deploy_path"`
	StartTimestamp int64             `json:"start_timestamp"`
	Labels         map[string]string `json:"labels"`
}

TopologyInfo is the topology info

Jump to

Keyboard shortcuts

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