From d9dfb436ea588a43be135a0808b28039d9ca2546 Mon Sep 17 00:00:00 2001 From: John Spray Date: Sun, 3 Jul 2016 19:45:28 +0100 Subject: [PATCH] mgr: s/DaemonMetadata/DaemonState/g Signed-off-by: John Spray --- src/CMakeLists.txt | 2 +- src/mgr/DaemonServer.cc | 6 ++-- src/mgr/DaemonServer.h | 6 ++-- src/mgr/{DaemonMetadata.cc => DaemonState.cc} | 18 +++++----- src/mgr/{DaemonMetadata.h => DaemonState.h} | 36 +++++++++---------- src/mgr/Mgr.cc | 14 ++++---- src/mgr/Mgr.h | 4 +-- src/mgr/PyModules.cc | 2 +- src/mgr/PyModules.h | 8 ++--- 9 files changed, 47 insertions(+), 49 deletions(-) rename src/mgr/{DaemonMetadata.cc => DaemonState.cc} (83%) rename src/mgr/{DaemonMetadata.h => DaemonState.h} (76%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index de1713c0ebb6f..5a73b26053fbd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -517,7 +517,7 @@ add_subdirectory(libradosstriper) if (WITH_MGR) set(mgr_srcs ceph_mgr.cc - mgr/DaemonMetadata.cc + mgr/DaemonState.cc mgr/DaemonServer.cc mgr/ClusterState.cc mgr/PyModules.cc diff --git a/src/mgr/DaemonServer.cc b/src/mgr/DaemonServer.cc index bfd551d12257d..b2f7882ea3484 100644 --- a/src/mgr/DaemonServer.cc +++ b/src/mgr/DaemonServer.cc @@ -23,7 +23,7 @@ #define dout_prefix *_dout << "mgr.server " << __func__ << " " DaemonServer::DaemonServer(MonClient *monc_, - DaemonMetadataIndex &daemon_state_, + DaemonStateIndex &daemon_state_, PyModules &py_modules_) : Dispatcher(g_ceph_context), msgr(nullptr), monc(monc_), daemon_state(daemon_state_), @@ -166,11 +166,11 @@ bool DaemonServer::handle_report(MMgrReport *m) dout(4) << "from " << m->get_connection() << " name " << m->daemon_name << dendl; - DaemonMetadataPtr daemon; + DaemonStatePtr daemon; if (daemon_state.exists(key)) { daemon = daemon_state.get(key); } else { - daemon = std::make_shared(daemon_state.types); + daemon = std::make_shared(daemon_state.types); // FIXME: crap, we don't know the hostname at this stage. daemon->key = key; daemon_state.insert(daemon); diff --git a/src/mgr/DaemonServer.h b/src/mgr/DaemonServer.h index ab93574360024..f37e7f015b624 100644 --- a/src/mgr/DaemonServer.h +++ b/src/mgr/DaemonServer.h @@ -26,7 +26,7 @@ #include "auth/AuthAuthorizeHandler.h" -#include "DaemonMetadata.h" +#include "DaemonState.h" class MMgrReport; class MMgrOpen; @@ -42,7 +42,7 @@ class DaemonServer : public Dispatcher protected: Messenger *msgr; MonClient *monc; - DaemonMetadataIndex &daemon_state; + DaemonStateIndex &daemon_state; PyModules &py_modules; AuthAuthorizeHandlerRegistry auth_registry; @@ -57,7 +57,7 @@ public: entity_addr_t get_myaddr() const; DaemonServer(MonClient *monc_, - DaemonMetadataIndex &daemon_state_, + DaemonStateIndex &daemon_state_, PyModules &py_modules_); ~DaemonServer(); diff --git a/src/mgr/DaemonMetadata.cc b/src/mgr/DaemonState.cc similarity index 83% rename from src/mgr/DaemonMetadata.cc rename to src/mgr/DaemonState.cc index 7ac0e3cb611a8..9ec95ffbfb037 100644 --- a/src/mgr/DaemonMetadata.cc +++ b/src/mgr/DaemonState.cc @@ -11,13 +11,13 @@ * Foundation. See file COPYING. */ -#include "DaemonMetadata.h" +#include "DaemonState.h" #define dout_subsys ceph_subsys_mgr #undef dout_prefix #define dout_prefix *_dout << "mgr " << __func__ << " " -void DaemonMetadataIndex::insert(DaemonMetadataPtr dm) +void DaemonStateIndex::insert(DaemonStatePtr dm) { Mutex::Locker l(lock); @@ -29,7 +29,7 @@ void DaemonMetadataIndex::insert(DaemonMetadataPtr dm) all[dm->key] = dm; } -void DaemonMetadataIndex::_erase(DaemonKey dmk) +void DaemonStateIndex::_erase(DaemonKey dmk) { assert(lock.is_locked_by_me()); @@ -43,11 +43,11 @@ void DaemonMetadataIndex::_erase(DaemonKey dmk) all.erase(dmk); } -DaemonMetadataCollection DaemonMetadataIndex::get_by_type(uint8_t type) const +DaemonStateCollection DaemonStateIndex::get_by_type(uint8_t type) const { Mutex::Locker l(lock); - DaemonMetadataCollection result; + DaemonStateCollection result; for (const auto &i : all) { if (i.first.first == type) { @@ -58,7 +58,7 @@ DaemonMetadataCollection DaemonMetadataIndex::get_by_type(uint8_t type) const return result; } -DaemonMetadataCollection DaemonMetadataIndex::get_by_server(const std::string &hostname) const +DaemonStateCollection DaemonStateIndex::get_by_server(const std::string &hostname) const { Mutex::Locker l(lock); @@ -69,21 +69,21 @@ DaemonMetadataCollection DaemonMetadataIndex::get_by_server(const std::string &h } } -bool DaemonMetadataIndex::exists(const DaemonKey &key) const +bool DaemonStateIndex::exists(const DaemonKey &key) const { Mutex::Locker l(lock); return all.count(key) > 0; } -DaemonMetadataPtr DaemonMetadataIndex::get(const DaemonKey &key) +DaemonStatePtr DaemonStateIndex::get(const DaemonKey &key) { Mutex::Locker l(lock); return all.at(key); } -void DaemonMetadataIndex::cull(entity_type_t daemon_type, +void DaemonStateIndex::cull(entity_type_t daemon_type, std::set names_exist) { Mutex::Locker l(lock); diff --git a/src/mgr/DaemonMetadata.h b/src/mgr/DaemonState.h similarity index 76% rename from src/mgr/DaemonMetadata.h rename to src/mgr/DaemonState.h index b5c00a9ada16a..a5aef3b3993a6 100644 --- a/src/mgr/DaemonMetadata.h +++ b/src/mgr/DaemonState.h @@ -11,10 +11,8 @@ * Foundation. See file COPYING. */ -#ifndef DAEMON_METADATA_H_ -#define DAEMON_METADATA_H_ - -// TODO: rename me to DaemonState from DaemonMetadata +#ifndef DAEMON_STATE_H_ +#define DAEMON_STATE_H_ #include #include @@ -68,7 +66,7 @@ class DaemonPerfCounters }; // The state that we store about one daemon -class DaemonMetadata +class DaemonState { public: DaemonKey key; @@ -83,14 +81,14 @@ class DaemonMetadata // The perf counters received in MMgrReport messages DaemonPerfCounters perf_counters; - DaemonMetadata(PerfCounterTypes &types_) + DaemonState(PerfCounterTypes &types_) : perf_counters(types_) { } }; -typedef std::shared_ptr DaemonMetadataPtr; -typedef std::map DaemonMetadataCollection; +typedef std::shared_ptr DaemonStatePtr; +typedef std::map DaemonStateCollection; @@ -100,11 +98,11 @@ typedef std::map DaemonMetadataCollection; * a view that can be queried by service type, ID or also * by server (aka fqdn). */ -class DaemonMetadataIndex +class DaemonStateIndex { private: - std::map by_server; - DaemonMetadataCollection all; + std::map by_server; + DaemonStateCollection all; std::set updating; @@ -112,22 +110,22 @@ class DaemonMetadataIndex public: - DaemonMetadataIndex() : lock("DaemonState") {} + DaemonStateIndex() : lock("DaemonState") {} - // FIXME: shouldn't really be public, maybe construct DaemonMetadata + // FIXME: shouldn't really be public, maybe construct DaemonState // objects internally to avoid this. PerfCounterTypes types; - void insert(DaemonMetadataPtr dm); + void insert(DaemonStatePtr dm); void _erase(DaemonKey dmk); bool exists(const DaemonKey &key) const; - DaemonMetadataPtr get(const DaemonKey &key); - DaemonMetadataCollection get_by_server(const std::string &hostname) const; - DaemonMetadataCollection get_by_type(uint8_t type) const; + DaemonStatePtr get(const DaemonKey &key); + DaemonStateCollection get_by_server(const std::string &hostname) const; + DaemonStateCollection get_by_type(uint8_t type) const; - const DaemonMetadataCollection &get_all() const {return all;} - const std::map &get_all_servers() const + const DaemonStateCollection &get_all() const {return all;} + const std::map &get_all_servers() const { return by_server; } diff --git a/src/mgr/Mgr.cc b/src/mgr/Mgr.cc index 128426c8b6260..35c6b075ba20d 100644 --- a/src/mgr/Mgr.cc +++ b/src/mgr/Mgr.cc @@ -66,18 +66,18 @@ Mgr::~Mgr() /** * Context for completion of metadata mon commands: take - * the result and stash it in DaemonMetadataIndex + * the result and stash it in DaemonStateIndex */ class MetadataUpdate : public Context { - DaemonMetadataIndex &daemon_state; + DaemonStateIndex &daemon_state; DaemonKey key; public: bufferlist outbl; std::string outs; - MetadataUpdate(DaemonMetadataIndex &daemon_state_, const DaemonKey &key_) + MetadataUpdate(DaemonStateIndex &daemon_state_, const DaemonKey &key_) : daemon_state(daemon_state_), key(key_) {} void finish(int r) @@ -97,7 +97,7 @@ public: json_spirit::mObject daemon_meta = json_result.get_obj(); - DaemonMetadataPtr dm = std::make_shared(daemon_state.types); + DaemonStatePtr dm = std::make_shared(daemon_state.types); dm->key = key; dm->hostname = daemon_meta.at("hostname").get_str(); @@ -243,7 +243,7 @@ void Mgr::load_all_metadata() continue; } - DaemonMetadataPtr dm = std::make_shared(daemon_state.types); + DaemonStatePtr dm = std::make_shared(daemon_state.types); dm->key = DaemonKey(CEPH_ENTITY_TYPE_MDS, daemon_meta.at("name").get_str()); dm->hostname = daemon_meta.at("hostname").get_str(); @@ -265,7 +265,7 @@ void Mgr::load_all_metadata() continue; } - DaemonMetadataPtr dm = std::make_shared(daemon_state.types); + DaemonStatePtr dm = std::make_shared(daemon_state.types); dm->key = DaemonKey(CEPH_ENTITY_TYPE_MON, daemon_meta.at("name").get_str()); dm->hostname = daemon_meta.at("hostname").get_str(); @@ -288,7 +288,7 @@ void Mgr::load_all_metadata() } dout(4) << osd_metadata.at("hostname").get_str() << dendl; - DaemonMetadataPtr dm = std::make_shared(daemon_state.types); + DaemonStatePtr dm = std::make_shared(daemon_state.types); dm->key = DaemonKey(CEPH_ENTITY_TYPE_OSD, stringify(osd_metadata.at("id").get_int())); dm->hostname = osd_metadata.at("hostname").get_str(); diff --git a/src/mgr/Mgr.h b/src/mgr/Mgr.h index bc33c6adfafe3..4a2ce779c8ff8 100644 --- a/src/mgr/Mgr.h +++ b/src/mgr/Mgr.h @@ -35,7 +35,7 @@ #include "DaemonServer.h" #include "PyModules.h" -#include "DaemonMetadata.h" +#include "DaemonState.h" #include "ClusterState.h" class MCommand; @@ -57,7 +57,7 @@ protected: Context *waiting_for_fs_map; PyModules py_modules; - DaemonMetadataIndex daemon_state; + DaemonStateIndex daemon_state; ClusterState cluster_state; DaemonServer server; diff --git a/src/mgr/PyModules.cc b/src/mgr/PyModules.cc index 82fd2c19f7dd5..f4b25f72e1b24 100644 --- a/src/mgr/PyModules.cc +++ b/src/mgr/PyModules.cc @@ -27,7 +27,7 @@ #define dout_prefix *_dout << "mgr " << __func__ << " " void PyModules::dump_server(const std::string &hostname, - const DaemonMetadataCollection &dmc, + const DaemonStateCollection &dmc, Formatter *f) { f->dump_string("hostname", hostname); diff --git a/src/mgr/PyModules.h b/src/mgr/PyModules.h index 3020636973152..93e373409158d 100644 --- a/src/mgr/PyModules.h +++ b/src/mgr/PyModules.h @@ -20,7 +20,7 @@ #include "common/Mutex.h" -#include "DaemonMetadata.h" +#include "DaemonState.h" #include "ClusterState.h" @@ -32,7 +32,7 @@ class PyModules protected: std::map modules; - DaemonMetadataIndex &daemon_state; + DaemonStateIndex &daemon_state; ClusterState &cluster_state; MonClient &monc; Finisher &finisher; @@ -42,7 +42,7 @@ class PyModules public: static constexpr auto config_prefix = "mgr."; - PyModules(DaemonMetadataIndex &ds, ClusterState &cs, MonClient &mc, + PyModules(DaemonStateIndex &ds, ClusterState &cs, MonClient &mc, Finisher &f) : daemon_state(ds), cluster_state(cs), monc(mc), finisher(f), lock("PyModules") @@ -76,7 +76,7 @@ public: int main(std::vector args); void dump_server(const std::string &hostname, - const DaemonMetadataCollection &dmc, + const DaemonStateCollection &dmc, Formatter *f); bool get_config(const std::string &handle, -- 2.39.5