summaryrefslogtreecommitdiffstats
path: root/src/crimson/common/config_proxy.cc
blob: 720fcffddae607235bb09b32e970974efd99a536 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-

#include "config_proxy.h"

namespace ceph::common {

ConfigProxy::ConfigProxy(const EntityName& name, std::string_view cluster)
{
  if (seastar::engine().cpu_id() != 0) {
    return;
  }
  // set the initial value on CPU#0
  values.reset(seastar::make_lw_shared<ConfigValues>());
  values.get()->name = name;
  values.get()->cluster = cluster;
  // and the only copy of md_config_impl<> is allocated on CPU#0
  local_config.reset(new md_config_t{*values, obs_mgr, true});
  if (name.is_mds()) {
    local_config->set_val_default(*values, obs_mgr,
				  "keyring", "$mds_data/keyring");
  } else if (name.is_osd()) {
    local_config->set_val_default(*values, obs_mgr,
				  "keyring", "$osd_data/keyring");
  }
}

seastar::future<> ConfigProxy::start()
{
  // populate values and config to all other shards
  if (!values) {
    return seastar::make_ready_future<>();
  }
  return container().invoke_on_others([this](auto& proxy) {
    return values.copy().then([config=local_config.get(),
			       &proxy](auto foreign_values) {
      proxy.values.reset();
      proxy.values = std::move(foreign_values);
      proxy.remote_config = config;
      return seastar::make_ready_future<>();
    });
  });
}

ConfigProxy::ShardedConfig ConfigProxy::sharded_conf;
}