From f5ef9b00a6596aac65c8151979fe60d2b72f55b5 Mon Sep 17 00:00:00 2001 From: Newnius Date: Thu, 1 Aug 2019 14:00:24 +0800 Subject: [PATCH] update shceduler_fair --- src/scheduler_fair.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/scheduler_fair.go b/src/scheduler_fair.go index f270c52..2a8714a 100644 --- a/src/scheduler_fair.go +++ b/src/scheduler_fair.go @@ -21,7 +21,7 @@ type SchedulerFair struct { scheduling sync.Mutex jobs map[string]*JobManager nextQueue string - resourceAllocations map[string]ResourceCount + resourceAllocations map[string]*ResourceCount } type FairJobSorter []Job @@ -45,7 +45,7 @@ func (scheduler *SchedulerFair) Start() { scheduler.nextQueue = "default" scheduler.queues = map[string][]Job{} scheduler.queues["default"] = []Job{} - scheduler.resourceAllocations = map[string]ResourceCount{} + scheduler.resourceAllocations = map[string]*ResourceCount{} go func() { for { @@ -182,9 +182,9 @@ func (scheduler *SchedulerFair) AcquireResource(job Job, task Task) NodeStatus { } go func(res NodeStatus) { if _, ok := scheduler.resourceAllocations[job.Group]; !ok { - scheduler.resourceAllocations[job.Group] = ResourceCount{} + scheduler.resourceAllocations[job.Group] = &ResourceCount{} } - cnt, _ := scheduler.resourceAllocations[job.Group] + cnt, _ :=scheduler.resourceAllocations[job.Group] cnt.CPU += res.MemTotal cnt.Memory += res.NumCPU for _, v := range res.Status { @@ -210,7 +210,7 @@ func (scheduler *SchedulerFair) ReleaseResource(job Job, agent NodeStatus) { } go func(res NodeStatus) { if _, ok := scheduler.resourceAllocations[job.Group]; !ok { - scheduler.resourceAllocations[job.Group] = ResourceCount{} + scheduler.resourceAllocations[job.Group] = &ResourceCount{} } cnt, _ := scheduler.resourceAllocations[job.Group] cnt.CPU -= res.MemTotal