handle

package
v1.1.0-beta.0...-76cbd72 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2026 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NextGenTargetScope is the target scope for new tasks in nextgen kernel.
	// on nextgen, DXF works as a service and runs only on node with scope 'dxf_service',
	// so all tasks must be submitted to that scope.
	NextGenTargetScope = "dxf_service"
)

Variables

View Source
var (

	// TaskChangedCh used to speed up task schedule, such as when task is submitted
	// in the same node as the scheduler manager.
	// put it here to avoid cyclic import.
	TaskChangedCh = make(chan struct{}, 1)
)

Functions

func CalculateRequiredNodes

func CalculateRequiredNodes(tasks []*proto.TaskBase, cpuCount int) int

CalculateRequiredNodes simulates how scheduler and balancer schedules tasks, and calculates the required node count to run the tasks. 'tasks' must be ordered by its rank, see TaskBase for more info about task rank.

func CancelTask

func CancelTask(ctx context.Context, taskKey string) error

CancelTask cancels a task.

func GetBusyNodes

func GetBusyNodes(ctx context.Context, manager *storage.TaskManager) ([]schstatus.Node, error)

GetBusyNodes get nodes that are currently running subtasks, or is the DXF owner as we don't want owner node floating around. exported for test.

func GetCPUCountOfNode

func GetCPUCountOfNode(ctx context.Context) (int, error)

GetCPUCountOfNode gets the CPU count of the managed node.

func GetCloudStorageURI

func GetCloudStorageURI(ctx context.Context, store kv.Storage) string

GetCloudStorageURI returns the cloud storage URI with cluster ID appended to the path.

func GetDefaultRegionSplitConfig

func GetDefaultRegionSplitConfig() (splitSize, splitKeys int64)

GetDefaultRegionSplitConfig gets the default region split size and keys.

func GetNodeResource

func GetNodeResource() *proto.NodeResource

GetNodeResource gets the node resource.

func GetNodesInfo

func GetNodesInfo(ctx context.Context, manager *storage.TaskManager) (nodeCount int, cpuCount int, err error)

GetNodesInfo retrieves the number of managed nodes and their CPU count. exported for test.

func GetScheduleFlags

func GetScheduleFlags(ctx context.Context, manager *storage.TaskManager) (map[schstatus.Flag]schstatus.TTLFlag, error)

GetScheduleFlags returns the schedule flags, such as pause-scale-in flag. exported for test.

func GetScheduleStatus

func GetScheduleStatus(ctx context.Context) (*schstatus.Status, error)

GetScheduleStatus returns the schedule status.

func GetScheduleTuneFactors

func GetScheduleTuneFactors(ctx context.Context, keyspace string) (*schstatus.TuneFactors, error)

GetScheduleTuneFactors gets the schedule tune factors for a keyspace. if not set or expired, it returns the default tune factors.

func GetTargetScope

func GetTargetScope() string

GetTargetScope get target scope for new tasks. in classical kernel, the target scope the new task is the service scope of the TiDB instance that user is currently connecting to. in nextgen kernel, it's always NextGenTargetScope.

func NewObjStore

func NewObjStore(ctx context.Context, uri string) (extstorage.ExternalStorage, error)

NewObjStore creates an object storage for global sort.

func NewObjStoreWithRecording

func NewObjStoreWithRecording(ctx context.Context, uri string) (*recording.AccessStats, extstorage.ExternalStorage, error)

NewObjStoreWithRecording creates an object storage for global sort with request recording.

func NotifyTaskChange

func NotifyTaskChange()

NotifyTaskChange is used to notify the scheduler manager that the task is changed, either a new task is submitted or a task is finished.

func PauseTask

func PauseTask(ctx context.Context, taskKey string) error

PauseTask pauses a task.

func ResumeTask

func ResumeTask(ctx context.Context, taskKey string) error

ResumeTask resumes a task.

func RunWithRetry

func RunWithRetry(
	ctx context.Context,
	maxRetry int,
	backoffer backoff.Backoffer,
	logger *zap.Logger,
	f func(context.Context) (bool, error),
) error

RunWithRetry runs a function with retry, when retry exceed max retry time, it returns the last error met. if the function fails with err, it should return a bool to indicate whether the error is retryable. if context done, it will stop early and return ctx.Err().

func SendRowAndSizeMeterData

func SendRowAndSizeMeterData(ctx context.Context, task *proto.Task, rows int64,
	dataKVSize, indexKVSize int64, logger *zap.Logger) (err error)

SendRowAndSizeMeterData sends the row count and size metering data.

func SetNodeResource

func SetNodeResource(rc *proto.NodeResource)

SetNodeResource gets the node resource.

func SubmitTask

func SubmitTask(ctx context.Context, taskKey string, taskType proto.TaskType, keyspace string, requiredSlots int, targetScope string, maxNodeCnt int, taskMeta []byte) (*proto.Task, error)

SubmitTask submits a task.

func UpdatePauseScaleInFlag

func UpdatePauseScaleInFlag(ctx context.Context, flag *schstatus.TTLFlag) error

UpdatePauseScaleInFlag updates the pause scale-in flag.

func WaitTask

func WaitTask(ctx context.Context, id int64, matchFn func(base *proto.TaskBase) bool) (*proto.TaskBase, error)

WaitTask waits for a task until it meets the matchFn.

func WaitTaskDoneByKey

func WaitTaskDoneByKey(ctx context.Context, taskKey string) error

WaitTaskDoneByKey waits for a task done by task key.

func WaitTaskDoneOrPaused

func WaitTaskDoneOrPaused(ctx context.Context, id int64) error

WaitTaskDoneOrPaused waits for a task done or paused. this API returns error if task failed or cancelled.

Types

This section is empty.

Jump to

Keyboard shortcuts

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