From: xie xingguo Date: Fri, 21 Jul 2017 10:35:06 +0000 (+0800) Subject: mon/HealthMonitor: avoid sending unnecessary MMonHealthChecks to leader X-Git-Tag: v12.1.2~167^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F16478%2Fhead;p=ceph.git mon/HealthMonitor: avoid sending unnecessary MMonHealthChecks to leader 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 --- diff --git a/src/mon/HealthMonitor.cc b/src/mon/HealthMonitor.cc index 53c79f50a699..a695e01db3ea 100644 --- a/src/mon/HealthMonitor.cc +++ b/src/mon/HealthMonitor.cc @@ -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; } diff --git a/src/mon/health_check.h b/src/mon/health_check.h index f0c00d176e87..51f0e1095d8e 100644 --- a/src/mon/health_check.h +++ b/src/mon/health_check.h @@ -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); }