rangetask

package
v3.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLocateRegionBackoffer

func NewLocateRegionBackoffer(ctx context.Context) *retry.Backoffer

NewLocateRegionBackoffer creates the backoofer for LocateRegion request.

Types

type DeleteRangeTask

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

DeleteRangeTask is used to delete all keys in a range. After performing DeleteRange, it keeps how many ranges it affects and if the task was canceled or not.

func NewDeleteRangeTask

func NewDeleteRangeTask(store storage, startKey []byte, endKey []byte, concurrency int) *DeleteRangeTask

NewDeleteRangeTask creates a DeleteRangeTask. Deleting will be performed when `Execute` method is invoked. Be careful while using this API. This API doesn't keep recent MVCC versions, but will delete all versions of all keys in the range immediately. Also notice that frequent invocation to this API may cause performance problems to TiKV.

func NewNotifyDeleteRangeTask

func NewNotifyDeleteRangeTask(store storage, startKey []byte, endKey []byte, concurrency int) *DeleteRangeTask

NewNotifyDeleteRangeTask creates a task that sends delete range requests to all regions in the range, but with the flag `notifyOnly` set. TiKV will not actually delete the range after receiving request, but it will be replicated via raft. This is used to notify the involved regions before sending UnsafeDestroyRange requests.

func (*DeleteRangeTask) CompletedRegions

func (t *DeleteRangeTask) CompletedRegions() int

CompletedRegions returns the number of regions that are affected by this delete range task

func (*DeleteRangeTask) Execute

func (t *DeleteRangeTask) Execute(ctx context.Context) error

Execute performs the delete range operation.

type Runner

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

Runner splits a range into many ranges to process concurrently, and convenient to send requests to all regions in the range. Because of merging and splitting, it's possible that multiple requests for disjoint ranges are sent to the same region.

func NewRangeTaskRunner

func NewRangeTaskRunner(
	name string,
	store storage,
	concurrency int,
	handler TaskHandler,
) *Runner

NewRangeTaskRunner creates a RangeTaskRunner.

`requestCreator` is the function used to create RPC request according to the given range. `responseHandler` is the function to process responses of errors. If `responseHandler` returns error, the whole job will be canceled.

func (*Runner) CompletedRegions

func (s *Runner) CompletedRegions() int

CompletedRegions returns how many regions has been sent requests.

func (*Runner) FailedRegions

func (s *Runner) FailedRegions() int

FailedRegions returns how many regions has failed to do the task.

func (*Runner) RunOnRange

func (s *Runner) RunOnRange(ctx context.Context, startKey, endKey []byte) error

RunOnRange runs the task on the given range. Empty startKey or endKey means unbounded.

func (*Runner) SetRegionsPerTask

func (s *Runner) SetRegionsPerTask(regionsPerTask int)

SetRegionsPerTask sets how many regions is in a divided task. Since regions may split and merge, it's possible that a sub task contains not exactly specified number of regions.

type TaskHandler

type TaskHandler = func(ctx context.Context, r kv.KeyRange) (TaskStat, error)

TaskHandler is the type of functions that processes a task of a key range. The function should calculate Regions that succeeded or failed to the task. Returning error from the handler means the error caused the whole task should be stopped.

type TaskStat

type TaskStat struct {
	CompletedRegions int
	FailedRegions    int
}

TaskStat is used to count Regions that completed or failed to do the task.

Jump to

Keyboard shortcuts

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