1
0
mirror of https://github.com/newnius/YAO-scheduler.git synced 2025-12-15 08:16:43 +00:00
This commit is contained in:
2019-04-16 16:59:19 +08:00
parent e34d75dc7f
commit 1504c71fb4
7 changed files with 45 additions and 41 deletions

View File

@@ -2,32 +2,32 @@ package main
import (
"sync"
)
)
type ResourcePool struct {
mu sync.Mutex
nodes map[int][]NodeStatus
nodes map[int]NodeStatus
}
func (pool *ResourcePool) update(node MsgAgent) {
func (pool *ResourcePool) update(node NodeStatus) {
pool.mu.Lock()
defer pool.mu.Unlock()
status, ok := pool.nodes[node.ClientID]
if ok {
for i := range status {
if status[i].UUID == node.Status[i].UUID {
node.Status[i].MemoryAllocated = status[i].MemoryAllocated
for i, GPU := range status.Status {
if GPU.UUID == node.Status[i].UUID {
node.Status[i].MemoryAllocated = GPU.MemoryAllocated
}
}
}
pool.nodes[node.ClientID] = node.Status
pool.nodes[node.ClientID] = node
//log.Println(pool.nodes)
}
func (pool *ResourcePool) getByID(id int) []NodeStatus {
func (pool *ResourcePool) getByID(id int) NodeStatus {
pool.mu.Lock()
defer pool.mu.Unlock()
@@ -35,5 +35,5 @@ func (pool *ResourcePool) getByID(id int) []NodeStatus {
if ok {
return status
}
return []NodeStatus{}
return NodeStatus{}
}