]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: move the PGStatService lifecycle into the MgrMon/PGMon
authorGreg Farnum <gfarnum@redhat.com>
Wed, 15 Mar 2017 22:24:51 +0000 (15:24 -0700)
committerSage Weil <sage@redhat.com>
Fri, 2 Jun 2017 16:59:43 +0000 (12:59 -0400)
I remain lazy enough that we just use the MgrMon right now for easier
testing.

Signed-off-by: Greg Farnum <gfarnum@redhat.com>
src/mon/MgrMonitor.cc
src/mon/MgrMonitor.h
src/mon/Monitor.cc
src/mon/PGMonitor.cc
src/mon/PGMonitor.h

index 041258b6371c99a35ea8bd3748b0f5aadefcf632..db748af167fb7352c33ff8ed049f1e487d79b76f 100644 (file)
@@ -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<MMonMgrReport*>(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;
+}
index d45d853ceb56904d12d32b9fd1ff4a15432ed16f..45ef04b7435e2719e0bebb492ba0db9d0357d886 100644 (file)
  * 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<uint64_t, ceph::coarse_mono_clock::time_point> 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
index adb624c4ab2c3b913ff96a14cfa0d1a9586d6cd4..c32a613d880163056c14cbe971264e501bde07c8 100644 (file)
@@ -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)
index 2f9ca65908bca53c32cd404c85bf22584b15254a..b5443c2293b461093c3868798682a3649ac571e7 100644 (file)
@@ -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;
+}
index 5f7650b0357a94b57e155f98253ca08a14ef3ec1..021e91ab81352e39d75dd58088ea397e4eed6564 100644 (file)
@@ -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<string>& 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);