From 0975968e71b05368d5f28f788cf863c2042c2696 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Fri, 1 Aug 2025 11:18:32 -0700 Subject: admin: Refactor task destination planning (#7063) * refactor planning into task detection * refactoring worker tasks * refactor * compiles, but only balance task is registered * compiles, but has nil exception * avoid nil logger * add back ec task * setting ec log directory * implement balance and vacuum tasks * EC tasks will no longer fail with "file not found" errors * Use ReceiveFile API to send locally generated shards * distributing shard files and ecx,ecj,vif files * generate .ecx files correctly * do not mount all possible EC shards (0-13) on every destination * use constants * delete all replicas * rename files * pass in volume size to tasks --- weed/worker/tasks/erasure_coding/scheduling.go | 40 ++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 weed/worker/tasks/erasure_coding/scheduling.go (limited to 'weed/worker/tasks/erasure_coding/scheduling.go') diff --git a/weed/worker/tasks/erasure_coding/scheduling.go b/weed/worker/tasks/erasure_coding/scheduling.go new file mode 100644 index 000000000..d9d891e04 --- /dev/null +++ b/weed/worker/tasks/erasure_coding/scheduling.go @@ -0,0 +1,40 @@ +package erasure_coding + +import ( + "github.com/seaweedfs/seaweedfs/weed/worker/tasks/base" + "github.com/seaweedfs/seaweedfs/weed/worker/types" +) + +// Scheduling implements the scheduling logic for erasure coding tasks +func Scheduling(task *types.TaskInput, runningTasks []*types.TaskInput, availableWorkers []*types.WorkerData, config base.TaskConfig) bool { + ecConfig := config.(*Config) + + // Check if we have available workers + if len(availableWorkers) == 0 { + return false + } + + // Count running EC tasks + runningCount := 0 + for _, runningTask := range runningTasks { + if runningTask.Type == types.TaskTypeErasureCoding { + runningCount++ + } + } + + // Check concurrency limit + if runningCount >= ecConfig.MaxConcurrent { + return false + } + + // Check if any worker can handle EC tasks + for _, worker := range availableWorkers { + for _, capability := range worker.Capabilities { + if capability == types.TaskTypeErasureCoding { + return true + } + } + } + + return false +} -- cgit v1.2.3