]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: refactor check_health()
authorSage Weil <sage@inktank.com>
Mon, 16 Jun 2014 23:58:14 +0000 (16:58 -0700)
committerSage Weil <sage@inktank.com>
Tue, 1 Jul 2014 23:13:08 +0000 (16:13 -0700)
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 <sage@inktank.com>
(cherry picked from commit 82e47db8073b622183a5e33f6e0b999a3a144804)

src/mon/ConfigKeyService.h
src/mon/DataHealthService.cc
src/mon/DataHealthService.h
src/mon/HealthMonitor.cc
src/mon/HealthMonitor.h
src/mon/HealthService.h
src/mon/Monitor.cc
src/mon/QuorumService.h

index e379af610b9cb96016dddbdee702764ed69a52f9..e33070b65bc3ee3387bd66115eca2d45bb84699d 100644 (file)
@@ -52,11 +52,9 @@ public:
    * @{
    */
   virtual void init() { }
-  virtual health_status_t get_health(
-                          Formatter *f,
-                          list<pair<health_status_t,string> > *detail) {
-    return HEALTH_OK;
-  }
+  virtual void get_health(Formatter *f,
+                         list<pair<health_status_t,string> >& summary,
+                          list<pair<health_status_t,string> > *detail) { }
   virtual bool service_dispatch(Message *m);
 
   virtual void start_epoch() { }
index bb6f8c0d46f64da19227a07b649c1fdfeae85e7a..def00ca173c751cc1ef0e0acf30a34ce4840f7d2 100644 (file)
@@ -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<pair<health_status_t,string> >& summary,
     list<pair<health_status_t,string> > *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<entity_inst_t,DataStats>::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)
index 750c58e5f80e58ef857dbe19128106eff2470b35..221e17947a8e42e9b8d489f24e5e84837efb5be3 100644 (file)
@@ -70,7 +70,8 @@ public:
     start_tick();
   }
 
-  virtual health_status_t get_health(Formatter *f,
+  virtual void get_health(Formatter *f,
+                          list<pair<health_status_t,string> >& summary,
                           list<pair<health_status_t,string> > *detail);
 
   virtual int get_type() {
index c6ab6f489180b163c718df807e659a10d0d321c9..7cba39bf17cbb8594b21f9d370f6c520e52eea88 100644 (file)
@@ -80,10 +80,10 @@ void HealthMonitor::service_shutdown()
   services.clear();
 }
 
-health_status_t HealthMonitor::get_health(Formatter *f,
-                                         list<pair<health_status_t,string> > *detail)
+void HealthMonitor::get_health(Formatter *f,
+                              list<pair<health_status_t,string> >& summary,
+                              list<pair<health_status_t,string> > *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<int,HealthService*>::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;
 }
 
index a1c98a9bb77565338961ba195df4e5dfe2f3b1a8..3d842615c936a7cf86dcd5decdfd610689cdff90 100644 (file)
@@ -42,8 +42,9 @@ public:
    * @{
    */
   virtual void init();
-  virtual health_status_t get_health(Formatter *f,
-                          list<pair<health_status_t,string> > *detail);
+  virtual void get_health(Formatter *f,
+                    list<pair<health_status_t,string> >& summary,
+                    list<pair<health_status_t,string> > *detail);
   virtual bool service_dispatch(Message *m);
 
   virtual void start_epoch() {
index 11d6e485758740ecd3e05ce7e42a94887e36d7c9..2a46f882b8db850aa4f2f8c7251c221de78643d8 100644 (file)
@@ -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<pair<health_status_t,string> > *detail) = 0;
+  virtual void get_health(Formatter *f,
+                         list<pair<health_status_t,string> >& summary,
+                         list<pair<health_status_t,string> > *detail) = 0;
   virtual int get_type() = 0;
   virtual string get_name() const = 0;
 };
index 09823276e42d6570d7fa3d01feebf0d8609fed3d..cd447e7cd1b1fd71465447949df16189dd098a59 100644 (file)
@@ -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();
index 27971b7d599bb93c067eedc3b73515c72f8489e9..ef9dcdcf1bd6ca1b5556a76ffc0afd75fe943c01 100644 (file)
@@ -124,7 +124,8 @@ public:
 
   virtual void init() { }
 
-  virtual health_status_t get_health(Formatter *f,
+  virtual void get_health(Formatter *f,
+                         list<pair<health_status_t,string> >& summary,
                           list<pair<health_status_t,string> > *detail) = 0;
   virtual int get_type() = 0;
   virtual string get_name() const = 0;