checkNodesForever 持续运行检查节点函数,并维护节点数组
()
| 52 | |
| 53 | //checkNodesForever 持续运行检查节点函数,并维护节点数组 |
| 54 | func (c *Controller) checkNodesForever() { |
| 55 | for { |
| 56 | now := time.Now() |
| 57 | for ip, node := range c.nodePool.Nodes { |
| 58 | if now.Sub(node.Update) > time.Duration(time.Second*10) { |
| 59 | delete(c.nodePool.Nodes, ip) |
| 60 | lg.Warn("Inspector %v, %v lost from controller", ip, node.Hostname) |
| 61 | } |
| 62 | } |
| 63 | time.Sleep(time.Second * 5) |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | //receiveHearbeat 接收心跳包,并更新节点状态 |
| 68 | func (c *Controller) receiveHearbeat(heartbeat *types.HeartBeat) { |