pdutil

package
v5.1.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2021 License: Apache-2.0 Imports: 29 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 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) ([]placement.Rule, error)

GetPlacementRules return the current placement rules.

func ResetTS

func ResetTS(ctx context.Context, pdAddr string, ts uint64, tlsConf *tls.Config) error

ResetTS resets the timestamp of PD to a bigger value.

func SearchPlacementRule

func SearchPlacementRule(tableID int64, placementRules []placement.Rule, role placement.PeerRoleType) *placement.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 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) Close

func (p *PdController) Close()

Close close the connection to pd.

func (*PdController) GetClusterVersion

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

GetClusterVersion returns the current cluster version.

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) 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) 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) RemoveSchedulersWithOrigin

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

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

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) UpdatePDScheduleConfig

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

UpdatePDScheduleConfig updates PD schedule config value associated with the key.

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