]> git.proxmox.com Git - ceph.git/blame - ceph/src/common/config_values.h
update ceph source to reef 18.2.0
[ceph.git] / ceph / src / common / config_values.h
CommitLineData
11fdf7f2
TL
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2
3#pragma once
4
5#include <cstdint>
6#include <map>
7#include <set>
8#include <string>
9#include <utility>
10
11#include "common/entity_name.h"
12#include "common/options.h"
13#include "log/SubsystemMap.h"
14#include "msg/msg_types.h"
15
16// @c ConfigValues keeps track of mappings from the config names to their values,
17// debug logging settings, and some other "unnamed" settings, like entity name of
18// the daemon.
19class ConfigValues {
9f95a23c 20 using values_t = std::map<std::string_view, std::map<int32_t,Option::value_t>>;
11fdf7f2
TL
21 values_t values;
22 // for populating md_config_impl::legacy_values in ctor
23 friend struct md_config_t;
24
25public:
26 EntityName name;
27 /// cluster name
9f95a23c 28 std::string cluster;
11fdf7f2
TL
29 ceph::logging::SubsystemMap subsys;
30 bool no_mon_config = false;
11fdf7f2
TL
31 // Set of configuration options that have changed since the last
32 // apply_changes
33 using changed_set_t = std::set<std::string>;
34 changed_set_t changed;
35
36// This macro block defines C members of the md_config_t struct
37// corresponding to the definitions in legacy_config_opts.h.
38// These C members are consumed by code that was written before
39// the new options.cc infrastructure: all newer code should
40// be consume options via explicit get() rather than C members.
41#define OPTION_OPT_INT(name) int64_t name;
42#define OPTION_OPT_LONGLONG(name) int64_t name;
43#define OPTION_OPT_STR(name) std::string name;
44#define OPTION_OPT_DOUBLE(name) double name;
45#define OPTION_OPT_FLOAT(name) double name;
46#define OPTION_OPT_BOOL(name) bool name;
47#define OPTION_OPT_ADDR(name) entity_addr_t name;
48#define OPTION_OPT_ADDRVEC(name) entity_addrvec_t name;
49#define OPTION_OPT_U32(name) uint64_t name;
50#define OPTION_OPT_U64(name) uint64_t name;
51#define OPTION_OPT_UUID(name) uuid_d name;
9f95a23c 52#define OPTION_OPT_SIZE(name) uint64_t name;
11fdf7f2
TL
53#define OPTION(name, ty) \
54 public: \
55 OPTION_##ty(name)
56#define SAFE_OPTION(name, ty) \
57 protected: \
58 OPTION_##ty(name)
20effc67 59#include "common/options/legacy_config_opts.h"
11fdf7f2
TL
60#undef OPTION_OPT_INT
61#undef OPTION_OPT_LONGLONG
62#undef OPTION_OPT_STR
63#undef OPTION_OPT_DOUBLE
64#undef OPTION_OPT_FLOAT
65#undef OPTION_OPT_BOOL
66#undef OPTION_OPT_ADDR
67#undef OPTION_OPT_ADDRVEC
68#undef OPTION_OPT_U32
69#undef OPTION_OPT_U64
70#undef OPTION_OPT_UUID
71#undef OPTION
72#undef SAFE_OPTION
73
74public:
75 enum set_value_result_t {
76 SET_NO_CHANGE,
77 SET_NO_EFFECT,
78 SET_HAVE_EFFECT,
79 };
80 /**
81 * @return true if changed, false otherwise
82 */
9f95a23c 83 set_value_result_t set_value(std::string_view key,
11fdf7f2
TL
84 Option::value_t&& value,
85 int level);
9f95a23c 86 int rm_val(const std::string_view key, int level);
11fdf7f2
TL
87 void set_logging(int which, const char* val);
88 /**
89 * @param level the level of the setting, -1 for the one with the
90 * highest-priority
91 */
9f95a23c 92 std::pair<Option::value_t, bool> get_value(const std::string_view name,
11fdf7f2
TL
93 int level) const;
94 template<typename Func> void for_each(Func&& func) const {
95 for (const auto& [name,configs] : values) {
96 func(name, configs);
97 }
98 }
9f95a23c 99 bool contains(const std::string_view key) const;
11fdf7f2 100};