]>
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
11 #include "include/utime.h"
12 #include "common/options.h"
13 #include "common/entity_name.h"
17 // the precedence is thus:
20 // crush location (coarse to fine, ordered by type id)
21 // daemon type (e.g., osd)
22 // device class (osd only)
23 // crush location (coarse to fine, ordered by type id)
24 // daemon name (e.g., mds.foo)
26 // Note that this means that if we have
28 // config/host:foo/a = 1
29 // config/osd/rack:foo/a = 2
31 // then we get a = 2. The osd-level config wins, even though rack
32 // is less precise than host, because the crush limiters are only
33 // resolved within a section (global, per-daemon, per-instance).
36 std::string location_type
, location_value
; ///< matches crush_location
37 std::string device_class
; ///< matches device class
40 return location_type
.size() == 0
41 && location_value
.size() == 0
42 && device_class
.size() == 0;
45 std::string
to_str() const {
47 if (location_type
.size()) {
48 r
+= location_type
+ ":" + location_value
;
50 if (device_class
.size()) {
54 r
+= "class:" + device_class
;
58 void dump(ceph::Formatter
*f
) const;
62 std::string raw_value
; ///< raw, unparsed, unvalidated value
63 const Option
*opt
; ///< the option
65 std::unique_ptr
<const Option
> unknown_opt
; ///< if fabricated for an unknown option
67 MaskedOption(const Option
*o
, bool fab
=false) : opt(o
) {
72 MaskedOption(MaskedOption
&& o
) {
73 raw_value
= std::move(o
.raw_value
);
75 mask
= std::move(o
.mask
);
76 unknown_opt
= std::move(o
.unknown_opt
);
78 const MaskedOption
& operator=(const MaskedOption
& o
) = delete;
79 const MaskedOption
& operator=(MaskedOption
&& o
) = delete;
81 /// return a precision metric (smaller is more precise)
82 int get_precision(const CrushWrapper
*crush
);
84 friend std::ostream
& operator<<(std::ostream
& out
, const MaskedOption
& o
);
86 void dump(ceph::Formatter
*f
) const;
90 std::multimap
<std::string
,MaskedOption
> options
;
95 void dump(ceph::Formatter
*f
) const;
96 std::string
get_minimal_conf() const;
101 std::map
<std::string
,Section
, std::less
<>> by_type
;
102 std::map
<std::string
,Section
, std::less
<>> by_id
;
103 std::list
<std::unique_ptr
<Option
>> stray_options
;
105 Section
*find_section(const std::string
& name
) {
106 if (name
== "global") {
109 auto i
= by_type
.find(name
);
110 if (i
!= by_type
.end()) {
113 i
= by_id
.find(name
);
114 if (i
!= by_id
.end()) {
123 stray_options
.clear();
125 void dump(ceph::Formatter
*f
) const;
126 std::map
<std::string
,std::string
,std::less
<>> generate_entity_map(
127 const EntityName
& name
,
128 const std::map
<std::string
,std::string
>& crush_location
,
129 const CrushWrapper
*crush
,
130 const std::string
& device_class
,
131 std::map
<std::string
,std::pair
<std::string
,const MaskedOption
*>> *src
=0);
134 const std::string
& key
,
137 static bool parse_mask(
138 const std::string
& in
,
139 std::string
*section
,
144 struct ConfigChangeSet
{
149 // key -> (old value, new value)
150 std::map
<std::string
,std::pair
<std::optional
<std::string
>,std::optional
<std::string
>>> diff
;
152 void dump(ceph::Formatter
*f
) const;
153 void print(std::ostream
& out
) const;