aboutsummaryrefslogtreecommitdiff
path: root/weed/worker/tasks/balance/scheduling.go
diff options
context:
space:
mode:
Diffstat (limited to 'weed/worker/tasks/balance/scheduling.go')
-rw-r--r--weed/worker/tasks/balance/scheduling.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/weed/worker/tasks/balance/scheduling.go b/weed/worker/tasks/balance/scheduling.go
new file mode 100644
index 000000000..878686309
--- /dev/null
+++ b/weed/worker/tasks/balance/scheduling.go
@@ -0,0 +1,37 @@
+package balance
+
+import (
+ "github.com/seaweedfs/seaweedfs/weed/worker/tasks/base"
+ "github.com/seaweedfs/seaweedfs/weed/worker/types"
+)
+
+// Scheduling implements the scheduling logic for balance tasks
+func Scheduling(task *types.TaskInput, runningTasks []*types.TaskInput, availableWorkers []*types.WorkerData, config base.TaskConfig) bool {
+ balanceConfig := config.(*Config)
+
+ // Count running balance tasks
+ runningBalanceCount := 0
+ for _, runningTask := range runningTasks {
+ if runningTask.Type == types.TaskTypeBalance {
+ runningBalanceCount++
+ }
+ }
+
+ // Check concurrency limit
+ if runningBalanceCount >= balanceConfig.MaxConcurrent {
+ return false
+ }
+
+ // Check if we have available workers
+ availableWorkerCount := 0
+ for _, worker := range availableWorkers {
+ for _, capability := range worker.Capabilities {
+ if capability == types.TaskTypeBalance {
+ availableWorkerCount++
+ break
+ }
+ }
+ }
+
+ return availableWorkerCount > 0
+}