From: Greg Farnum Date: Wed, 15 Mar 2017 22:24:51 +0000 (-0700) Subject: mon: move the PGStatService lifecycle into the MgrMon/PGMon X-Git-Tag: ses5-milestone6~8^2~19^2~106 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ed1af717aa40c1f451d653b3c017bd6e7e7b695d;p=ceph.git mon: move the PGStatService lifecycle into the MgrMon/PGMon I remain lazy enough that we just use the MgrMon right now for easier testing. Signed-off-by: Greg Farnum --- diff --git a/src/mon/MgrMonitor.cc b/src/mon/MgrMonitor.cc index 041258b6371c..db748af167fb 100644 --- a/src/mon/MgrMonitor.cc +++ b/src/mon/MgrMonitor.cc @@ -17,7 +17,7 @@ #include "messages/MMonMgrReport.h" #include "PGMap.h" -#include "PGMonitor.h" +#include "PGStatService.h" #include "include/stringify.h" #include "mgr/MgrContext.h" #include "OSDMonitor.h" @@ -250,7 +250,7 @@ bool MgrMonitor::preprocess_report(MonOpRequestRef op) { return false; } bool MgrMonitor::prepare_report(MonOpRequestRef op) { MMonMgrReport *m = static_cast(op->get_req()); - mon->pgservice->reset(m->pg_map); + pgservice->reset(m->pg_map); return true; } @@ -625,3 +625,16 @@ void MgrMonitor::on_shutdown() { cancel_timer(); } + +PGStatService *MgrMonitor::get_pg_stat_service() +{ + if (!pgservice) { + pgservice = new PGMapStatService(); + } + return pgservice; +} + +MgrMonitor::~MgrMonitor() +{ + delete pgservice; +} diff --git a/src/mon/MgrMonitor.h b/src/mon/MgrMonitor.h index d45d853ceb56..45ef04b7435e 100644 --- a/src/mon/MgrMonitor.h +++ b/src/mon/MgrMonitor.h @@ -11,19 +11,24 @@ * Foundation. See file COPYING. */ +#ifndef CEPH_MGRMONITOR_H +#define CEPH_MGRMONITOR_H #include "include/Context.h" #include "MgrMap.h" #include "PaxosService.h" +class PGStatService; -class MgrMonitor : public PaxosService +class MgrMonitor: public PaxosService { MgrMap map; MgrMap pending_map; utime_t first_seen_inactive; + PGStatService *pgservice = nullptr; + std::map last_beacon; /** @@ -44,7 +49,10 @@ class MgrMonitor : public PaxosService public: MgrMonitor(Monitor *mn, Paxos *p, const string& service_name) : PaxosService(mn, p, service_name) + : PaxosService(mn, p, service_name), + digest_event(nullptr) {} + ~MgrMonitor() override; void init() override; void on_shutdown() override; @@ -84,6 +92,9 @@ public: void print_summary(Formatter *f, std::ostream *ss) const; + PGStatService *get_pg_stat_service(); + friend class C_Updated; }; +#endif diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index adb624c4ab2c..c32a613d8801 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -179,7 +179,7 @@ Monitor::Monitor(CephContext* cct_, string nm, MonitorDBStore *s, leader_supported_mon_commands_size(0), mgr_messenger(mgr_m), mgr_client(cct_, mgr_m), - pgservice(new PGMapStatService), + pgservice(nullptr), store(s), state(STATE_PROBING), @@ -243,6 +243,8 @@ Monitor::Monitor(CephContext* cct_, string nm, MonitorDBStore *s, int cmdsize; get_locally_supported_monitor_commands(&cmds, &cmdsize); set_leader_supported_commands(cmds, cmdsize); + + pgservice = mgrmon()->get_pg_stat_service(); } PaxosService *Monitor::get_paxos_service_by_name(const string& name) diff --git a/src/mon/PGMonitor.cc b/src/mon/PGMonitor.cc index 2f9ca65908bc..b5443c2293b4 100644 --- a/src/mon/PGMonitor.cc +++ b/src/mon/PGMonitor.cc @@ -19,6 +19,7 @@ #include "Monitor.h" #include "OSDMonitor.h" #include "MonitorDBStore.h" +#include "PGStatService.h" #include "messages/MPGStats.h" #include "messages/MPGStatsAck.h" @@ -1670,3 +1671,15 @@ bool PGMonitor::check_sub(Subscription *sub) } return true; } + +PGStatService *PGMonitor::get_pg_stat_service() +{ + if (!pgservice) { + pgservice = new PGMapStatService(pg_map); + } + return pgservice; +} +PGMonitor::~PGMonitor() +{ + delete pgservice; +} diff --git a/src/mon/PGMonitor.h b/src/mon/PGMonitor.h index 5f7650b0357a..021e91ab8135 100644 --- a/src/mon/PGMonitor.h +++ b/src/mon/PGMonitor.h @@ -38,10 +38,12 @@ class MGetPoolStats; class TextTable; class MPGStats; +class PGStatService; class PGMonitor : public PaxosService { public: PGMap pg_map; + PGStatService *pgservice; private: PGMap::Incremental pending_inc; @@ -92,11 +94,12 @@ private: public: PGMonitor(Monitor *mn, Paxos *p, const string& service_name) : PaxosService(mn, p, service_name), + pgservice(nullptr), pgmap_meta_prefix("pgmap_meta"), pgmap_pg_prefix("pgmap_pg"), pgmap_osd_prefix("pgmap_osd") { } - ~PGMonitor() override { } + ~PGMonitor() override; void get_store_prefixes(set& s) override { s.insert(get_service_name()); @@ -140,6 +143,8 @@ public: void check_subs(); bool check_sub(Subscription *sub); + PGStatService *get_pg_stat_service(); + private: // no copying allowed PGMonitor(const PGMonitor &rhs);