]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
PGMonitor: unregister the config obs in ~PGMonitor
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Wed, 20 Apr 2011 20:38:17 +0000 (13:38 -0700)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Wed, 20 Apr 2011 20:49:21 +0000 (13:49 -0700)
Using the new unregister call, unregister the config observer in
~PGMonitor.

Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
src/mon/PGMonitor.cc
src/mon/PGMonitor.h

index 235e1db720081cffb7a742b4ab8be1bda435de65..4a0bf3a01e0f86905edafe969450be2d19e63599 100644 (file)
@@ -47,6 +47,36 @@ static ostream& _prefix(Monitor *mon, PGMap& pg_map) {
                << ".pg v" << pg_map.version << " ";
 }
 
+class RatioMonitor : public md_config_obs_t {
+  PGMonitor *mon;
+public:
+  RatioMonitor(PGMonitor *pgmon) : mon(pgmon) {}
+  virtual ~RatioMonitor() {}
+  virtual const char **get_tracked_conf_keys() const {
+    static const char *KEYS[] = { "mon_osd_full_ratio",
+                                 "mon_osd_nearfull_ratio", NULL };
+    return KEYS;
+  }
+  virtual void handle_conf_change(const md_config_t *conf,
+                                 const std::set<std::string>& changed) {
+    mon->update_full_ratios(((float)conf->mon_osd_full_ratio) / 100,
+                           ((float)conf->mon_osd_nearfull_ratio) / 100);
+  }
+};
+
+PGMonitor::PGMonitor(Monitor *mn, Paxos *p)
+  : PaxosService(mn, p)
+{
+  ratio_monitor = new RatioMonitor(this);
+  g_conf.add_observer(ratio_monitor);
+}
+
+PGMonitor::~PGMonitor()
+{
+  g_conf.remove_observer(ratio_monitor);
+  delete ratio_monitor;
+}
+
 /*
  Tick function to update the map based on performance every N seconds
 */
index 817a9073e4825d85c0d108451b6109509956a0f4..eb9facae0c1f970ebfb6c05ecb92f016ba5b381e 100644 (file)
@@ -37,6 +37,8 @@ class MStatfs;
 class MMonCommand;
 class MGetPoolStats;
 
+class RatioMonitor;
+
 class PGMonitor : public PaxosService {
 public:
   PGMap pg_map;
@@ -94,35 +96,9 @@ private:
   bool register_new_pgs();
   void send_pg_creates();
 
- public:
-  class RatioMonitor : public md_config_obs_t {
-    PGMonitor *mon;
-  public:
-    RatioMonitor(PGMonitor *pgmon) : mon(pgmon) {}
-    virtual ~RatioMonitor() {}
-    virtual const char **get_tracked_conf_keys() const {
-      static const char *KEYS[] = { "mon_osd_full_ratio",
-                                    "mon_osd_nearfull_ratio", NULL };
-      return KEYS;
-    }
-    virtual void handle_conf_change(const md_config_t *conf,
-                                    const std::set<std::string>& changed) {
-      mon->update_full_ratios(((float)conf->mon_osd_full_ratio) / 100,
-                              ((float)conf->mon_osd_nearfull_ratio) / 100);
-    }
-  };
-
-  RatioMonitor *ratio_monitor;
-  friend class RatioMonitor;
-
-  PGMonitor(Monitor *mn, Paxos *p) : PaxosService(mn, p) {
-    ratio_monitor = new RatioMonitor(this);
-    g_conf.add_observer(ratio_monitor);
-  }
-
-  ~PGMonitor() {
-    delete ratio_monitor;
-  }
+public:
+  PGMonitor(Monitor *mn, Paxos *p);
+  virtual ~PGMonitor();
 
   virtual void on_election_start();
 
@@ -132,6 +108,13 @@ private:
 
   enum health_status_t get_health(std::ostream &ss) const;
 
+private:
+  // no copying allowed
+  PGMonitor(const PGMonitor &rhs);
+  PGMonitor &operator=(const PGMonitor &rhs);
+
+  RatioMonitor *ratio_monitor;
+  friend class RatioMonitor;
 };
 
 #endif