]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/HealthMonitor: avoid sending unnecessary MMonHealthChecks to leader 16478/head
authorxie xingguo <xie.xingguo@zte.com.cn>
Fri, 21 Jul 2017 10:35:06 +0000 (18:35 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Fri, 21 Jul 2017 11:50:11 +0000 (19:50 +0800)
If there is no historic warnings and no new warnings is generated,
skip sending MMonHealthChecks(for peon) or updating quorum_checks(for leader).

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/mon/HealthMonitor.cc
src/mon/health_check.h

index 53c79f50a6999ba3902110bea4c9b6416c8705be..a695e01db3ea4ea9bb01ecb55bb5e5514e435fc4 100644 (file)
@@ -278,19 +278,26 @@ bool HealthMonitor::check_member_health()
   }
 
   auto p = quorum_checks.find(mon->rank);
-  if (p == quorum_checks.end() ||
-      p->second != next) {
-    if (mon->is_leader()) {
-      // prepare to propose
-      quorum_checks[mon->rank] = next;
-      changed = true;
-    } else {
-      // tell the leader
-      mon->messenger->send_message(new MMonHealthChecks(next),
-                                  mon->monmap->get_inst(mon->get_leader()));
+  if (p == quorum_checks.end()) {
+    if (next.empty()) {
+      return false;
+    }
+  } else {
+    if (p->second == next) {
+      return false;
     }
   }
 
+  if (mon->is_leader()) {
+    // prepare to propose
+    quorum_checks[mon->rank] = next;
+    changed = true;
+  } else {
+    // tell the leader
+    mon->messenger->send_message(new MMonHealthChecks(next),
+                                 mon->monmap->get_inst(mon->get_leader()));
+  }
+
   return changed;
 }
 
index f0c00d176e870801da679e5016caf2580aeda4e0..51f0e1095d8e5179d4481f94c81f4844d189935a 100644 (file)
@@ -87,6 +87,9 @@ struct health_check_map_t {
   void clear() {
     checks.clear();
   }
+  bool empty() const {
+    return checks.empty();
+  }
   void swap(health_check_map_t& other) {
     checks.swap(other.checks);
   }