restore_util

package
v3.0.5+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SplitRetryTimes = 16

	SplitWaitMaxRetryTimes = 64
	SplitWaitInterval      = 8 * time.Millisecond
	SplitMaxWaitInterval   = time.Second

	ScatterWaitMaxRetryTimes = 128
	ScatterWaitInterval      = 50 * time.Millisecond
	ScatterMaxWaitInterval   = 5 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// GetStore gets a store by a store id.
	GetStore(ctx context.Context, storeID uint64) (*metapb.Store, error)
	// GetRegion gets a region which includes a specified key.
	GetRegion(ctx context.Context, key []byte) (*RegionInfo, error)
	// GetRegionByID gets a region by a region id.
	GetRegionByID(ctx context.Context, regionID uint64) (*RegionInfo, error)
	// SplitRegion splits a region from a key, if key is not included in the region, it will return nil.
	// note: the key should not be encoded
	SplitRegion(ctx context.Context, regionInfo *RegionInfo, key []byte) (*RegionInfo, error)
	// ScatterRegion scatters a specified region.
	ScatterRegion(ctx context.Context, regionInfo *RegionInfo) error
	// GetOperator gets the status of operator of the specified region.
	GetOperator(ctx context.Context, regionID uint64) (*pdpb.GetOperatorResponse, error)
	// ScanRegion gets a list of regions, starts from the region that contains key.
	// Limit limits the maximum number of regions returned.
	ScanRegions(ctx context.Context, key, endKey []byte, limit int) ([]*RegionInfo, error)
}

Client is a external client used by RegionSplitter.

func NewClient

func NewClient(client pd.Client) Client

NewClient returns a client used by RegionSplitter.

type Range

type Range struct {
	StartKey []byte
	EndKey   []byte
}

Range represents a range of keys.

func (*Range) Less

func (r *Range) Less(than btree.Item) bool

Less compares a range with a btree.Item

func (*Range) String

func (r *Range) String() string

String formats a range to a string

type RangeIterator

type RangeIterator func(rg *Range) bool

RangeIterator allows callers of Ascend to iterate in-order over portions of the tree. When this function returns false, iteration will stop and the associated Ascend function will immediately return.

type RangeTree

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

RangeTree stores the ranges in an orderly manner. All the ranges it stored do not overlap.

func NewRangeTree

func NewRangeTree() *RangeTree

NewRangeTree returns a new RangeTree.

func (*RangeTree) Ascend

func (rt *RangeTree) Ascend(iterator RangeIterator)

Ascend calls the iterator for every value in the tree within [first, last], until the iterator returns false.

func (*RangeTree) Find

func (rt *RangeTree) Find(key []byte) *Range

Find returns nil or a range in the range tree

func (*RangeTree) InsertRange

func (rt *RangeTree) InsertRange(rg Range) bool

InsertRanges inserts ranges into the range tree. it returns true if all ranges inserted successfully. it returns false if there are some overlapped ranges.

type RegionInfo

type RegionInfo struct {
	Region *metapb.Region
	Leader *metapb.Peer
}

RegionInfo includes a region and the leader of the region.

type RegionSplitter

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

RegionSplitter is a executor of region split by rules.

func NewRegionSplitter

func NewRegionSplitter(client Client) *RegionSplitter

NewRegionSplitter returns a new RegionSplitter.

func (*RegionSplitter) Split

func (rs *RegionSplitter) Split(ctx context.Context, ranges []Range, rewriteRules *RewriteRules) error

Split executes a region split. It will split regions by the rewrite rules, then it will split regions by the end key of each range. tableRules includes the prefix of a table, since some ranges may have a prefix with record sequence or index sequence. note: all ranges and rewrite rules must have raw key.

type RewriteRules

type RewriteRules struct {
	Table []*import_sstpb.RewriteRule
	Data  []*import_sstpb.RewriteRule
}

Jump to

Keyboard shortcuts

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