From: Kefu Chai Date: Sun, 19 Dec 2021 06:48:07 +0000 (+0800) Subject: mgr: move DaemonState methods into .cc X-Git-Tag: v17.1.0~180^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F44353%2Fhead;p=ceph.git mgr: move DaemonState methods into .cc for faster compilation, and for better readability. Signed-off-by: Kefu Chai --- diff --git a/src/mgr/DaemonState.cc b/src/mgr/DaemonState.cc index f8286c64fcb7..044ddadad03c 100644 --- a/src/mgr/DaemonState.cc +++ b/src/mgr/DaemonState.cc @@ -164,6 +164,50 @@ void DeviceState::print(ostream& out) const } } +void DaemonState::set_metadata(const std::map& 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 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& 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}; diff --git a/src/mgr/DaemonState.h b/src/mgr/DaemonState.h index 556439afea46..0688db81bb1f 100644 --- a/src/mgr/DaemonState.h +++ b/src/mgr/DaemonState.h @@ -162,48 +162,8 @@ class DaemonState : perf_counters(types_) { } - - void set_metadata(const std::map& 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 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& _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& m); + const std::map& _get_config_defaults(); }; typedef std::shared_ptr DaemonStatePtr;