]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr: move DaemonState methods into .cc
authorKefu Chai <tchaikov@gmail.com>
Sun, 19 Dec 2021 06:48:07 +0000 (14:48 +0800)
committerKefu Chai <tchaikov@gmail.com>
Sun, 19 Dec 2021 07:02:45 +0000 (15:02 +0800)
for faster compilation, and for better readability.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
src/mgr/DaemonState.cc
src/mgr/DaemonState.h

index f8286c64fcb7ecccdca6fae36a79226ecd7653cd..044ddadad03c91a7aeabd4e4469ce010792a1130 100644 (file)
@@ -164,6 +164,50 @@ void DeviceState::print(ostream& out) const
   }
 }
 
+void DaemonState::set_metadata(const std::map<std::string,std::string>& m)
+{
+  devices.clear();
+  devices_bypath.clear();
+  metadata = m;
+  if (auto found = m.find("device_ids"); found != m.end()) {
+    auto& device_ids = found->second;
+    std::map<std::string,std::string> paths; // devname -> id or path
+    if (auto found = m.find("device_paths"); found != m.end()) {
+      get_str_map(found->second, &paths, ",; ");
+    }
+    for_each_pair(
+      device_ids, ",; ",
+      [&paths, this](std::string_view devname, std::string_view id) {
+       // skip blank ids
+       if (id.empty()) {
+         return;
+       }
+       // id -> devname
+       devices.emplace(id, devname);
+       if (auto path = paths.find(std::string(id)); path != paths.end()) {
+         // id -> path
+         devices_bypath.emplace(id, path->second);
+       }
+      });
+  }
+  if (auto found = m.find("hostname"); found != m.end()) {
+    hostname = found->second;
+  }
+}
+
+const std::map<std::string,std::string>& DaemonState::_get_config_defaults()
+{
+  if (config_defaults.empty() &&
+      config_defaults_bl.length()) {
+    auto p = config_defaults_bl.cbegin();
+    try {
+      decode(config_defaults, p);
+    } catch (buffer::error& e) {
+    }
+  }
+  return config_defaults;
+}
+
 void DaemonStateIndex::insert(DaemonStatePtr dm)
 {
   std::unique_lock l{lock};
index 556439afea4614b2cf3a9eb4b38987a560688266..0688db81bb1f60dc4407646b1055810bd892b642 100644 (file)
@@ -162,48 +162,8 @@ class DaemonState
     : perf_counters(types_)
   {
   }
-
-  void set_metadata(const std::map<std::string,std::string>& m) {
-    devices.clear();
-    devices_bypath.clear();
-    metadata = m;
-    if (auto found = m.find("device_ids"); found != m.end()) {
-      auto& device_ids = found->second;
-      std::map<std::string,std::string> paths; // devname -> id or path
-      if (auto found = m.find("device_paths"); found != m.end()) {
-       get_str_map(found->second, &paths, ",; ");
-      }
-      for_each_pair(
-       device_ids, ",; ",
-       [&paths, this](std::string_view devname, std::string_view id) {
-         // skip blank ids
-         if (id.empty()) {
-           return;
-         }
-         // id -> devname
-         devices.emplace(id, devname);
-         if (auto path = paths.find(std::string(id)); path != paths.end()) {
-           // id -> path
-           devices_bypath.emplace(id, path->second);
-         }
-       });
-    }
-    if (auto found = m.find("hostname"); found != m.end()) {
-      hostname = found->second;
-    }
-  }
-
-  const std::map<std::string,std::string>& _get_config_defaults() {
-    if (config_defaults.empty() &&
-       config_defaults_bl.length()) {
-      auto p = config_defaults_bl.cbegin();
-      try {
-       decode(config_defaults, p);
-      } catch (buffer::error& e) {
-      }
-    }
-    return config_defaults;
-  }
+  void set_metadata(const std::map<std::string,std::string>& m);
+  const std::map<std::string,std::string>& _get_config_defaults();
 };
 
 typedef std::shared_ptr<DaemonState> DaemonStatePtr;