From e209db4a69034b7b0d873dcfd36f38d9a78f354b Mon Sep 17 00:00:00 2001 From: Colin Patrick McCabe Date: Wed, 20 Apr 2011 13:38:17 -0700 Subject: [PATCH] PGMonitor: unregister the config obs in ~PGMonitor Using the new unregister call, unregister the config observer in ~PGMonitor. Signed-off-by: Colin McCabe --- src/mon/PGMonitor.cc | 30 ++++++++++++++++++++++++++++++ src/mon/PGMonitor.h | 41 ++++++++++++----------------------------- 2 files changed, 42 insertions(+), 29 deletions(-) diff --git a/src/mon/PGMonitor.cc b/src/mon/PGMonitor.cc index 235e1db720081..4a0bf3a01e0f8 100644 --- a/src/mon/PGMonitor.cc +++ b/src/mon/PGMonitor.cc @@ -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& 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 */ diff --git a/src/mon/PGMonitor.h b/src/mon/PGMonitor.h index 817a9073e4825..eb9facae0c1f9 100644 --- a/src/mon/PGMonitor.h +++ b/src/mon/PGMonitor.h @@ -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& 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 -- 2.39.5