]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: outline a PGStatService to replace raw PGMap calls
authorGreg Farnum <gfarnum@redhat.com>
Tue, 14 Mar 2017 22:43:08 +0000 (15:43 -0700)
committerSage Weil <sage@redhat.com>
Fri, 2 Jun 2017 16:59:10 +0000 (12:59 -0400)
Right now, this is a quick hack that derives from PGMap. Soon, it will
be more interesting.

Signed-off-by: Greg Farnum <gfarnum@redhat.com>
src/mon/MgrMonitor.cc
src/mon/MgrMonitor.h
src/mon/Monitor.cc
src/mon/Monitor.h
src/mon/PGStatService.h [new file with mode: 0644]

index a3485e561878ecf60b45ef4802b7ad6bc2b785ca..bb1cf4a3b4131ddd1390d8704da92f5b68f9c825 100644 (file)
@@ -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());
-  pg_map = m->pg_map;
+  mon->pgservice.reset(m->pg_map);
   return true;
 }
 
index e0d82177473a3c0c7a60a9ed4d76c18434499bf1..d45d853ceb56904d12d32b9fd1ff4a15432ed16f 100644 (file)
@@ -15,7 +15,6 @@
 #include "include/Context.h"
 #include "MgrMap.h"
 #include "PaxosService.h"
-#include "PGMap.h"
 
 
 class MgrMonitor : public PaxosService
@@ -43,7 +42,6 @@ class MgrMonitor : public PaxosService
   bool check_caps(MonOpRequestRef op, const uuid_d& fsid);
 
 public:
-  PGMap pg_map;
   MgrMonitor(Monitor *mn, Paxos *p, const string& service_name)
     : PaxosService(mn, p, service_name)
   {}
index 69bb9dbc0b9e768be22cba1c6c1b99ecf42e8766..9d61a0a6606951b33b68f8b68c4f93d0a1c94d9f 100644 (file)
@@ -2576,7 +2576,7 @@ void Monitor::get_cluster_status(stringstream &ss, Formatter *f)
     osdmon()->osdmap.print_summary(f, cout);
     f->close_section();
     f->open_object_section("pgmap");
-    mgrmon()->pg_map.print_summary(f, NULL);
+    pgservice.print_summary(f, NULL);
     f->close_section();
     f->open_object_section("fsmap");
     mdsmon()->get_fsmap().print_summary(f, NULL);
@@ -2620,7 +2620,7 @@ void Monitor::get_cluster_status(stringstream &ss, Formatter *f)
     osdmon()->osdmap.print_summary(NULL, ss);
 
     ss << "\n \n  data:\n";
-    mgrmon()->pg_map.print_summary(NULL, &ss);
+    pgservice.print_summary(NULL, &ss);
     ss << "\n ";
   }
 }
@@ -3086,10 +3086,10 @@ void Monitor::handle_command(MonOpRequestRef op)
       if (f)
         f->open_object_section("stats");
 
-      mgrmon()->pg_map.dump_fs_stats(&ds, f.get(), verbose);
+      pgservice.dump_fs_stats(&ds, f.get(), verbose);
       if (!f)
         ds << '\n';
-      mgrmon()->pg_map.dump_pool_stats(osdmon()->osdmap, &ds, f.get(), verbose);
+      pgservice.dump_pool_stats(osdmon()->osdmap, &ds, f.get(), verbose);
 
       if (f) {
         f->close_section();
index 3f8b5950888e0d127191afd5cf58fee33a22b35b..1ec82242e7056c75eeaeac804718043157cab7d7 100644 (file)
@@ -35,6 +35,7 @@
 #include "Elector.h"
 #include "Paxos.h"
 #include "Session.h"
+#include "PGStatService.h"
 
 #include "common/LogClient.h"
 #include "auth/cephx/CephxKeyServer.h"
@@ -169,6 +170,8 @@ public:
   MgrClient mgr_client;
   uint64_t mgr_proxy_bytes = 0;  // in-flight proxied mgr command message bytes
 
+  PGStatService pgservice;
+
 private:
   void new_tick();
 
diff --git a/src/mon/PGStatService.h b/src/mon/PGStatService.h
new file mode 100644 (file)
index 0000000..ad13a17
--- /dev/null
@@ -0,0 +1,48 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2017 Greg Farnum/Red Hat <gfarnum@redhat.com>
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation.  See file COPYING.
+ *
+ */
+
+/**
+ * This service abstracts out the specific implementation providing information
+ * needed by parts of the Monitor based around PGStats. This'll make for
+ * an easier transition from the PGMonitor-based queries where we handle
+ * PGStats directly, to where we are getting information passed in from
+ * the Ceph Manager.
+ *
+ * This initial implementation cheats by wrapping a PGMap so we don't need
+ * to reimplement everything in one go.
+ */
+
+#ifndef CEPH_PGSTATSERVICE_H
+#define CEPH_PGSTATSERVICE_H
+
+#include "mon/PGMap.h"
+
+class PGStatService : public PGMap {
+  PGMap& parent;
+public:
+  PGStatService() : PGMap(),
+                   parent(*static_cast<PGMap*>(this)) {}
+  PGStatService(const PGMap& o) : PGMap(o),
+                                 parent(*static_cast<PGMap*>(this)) {}
+  PGStatService& operator=(const PGMap& o) {
+    reset(o);
+    return *this;
+  }
+  void reset(const PGMap& o) {
+    parent = o;
+  }
+};
+
+
+#endif