Documentation ¶
Index ¶
Constants ¶
const ( SplitRetryTimes = 32 SplitRetryInterval = 50 * time.Millisecond SplitMaxRetryInterval = time.Second SplitCheckMaxRetryTimes = 64 SplitCheckInterval = 8 * time.Millisecond SplitMaxCheckInterval = time.Second ScatterWaitMaxRetryTimes = 64 ScatterWaitInterval = 50 * time.Millisecond ScatterMaxWaitInterval = time.Second ScatterWaitUpperInterval = 180 * 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) // BatchSplitRegions splits a region from a batch of keys. // note: the keys should not be encoded BatchSplitRegions(ctx context.Context, regionInfo *RegionInfo, keys [][]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) // GetPlacementRule loads a placement rule from PD. GetPlacementRule(ctx context.Context, groupID, ruleID string) (placement.Rule, error) // SetPlacementRule insert or update a placement rule to PD. SetPlacementRule(ctx context.Context, rule placement.Rule) error // DeletePlacementRule removes a placement rule from PD. DeletePlacementRule(ctx context.Context, groupID, ruleID string) error // SetStoreLabel add or update specified label of stores. If labelValue // is empty, it clears the label. SetStoresLabel(ctx context.Context, stores []uint64, labelKey, labelValue string) error }
Client is an external client used by RegionSplitter.
type Range ¶
Range represents a range of keys.
type RangeIterator ¶
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 (*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.
type RegionInfo ¶
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, onSplit OnSplitFunc, ) 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 }