]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | ||
4 | #ifndef CEPH_CRUSH_LOCATION_H | |
5 | #define CEPH_CRUSH_LOCATION_H | |
6 | ||
9f95a23c | 7 | #include <iosfwd> |
7c673cae | 8 | #include <map> |
7c673cae | 9 | #include <string> |
1e59de90 TL |
10 | #if FMT_VERSION >= 90000 |
11 | #include <fmt/ostream.h> | |
12 | #endif | |
7c673cae | 13 | |
9f95a23c TL |
14 | #include "common/ceph_mutex.h" |
15 | #include "include/common_fwd.h" | |
7c673cae | 16 | |
1e59de90 | 17 | namespace ceph::crush { |
7c673cae | 18 | |
9f95a23c | 19 | class CrushLocation { |
7c673cae | 20 | public: |
11fdf7f2 | 21 | explicit CrushLocation(CephContext *c) : cct(c) { |
224ce89b | 22 | init_on_startup(); |
7c673cae FG |
23 | } |
24 | ||
25 | int update_from_conf(); ///< refresh from config | |
26 | int update_from_hook(); ///< call hook, if present | |
27 | int init_on_startup(); | |
28 | ||
9f95a23c TL |
29 | std::multimap<std::string,std::string> get_location() const; |
30 | ||
31 | private: | |
32 | int _parse(const std::string& s); | |
33 | CephContext *cct; | |
34 | std::multimap<std::string,std::string> loc; | |
35 | mutable ceph::mutex lock = ceph::make_mutex("CrushLocation"); | |
7c673cae FG |
36 | }; |
37 | ||
9f95a23c TL |
38 | std::ostream& operator<<(std::ostream& os, const CrushLocation& loc); |
39 | } | |
1e59de90 TL |
40 | |
41 | #if FMT_VERSION >= 90000 | |
42 | template <> struct fmt::formatter<ceph::crush::CrushLocation> : fmt::ostream_formatter {}; | |
43 | #endif | |
44 | ||
7c673cae | 45 | #endif |