]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/MgrMap: un-inline methods to reduce compile times
authorMax Kellermann <max.kellermann@ionos.com>
Wed, 13 Nov 2024 20:50:32 +0000 (21:50 +0100)
committerMax Kellermann <max.kellermann@ionos.com>
Tue, 16 Sep 2025 10:42:05 +0000 (12:42 +0200)
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
src/mon/MgrMap.cc
src/mon/MgrMap.h

index 5845362038f2af881c76ddaf609a0bebe60a5073..984281d8891b70e02f768f85ed80f72cbf54c312 100644 (file)
@@ -149,6 +149,34 @@ std::list<MgrMap::ModuleInfo> MgrMap::ModuleInfo::generate_test_instances()
   return ls;
 }
 
+std::set<std::string> MgrMap::get_all_names() const {
+  std::set<std::string> ls;
+  if (active_name.size()) {
+    ls.insert(active_name);
+  }
+  for (auto& p : standbys) {
+    ls.insert(p.second.name);
+  }
+  return ls;
+}
+
+std::set<std::string> MgrMap::get_always_on_modules() const {
+  unsigned rnum = to_integer<uint32_t>(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<decltype(epoch)>::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) {
index 9a9ae8f77f18bfcf26454a991821cb36da8af747..f61365f14c59e716b5d2c3a3a48db18f625dc861 100644 (file)
@@ -138,12 +138,10 @@ public:
   // running modules on the active mgr daemon.
   std::map<std::string, std::string> 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<decltype(epoch)>::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<std::string> get_all_names() const {
-    std::set<std::string> ls;
-    if (active_name.size()) {
-      ls.insert(active_name);
-    }
-    for (auto& p : standbys) {
-      ls.insert(p.second.name);
-    }
-    return ls;
-  }
-
-  std::set<std::string> get_always_on_modules() const {
-    unsigned rnum = to_integer<uint32_t>(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<std::string> get_all_names() const;
+  std::set<std::string> get_always_on_modules() const;
 
   void encode(ceph::buffer::list& bl, uint64_t features) const;
   void decode(ceph::buffer::list::const_iterator& p);