tm-monitor: update health after we added / removed node (#2694)

Refs #2693
This commit is contained in:
zhangzheng 2018-10-25 18:27:32 +08:00 committed by Anton Kaliaev
parent 6643c5dd11
commit bbf15b3d09
1 changed files with 8 additions and 0 deletions

View File

@ -140,14 +140,22 @@ func (n *Network) NodeIsOnline(name string) {
// NewNode is called when the new node is added to the monitor.
func (n *Network) NewNode(name string) {
n.mu.Lock()
defer n.mu.Unlock()
n.NumNodesMonitored++
n.NumNodesMonitoredOnline++
n.updateHealth()
}
// NodeDeleted is called when the node is deleted from under the monitor.
func (n *Network) NodeDeleted(name string) {
n.mu.Lock()
defer n.mu.Unlock()
n.NumNodesMonitored--
n.NumNodesMonitoredOnline--
n.updateHealth()
}
func (n *Network) updateHealth() {