mirror of
https://github.com/newnius/YAO-scheduler.git
synced 2025-12-15 08:16:43 +00:00
update
This commit is contained in:
@@ -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{}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user