mirror of
https://github.com/newnius/YAO-scheduler.git
synced 2025-12-15 08:16:43 +00:00
update shceduler_fair
This commit is contained in:
@@ -21,7 +21,7 @@ type SchedulerFair struct {
|
|||||||
scheduling sync.Mutex
|
scheduling sync.Mutex
|
||||||
jobs map[string]*JobManager
|
jobs map[string]*JobManager
|
||||||
nextQueue string
|
nextQueue string
|
||||||
resourceAllocations map[string]ResourceCount
|
resourceAllocations map[string]*ResourceCount
|
||||||
}
|
}
|
||||||
|
|
||||||
type FairJobSorter []Job
|
type FairJobSorter []Job
|
||||||
@@ -45,7 +45,7 @@ func (scheduler *SchedulerFair) Start() {
|
|||||||
scheduler.nextQueue = "default"
|
scheduler.nextQueue = "default"
|
||||||
scheduler.queues = map[string][]Job{}
|
scheduler.queues = map[string][]Job{}
|
||||||
scheduler.queues["default"] = []Job{}
|
scheduler.queues["default"] = []Job{}
|
||||||
scheduler.resourceAllocations = map[string]ResourceCount{}
|
scheduler.resourceAllocations = map[string]*ResourceCount{}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
@@ -182,9 +182,9 @@ func (scheduler *SchedulerFair) AcquireResource(job Job, task Task) NodeStatus {
|
|||||||
}
|
}
|
||||||
go func(res NodeStatus) {
|
go func(res NodeStatus) {
|
||||||
if _, ok := scheduler.resourceAllocations[job.Group]; !ok {
|
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.CPU += res.MemTotal
|
||||||
cnt.Memory += res.NumCPU
|
cnt.Memory += res.NumCPU
|
||||||
for _, v := range res.Status {
|
for _, v := range res.Status {
|
||||||
@@ -210,7 +210,7 @@ func (scheduler *SchedulerFair) ReleaseResource(job Job, agent NodeStatus) {
|
|||||||
}
|
}
|
||||||
go func(res NodeStatus) {
|
go func(res NodeStatus) {
|
||||||
if _, ok := scheduler.resourceAllocations[job.Group]; !ok {
|
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.CPU -= res.MemTotal
|
||||||
|
|||||||
Reference in New Issue
Block a user