From: Sage Weil Date: Mon, 16 Jun 2014 23:58:14 +0000 (-0700) Subject: mon: refactor check_health() X-Git-Tag: v0.80.2~8^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=e96637c2e33ec092f28af0ce96bfe2e4d7748ff8;p=ceph.git mon: refactor check_health() Refactor the get_health() methods to always take both a summary and detail. Eliminate the return value and pull that directly from the summary, as we already do with the PaxosServices. Signed-off-by: Sage Weil (cherry picked from commit 82e47db8073b622183a5e33f6e0b999a3a144804) --- diff --git a/src/mon/ConfigKeyService.h b/src/mon/ConfigKeyService.h index e379af610b9cb..e33070b65bc3e 100644 --- a/src/mon/ConfigKeyService.h +++ b/src/mon/ConfigKeyService.h @@ -52,11 +52,9 @@ public: * @{ */ virtual void init() { } - virtual health_status_t get_health( - Formatter *f, - list > *detail) { - return HEALTH_OK; - } + virtual void get_health(Formatter *f, + list >& summary, + list > *detail) { } virtual bool service_dispatch(Message *m); virtual void start_epoch() { } diff --git a/src/mon/DataHealthService.cc b/src/mon/DataHealthService.cc index bb6f8c0d46f64..def00ca173c75 100644 --- a/src/mon/DataHealthService.cc +++ b/src/mon/DataHealthService.cc @@ -68,8 +68,9 @@ void DataHealthService::start_epoch() last_warned_percent = 0; } -health_status_t DataHealthService::get_health( +void DataHealthService::get_health( Formatter *f, + list >& summary, list > *detail) { dout(10) << __func__ << dendl; @@ -78,8 +79,6 @@ health_status_t DataHealthService::get_health( f->open_array_section("mons"); } - health_status_t overall_status = HEALTH_OK; - for (map::iterator it = stats.begin(); it != stats.end(); ++it) { string mon_name = mon->monmap->get_name(it->first.addr); @@ -107,8 +106,6 @@ health_status_t DataHealthService::get_health( health_detail.append(ss.str()); } - if (overall_status > health_status) - overall_status = health_status; if (detail && health_status != HEALTH_OK) { stringstream ss; @@ -134,8 +131,6 @@ health_status_t DataHealthService::get_health( f->close_section(); // mons f->close_section(); // data_health } - - return overall_status; } int DataHealthService::update_store_stats(DataStats &ours) diff --git a/src/mon/DataHealthService.h b/src/mon/DataHealthService.h index 750c58e5f80e5..221e17947a8e4 100644 --- a/src/mon/DataHealthService.h +++ b/src/mon/DataHealthService.h @@ -70,7 +70,8 @@ public: start_tick(); } - virtual health_status_t get_health(Formatter *f, + virtual void get_health(Formatter *f, + list >& summary, list > *detail); virtual int get_type() { diff --git a/src/mon/HealthMonitor.cc b/src/mon/HealthMonitor.cc index c6ab6f489180b..7cba39bf17cbb 100644 --- a/src/mon/HealthMonitor.cc +++ b/src/mon/HealthMonitor.cc @@ -80,10 +80,10 @@ void HealthMonitor::service_shutdown() services.clear(); } -health_status_t HealthMonitor::get_health(Formatter *f, - list > *detail) +void HealthMonitor::get_health(Formatter *f, + list >& summary, + list > *detail) { - health_status_t overall = HEALTH_OK; if (f) { f->open_object_section("health"); f->open_array_section("health_services"); @@ -92,16 +92,12 @@ health_status_t HealthMonitor::get_health(Formatter *f, for (map::iterator it = services.begin(); it != services.end(); ++it) { - health_status_t h = it->second->get_health(f, detail); - if (overall > h) - overall = h; + it->second->get_health(f, summary, detail); } if (f) { f->close_section(); // health_services f->close_section(); // health } - - return overall; } diff --git a/src/mon/HealthMonitor.h b/src/mon/HealthMonitor.h index a1c98a9bb7756..3d842615c936a 100644 --- a/src/mon/HealthMonitor.h +++ b/src/mon/HealthMonitor.h @@ -42,8 +42,9 @@ public: * @{ */ virtual void init(); - virtual health_status_t get_health(Formatter *f, - list > *detail); + virtual void get_health(Formatter *f, + list >& summary, + list > *detail); virtual bool service_dispatch(Message *m); virtual void start_epoch() { diff --git a/src/mon/HealthService.h b/src/mon/HealthService.h index 11d6e48575874..2a46f882b8db8 100644 --- a/src/mon/HealthService.h +++ b/src/mon/HealthService.h @@ -37,8 +37,9 @@ struct HealthService : public QuorumService virtual bool service_dispatch(MMonHealth *m) = 0; public: - virtual health_status_t get_health(Formatter *f, - list > *detail) = 0; + virtual void get_health(Formatter *f, + list >& summary, + list > *detail) = 0; virtual int get_type() = 0; virtual string get_name() const = 0; }; diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 09823276e42d6..cd447e7cd1b1f 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -1889,6 +1889,8 @@ void Monitor::get_health(string& status, bufferlist *detailbl, Formatter *f) s->get_health(summary, detailbl ? &detail : NULL); } + health_monitor->get_health(f, summary, (detailbl ? &detail : NULL)); + if (f) f->open_array_section("summary"); stringstream ss; @@ -1974,10 +1976,6 @@ void Monitor::get_health(string& status, bufferlist *detailbl, Formatter *f) if (f) f->close_section(); - health_status_t hmstatus = health_monitor->get_health(f, (detailbl ? &detail : NULL)); - if (overall > hmstatus) - overall = hmstatus; - stringstream fss; fss << overall; status = fss.str() + ss.str(); diff --git a/src/mon/QuorumService.h b/src/mon/QuorumService.h index 27971b7d599bb..ef9dcdcf1bd6c 100644 --- a/src/mon/QuorumService.h +++ b/src/mon/QuorumService.h @@ -124,7 +124,8 @@ public: virtual void init() { } - virtual health_status_t get_health(Formatter *f, + virtual void get_health(Formatter *f, + list >& summary, list > *detail) = 0; virtual int get_type() = 0; virtual string get_name() const = 0;