]>
git.proxmox.com Git - ceph.git/blob - ceph/src/mon/ConfigMap.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
10 #include "include/utime.h"
11 #include "common/options.h"
12 #include "common/entity_name.h"
16 // the precedence is thus:
19 // crush location (coarse to fine, ordered by type id)
20 // daemon type (e.g., osd)
21 // device class (osd only)
22 // crush location (coarse to fine, ordered by type id)
23 // daemon name (e.g., mds.foo)
25 // Note that this means that if we have
27 // config/host:foo/a = 1
28 // config/osd/rack:foo/a = 2
30 // then we get a = 2. The osd-level config wins, even though rack
31 // is less precise than host, because the crush limiters are only
32 // resolved within a section (global, per-daemon, per-instance).
35 std::string location_type
, location_value
; ///< matches crush_location
36 std::string device_class
; ///< matches device class
39 return location_type
.size() == 0
40 && location_value
.size() == 0
41 && device_class
.size() == 0;
44 std::string
to_str() const {
46 if (location_type
.size()) {
47 r
+= location_type
+ ":" + location_value
;
49 if (device_class
.size()) {
53 r
+= "class:" + device_class
;
57 void dump(ceph::Formatter
*f
) const;
61 std::string raw_value
; ///< raw, unparsed, unvalidated value
62 const Option
*opt
; ///< the option
64 std::unique_ptr
<const Option
> unknown_opt
; ///< if fabricated for an unknown option
66 MaskedOption(const Option
*o
, bool fab
=false) : opt(o
) {
71 MaskedOption(MaskedOption
&& o
) {
72 raw_value
= std::move(o
.raw_value
);
74 mask
= std::move(o
.mask
);
75 unknown_opt
= std::move(o
.unknown_opt
);
77 const MaskedOption
& operator=(const MaskedOption
& o
) = delete;
78 const MaskedOption
& operator=(MaskedOption
&& o
) = delete;
80 /// return a precision metric (smaller is more precise)
81 int get_precision(const CrushWrapper
*crush
);
83 friend std::ostream
& operator<<(std::ostream
& out
, const MaskedOption
& o
);
85 void dump(ceph::Formatter
*f
) const;
89 std::multimap
<std::string
,MaskedOption
> options
;
94 void dump(ceph::Formatter
*f
) const;
95 std::string
get_minimal_conf() const;
100 std::map
<std::string
,Section
, std::less
<>> by_type
;
101 std::map
<std::string
,Section
, std::less
<>> by_id
;
102 std::list
<std::unique_ptr
<Option
>> stray_options
;
104 Section
*find_section(const std::string
& name
) {
105 if (name
== "global") {
108 auto i
= by_type
.find(name
);
109 if (i
!= by_type
.end()) {
112 i
= by_id
.find(name
);
113 if (i
!= by_id
.end()) {
122 stray_options
.clear();
124 void dump(ceph::Formatter
*f
) const;
125 std::map
<std::string
,std::string
,std::less
<>> generate_entity_map(
126 const EntityName
& name
,
127 const std::map
<std::string
,std::string
>& crush_location
,
128 const CrushWrapper
*crush
,
129 const std::string
& device_class
,
130 std::map
<std::string
,std::pair
<std::string
,const MaskedOption
*>> *src
=0);
133 const std::string
& key
,
136 static bool parse_mask(
137 const std::string
& in
,
138 std::string
*section
,
143 struct ConfigChangeSet
{
148 // key -> (old value, new value)
149 std::map
<std::string
,std::pair
<boost::optional
<std::string
>,boost::optional
<std::string
>>> diff
;
151 void dump(ceph::Formatter
*f
) const;
152 void print(std::ostream
& out
) const;