mirror of
https://github.com/newnius/YAO-scheduler.git
synced 2025-06-08 06:41:56 +00:00
add keep alive support
This commit is contained in:
parent
4d14a93b88
commit
926fb144f2
@ -10,9 +10,19 @@ type ResourcePool struct {
|
|||||||
nodes map[string]NodeStatus
|
nodes map[string]NodeStatus
|
||||||
|
|
||||||
history []PoolStatus
|
history []PoolStatus
|
||||||
|
|
||||||
|
heartBeat map[string]time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pool *ResourcePool) start() {
|
func (pool *ResourcePool) start() {
|
||||||
|
/* check dead nodes */
|
||||||
|
for k, v := range pool.heartBeat {
|
||||||
|
if v.Add(time.Second * 30).Before(time.Now()) {
|
||||||
|
delete(pool.nodes, k)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* save pool status periodically */
|
||||||
go func() {
|
go func() {
|
||||||
/* waiting for data */
|
/* waiting for data */
|
||||||
pool.history = []PoolStatus{}
|
pool.history = []PoolStatus{}
|
||||||
@ -79,6 +89,7 @@ func (pool *ResourcePool) update(node NodeStatus) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
pool.nodes[node.ClientID] = node
|
pool.nodes[node.ClientID] = node
|
||||||
|
pool.heartBeat[node.ClientID] = time.Now()
|
||||||
|
|
||||||
//log.Println(pool.nodes)
|
//log.Println(pool.nodes)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user