]> git.proxmox.com Git - ceph.git/blob - ceph/src/mon/KVMonitor.h
import ceph quincy 17.2.6
[ceph.git] / ceph / src / mon / KVMonitor.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #pragma once
5
6 #include <optional>
7
8 #include "mon/PaxosService.h"
9
10 class MonSession;
11
12 extern const std::string KV_PREFIX;
13
14 class KVMonitor : public PaxosService
15 {
16 version_t version = 0;
17 std::map<std::string,std::optional<ceph::buffer::list>> pending;
18
19 bool _have_prefix(const std::string &prefix);
20
21 public:
22 KVMonitor(Monitor &m, Paxos &p, const std::string& service_name);
23
24 void init() override;
25
26 void get_store_prefixes(std::set<std::string>& s) const override;
27
28 bool preprocess_command(MonOpRequestRef op);
29 bool prepare_command(MonOpRequestRef op);
30
31 bool preprocess_query(MonOpRequestRef op) override;
32 bool prepare_update(MonOpRequestRef op) override;
33
34 void create_initial() override;
35 void update_from_paxos(bool *need_bootstrap) override;
36 void create_pending() override;
37 void encode_pending(MonitorDBStore::TransactionRef t) override;
38 version_t get_trim_to() const override;
39
40 void encode_full(MonitorDBStore::TransactionRef t) override { }
41
42 void on_active() override;
43 void tick() override;
44
45 int validate_osd_destroy(const int32_t id, const uuid_d& uuid);
46 void do_osd_destroy(int32_t id, uuid_d& uuid);
47 int validate_osd_new(
48 const uuid_d& uuid,
49 const std::string& dmcrypt_key,
50 std::stringstream& ss);
51 void do_osd_new(const uuid_d& uuid, const std::string& dmcrypt_key);
52
53 void check_sub(MonSession *s);
54 void check_sub(Subscription *sub);
55 void check_all_subs();
56
57 bool maybe_send_update(Subscription *sub);
58
59
60 // used by other services to adjust kv content; note that callers MUST ensure that
61 // propose_pending() is called and a commit is forced to provide atomicity and
62 // proper subscriber notifications.
63 void enqueue_set(const std::string& key, bufferlist &v) {
64 pending[key] = v;
65 }
66 void enqueue_rm(const std::string& key) {
67 pending[key].reset();
68 }
69 };