]>
Commit | Line | Data |
---|---|---|
f67539c2 TL |
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 | ||
20effc67 | 6 | #include <optional> |
f67539c2 TL |
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; | |
20effc67 | 17 | std::map<std::string,std::optional<ceph::buffer::list>> pending; |
f67539c2 | 18 | |
20effc67 | 19 | bool _have_prefix(const std::string &prefix); |
f67539c2 TL |
20 | |
21 | public: | |
22 | KVMonitor(Monitor &m, Paxos &p, const std::string& service_name); | |
23 | ||
24 | void init() override; | |
25 | ||
20effc67 | 26 | void get_store_prefixes(std::set<std::string>& s) const override; |
f67539c2 TL |
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) { | |
20effc67 | 67 | pending[key].reset(); |
f67539c2 TL |
68 | } |
69 | }; |