pdutil

package
v0.0.0-...-503c688 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: Apache-2.0, Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// Schedulers represent region/leader schedulers which can impact on performance.
	Schedulers = map[string]struct{}{
		"balance-leader-scheduler":     {},
		"balance-hot-region-scheduler": {},
		"balance-region-scheduler":     {},

		"shuffle-leader-scheduler":     {},
		"shuffle-region-scheduler":     {},
		"shuffle-hot-region-scheduler": {},
	}
)

Functions

func DefaultExpectPDCfgGenerators

func DefaultExpectPDCfgGenerators() map[string]pauseConfigGenerator

DefaultExpectPDCfgGenerators returns default pd config generators

func FetchPDVersion

func FetchPDVersion(ctx context.Context, tls *common.TLS, pdAddr string) (*semver.Version, error)

FetchPDVersion get pd version

func GetPlacementRules

func GetPlacementRules(ctx context.Context, pdAddr string, tlsConf *tls.Config) ([]pdtypes.Rule, error)

GetPlacementRules return the current placement rules.

func SearchPlacementRule

func SearchPlacementRule(tableID int64, placementRules []pdtypes.Rule, role pdtypes.PeerRoleType) *pdtypes.Rule

SearchPlacementRule returns the placement rule matched to the table or nil.

Types

type ClusterConfig

type ClusterConfig struct {
	// Enable PD schedulers before restore
	Schedulers []string `json:"schedulers"`
	// Original scheudle configuration
	ScheduleCfg map[string]interface{} `json:"schedule_cfg"`
}

ClusterConfig represents a set of scheduler whose config have been modified along with their original config.

type KeyRangeRule

type KeyRangeRule struct {
	StartKeyHex string `json:"start_key"` // hex format start key, for marshal/unmarshal
	EndKeyHex   string `json:"end_key"`   // hex format end key, for marshal/unmarshal
}

KeyRangeRule contains the start key and end key of the LabelRule. This struct is partially copied from https://github.com/tikv/pd/blob/783d060861cef37c38cbdcab9777fe95c17907fe/server/schedule/labeler/rules.go#L62.

type LabelRule

type LabelRule struct {
	ID       string        `json:"id"`
	Labels   []RegionLabel `json:"labels"`
	RuleType string        `json:"rule_type"`
	Data     interface{}   `json:"data"`
}

LabelRule is the rule to assign labels to a region. This struct is partially copied from https://github.com/tikv/pd/blob/783d060861cef37c38cbdcab9777fe95c17907fe/server/schedule/labeler/rules.go#L41.

type PdController

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

PdController manage get/update config from pd.

func NewPdController

func NewPdController(
	ctx context.Context,
	pdAddrs string,
	tlsConf *tls.Config,
	securityOption pd.SecurityOption,
) (*PdController, error)

NewPdController creates a new PdController.

func (*PdController) CanPauseSchedulerByKeyRange

func (p *PdController) CanPauseSchedulerByKeyRange() bool

CanPauseSchedulerByKeyRange returns whether the scheduler can be paused by key range.

func (*PdController) Close

func (p *PdController) Close()

Close close the connection to pd.

func (*PdController) CreateOrUpdateRegionLabelRule

func (p *PdController) CreateOrUpdateRegionLabelRule(ctx context.Context, rule LabelRule) error

CreateOrUpdateRegionLabelRule creates or updates a region label rule.

func (*PdController) DeleteRegionLabelRule

func (p *PdController) DeleteRegionLabelRule(ctx context.Context, ruleID string) error

DeleteRegionLabelRule deletes a region label rule.

func (*PdController) GenRestoreSchedulerFunc

func (p *PdController) GenRestoreSchedulerFunc(config ClusterConfig,
	configsNeedRestore map[string]pauseConfigGenerator) UndoFunc

GenRestoreSchedulerFunc gen restore func

func (*PdController) GetClusterVersion

func (p *PdController) GetClusterVersion(ctx context.Context) (string, error)

GetClusterVersion returns the current cluster version.

func (*PdController) GetMinResolvedTS

func (p *PdController) GetMinResolvedTS(ctx context.Context) (uint64, error)

GetMinResolvedTS get min-resolved-ts from pd

func (*PdController) GetPDClient

func (p *PdController) GetPDClient() pd.Client

GetPDClient set pd addrs and cli for test.

func (*PdController) GetPDScheduleConfig

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

GetPDScheduleConfig returns PD schedule config value associated with the key. It returns nil if there is no such config item.

func (*PdController) GetRegionCount

func (p *PdController) GetRegionCount(ctx context.Context, startKey, endKey []byte) (int, error)

GetRegionCount returns the region count in the specified range.

func (*PdController) GetStoreInfo

