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-03-20 11:14:07 +08:00
parent aa2a233485
commit 66b4468c74
8 changed files with 541 additions and 26 deletions

View File

@@ -2,22 +2,32 @@ package main
import (
"sync"
)
)
type ResourcePool struct {
mu sync.Mutex
nodes map[int][]Status
nodes map[int][]NodeStatus
}
func (pool *ResourcePool) update(node MsgAgent) {
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
}
}
}
pool.nodes[node.ClientID] = node.Status
//log.Println(pool.nodes)
}
func (pool *ResourcePool) getByID(id int) []Status {
func (pool *ResourcePool) getByID(id int) []NodeStatus {
pool.mu.Lock()
defer pool.mu.Unlock()
@@ -25,5 +35,5 @@ func (pool *ResourcePool) getByID(id int) []Status {
if ok {
return status
}
return []Status{}
return []NodeStatus{}
}