From: Greg Farnum Date: Tue, 14 Mar 2017 22:43:08 +0000 (-0700) Subject: mon: outline a PGStatService to replace raw PGMap calls X-Git-Tag: ses5-milestone6~8^2~19^2~123 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=29acfa9349517ea9f37f74706c223e7243caf807;p=ceph.git mon: outline a PGStatService to replace raw PGMap calls Right now, this is a quick hack that derives from PGMap. Soon, it will be more interesting. Signed-off-by: Greg Farnum --- diff --git a/src/mon/MgrMonitor.cc b/src/mon/MgrMonitor.cc index a3485e56187..bb1cf4a3b41 100644 --- a/src/mon/MgrMonitor.cc +++ b/src/mon/MgrMonitor.cc @@ -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()); - pg_map = m->pg_map; + mon->pgservice.reset(m->pg_map); return true; } diff --git a/src/mon/MgrMonitor.h b/src/mon/MgrMonitor.h index e0d82177473..d45d853ceb5 100644 --- a/src/mon/MgrMonitor.h +++ b/src/mon/MgrMonitor.h @@ -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) {} diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 69bb9dbc0b9..9d61a0a6606 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -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(); diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index 3f8b5950888..1ec82242e70 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -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 index 00000000000..ad13a176fe8 --- /dev/null +++ b/src/mon/PGStatService.h @@ -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 + * + * 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(this)) {} + PGStatService(const PGMap& o) : PGMap(o), + parent(*static_cast(this)) {} + PGStatService& operator=(const PGMap& o) { + reset(o); + return *this; + } + void reset(const PGMap& o) { + parent = o; + } +}; + + +#endif