func (p *PdController) GetStoreInfo(ctx context.Context, storeID uint64) (*pdtypes.StoreInfo, error)

GetStoreInfo returns the info of store with the specified id.

func (*PdController) ListSchedulers

func (p *PdController) ListSchedulers(ctx context.Context) ([]string, error)

ListSchedulers list all pd scheduler.

func (*PdController) MakeUndoFunctionByConfig

func (p *PdController) MakeUndoFunctionByConfig(config ClusterConfig) UndoFunc

MakeUndoFunctionByConfig return an UndoFunc based on specified ClusterConfig

func (*PdController) MarkRecovering

func (p *PdController) MarkRecovering(ctx context.Context) error

MarkRecovering mark pd into recovering

func (*PdController) PauseSchedulersByKeyRange

func (p *PdController) PauseSchedulersByKeyRange(ctx context.Context,
	startKey, endKey []byte) (done <-chan struct{}, err error)

PauseSchedulersByKeyRange will pause schedulers for regions in the specific key range. This function will spawn a goroutine to keep pausing schedulers periodically until the context is done. The return done channel is used to notify the caller that the background goroutine is exited.

func (*PdController) RecoverBaseAllocID

func (p *PdController) RecoverBaseAllocID(ctx context.Context, id uint64) error

RecoverBaseAllocID recover base alloc id

func (*PdController) RemoveAllPDSchedulers

func (p *PdController) RemoveAllPDSchedulers(ctx context.Context) (undo UndoFunc, err error)

RemoveAllPDSchedulers pause pd scheduler during the snapshot backup and restore

func (*PdController) RemoveSchedulers

func (p *PdController) RemoveSchedulers(ctx context.Context) (undo UndoFunc, err error)

RemoveSchedulers removes the schedulers that may slow down BR speed.

func (*PdController) RemoveSchedulersWithCfg

func (p *PdController) RemoveSchedulersWithCfg(ctx context.Context, removeCfg ClusterConfig) error

RemoveSchedulersWithCfg removes pd schedulers and configs with specified ClusterConfig

func (*PdController) RemoveSchedulersWithConfig

func (p *PdController) RemoveSchedulersWithConfig(
	ctx context.Context,
) (undo UndoFunc, config *ClusterConfig, err error)

RemoveSchedulersWithConfig removes the schedulers that may slow down BR speed.

func (*PdController) RemoveSchedulersWithConfigGenerator

func (p *PdController) RemoveSchedulersWithConfigGenerator(ctx context.Context,
	pdConfigGenerators map[string]pauseConfigGenerator) (
	origin ClusterConfig, modified ClusterConfig, err error)

RemoveSchedulersWithConfigGenerator pause scheduler with custom config generator

func (*PdController) RemoveSchedulersWithOrigin

func (p *PdController) RemoveSchedulersWithOrigin(ctx context.Context) (origin ClusterConfig,
	modified ClusterConfig, err error)

RemoveSchedulersWithOrigin pause and remove br related schedule configs and return the origin and modified configs

func (*PdController) ResetTS

func (p *PdController) ResetTS(ctx context.Context, ts uint64) error

ResetTS reset current ts of pd

func (*PdController) ResumeSchedulers

func (p *PdController) ResumeSchedulers(ctx context.Context, schedulers []string) error

ResumeSchedulers resume pd scheduler.

func (*PdController) SetHTTP

func (p *PdController) SetHTTP(addrs []string, cli *http.Client)

SetHTTP set pd addrs and cli for test.

func (*PdController) SetPDClient

func (p *PdController) SetPDClient(pdClient pd.Client)

SetPDClient set pd addrs and cli for test.

func (*PdController) UnmarkRecovering

func (p *PdController) UnmarkRecovering(ctx context.Context) error

UnmarkRecovering unmark pd recovering

func (*PdController) UpdatePDScheduleConfig

func (p *PdController) UpdatePDScheduleConfig(ctx context.Context) error

UpdatePDScheduleConfig updates PD schedule config value associated with the key.

type RegionLabel

type RegionLabel struct {
	Key     string `json:"key"`
	Value   string `json:"value"`
	TTL     string `json:"ttl,omitempty"`
	StartAt string `json:"start_at,omitempty"`
}

RegionLabel is the label of a region. This struct is partially copied from https://github.com/tikv/pd/blob/783d060861cef37c38cbdcab9777fe95c17907fe/server/schedule/labeler/rules.go#L31.

type UndoFunc

type UndoFunc func(context.Context) error

UndoFunc is a 'undo' operation of some undoable command. (e.g. RemoveSchedulers).

var Nop UndoFunc = func(context.Context) error { return nil }

Nop is the 'zero value' of undo func.

Jump to

Keyboard shortcuts

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