From: Max Kellermann Date: Wed, 13 Nov 2024 20:50:32 +0000 (+0100) Subject: mon/MgrMap: un-inline methods to reduce compile times X-Git-Tag: v21.0.0~50^2~16 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6ca7a19b7adc1c7c3d3a193888f2aeebb8b1b671;p=ceph.git mon/MgrMap: un-inline methods to reduce compile times Signed-off-by: Max Kellermann --- diff --git a/src/mon/MgrMap.cc b/src/mon/MgrMap.cc index 5845362038f2..984281d8891b 100644 --- a/src/mon/MgrMap.cc +++ b/src/mon/MgrMap.cc @@ -149,6 +149,34 @@ std::list MgrMap::ModuleInfo::generate_test_instances() return ls; } +std::set MgrMap::get_all_names() const { + std::set ls; + if (active_name.size()) { + ls.insert(active_name); + } + for (auto& p : standbys) { + ls.insert(p.second.name); + } + return ls; +} + +std::set MgrMap::get_always_on_modules() const { + unsigned rnum = to_integer(ceph_release()); + auto it = always_on_modules.find(rnum); + if (it == always_on_modules.end()) { + // ok, try the most recent release + if (always_on_modules.empty()) { + return {}; // ugh + } + --it; + if (it->first < rnum) { + return it->second; + } + return {}; // wth + } + return it->second; +} + void MgrMap::StandbyInfo::encode(ceph::buffer::list& bl) const { ENCODE_START(4, 1, bl); @@ -217,6 +245,48 @@ bool MgrMap::StandbyInfo::have_module(const std::string &module_name) const return it != available_modules.end(); } +MgrMap::MgrMap() noexcept = default; +MgrMap::~MgrMap() noexcept = default; + +MgrMap MgrMap::create_null_mgrmap() { + MgrMap null_map; + /* Use the largest epoch so it's always bigger than whatever the mgr has. */ + null_map.epoch = std::numeric_limits::max(); + return null_map; +} + +bool MgrMap::all_support_module(const std::string& module) { + if (!have_module(module)) { + return false; + } + for (auto& p : standbys) { + if (!p.second.have_module(module)) { + return false; + } + } + return true; +} + +bool MgrMap::have_module(const std::string &module_name) const +{ + for (const auto &i : available_modules) { + if (i.name == module_name) { + return true; + } + } + + return false; +} + +const MgrMap::ModuleInfo *MgrMap::get_module_info(const std::string &module_name) const { + for (const auto &i : available_modules) { + if (i.name == module_name) { + return &i; + } + } + return nullptr; +} + bool MgrMap::can_run_module(const std::string &module_name, std::string *error) const { for (const auto &i : available_modules) { diff --git a/src/mon/MgrMap.h b/src/mon/MgrMap.h index 9a9ae8f77f18..f61365f14c59 100644 --- a/src/mon/MgrMap.h +++ b/src/mon/MgrMap.h @@ -138,12 +138,10 @@ public: // running modules on the active mgr daemon. std::map services; - static MgrMap create_null_mgrmap() { - MgrMap null_map; - /* Use the largest epoch so it's always bigger than whatever the mgr has. */ - null_map.epoch = std::numeric_limits::max(); - return null_map; - } + MgrMap() noexcept; + ~MgrMap() noexcept; + + static MgrMap create_null_mgrmap(); epoch_t get_epoch() const { return epoch; } epoch_t get_last_failure_osd_epoch() const { return last_failure_osd_epoch; } @@ -154,37 +152,10 @@ public: const utime_t& get_active_change() const { return active_change; } int get_num_standby() const { return standbys.size(); } - bool all_support_module(const std::string& module) { - if (!have_module(module)) { - return false; - } - for (auto& p : standbys) { - if (!p.second.have_module(module)) { - return false; - } - } - return true; - } - - bool have_module(const std::string &module_name) const - { - for (const auto &i : available_modules) { - if (i.name == module_name) { - return true; - } - } + bool all_support_module(const std::string& module); - return false; - } - - const ModuleInfo *get_module_info(const std::string &module_name) const { - for (const auto &i : available_modules) { - if (i.name == module_name) { - return &i; - } - } - return nullptr; - } + bool have_module(const std::string &module_name) const; + const ModuleInfo *get_module_info(const std::string &module_name) const; bool can_run_module(const std::string &module_name, std::string *error) const; @@ -217,33 +188,8 @@ public: return false; } - std::set get_all_names() const { - std::set ls; - if (active_name.size()) { - ls.insert(active_name); - } - for (auto& p : standbys) { - ls.insert(p.second.name); - } - return ls; - } - - std::set get_always_on_modules() const { - unsigned rnum = to_integer(ceph_release()); - auto it = always_on_modules.find(rnum); - if (it == always_on_modules.end()) { - // ok, try the most recent release - if (always_on_modules.empty()) { - return {}; // ugh - } - --it; - if (it->first < rnum) { - return it->second; - } - return {}; // wth - } - return it->second; - } + std::set get_all_names() const; + std::set get_always_on_modules() const; void encode(ceph::buffer::list& bl, uint64_t features) const; void decode(ceph::buffer::list::const_iterator& p);