From bbf15b3d09ac05ff2cfd58b53313ec612e1a9b07 Mon Sep 17 00:00:00 2001 From: zhangzheng Date: Thu, 25 Oct 2018 18:27:32 +0800 Subject: [PATCH] tm-monitor: update health after we added / removed node (#2694) Refs #2693 --- tools/tm-monitor/monitor/network.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/tm-monitor/monitor/network.go b/tools/tm-monitor/monitor/network.go index 9b147c06b..bb5dd0baa 100644 --- a/tools/tm-monitor/monitor/network.go +++ b/tools/tm-monitor/monitor/network.go @@ -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() {