summaryrefslogtreecommitdiffstats
path: root/src/mon/ConfigMonitor.h
blob: d46d8b9de726868379a71d6bde2249ae9a3ad9c3 (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
46
47
48
49
50
51
52
53
54
55
56
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab

#pragma once

#include <boost/optional.hpp>

#include "ConfigMap.h"
#include "mon/PaxosService.h"

class MonSession;

class ConfigMonitor : public PaxosService
{
  version_t version = 0;
  ConfigMap config_map;
  map<string,boost::optional<bufferlist>> pending;
  string pending_description;
  map<string,boost::optional<bufferlist>> pending_cleanup;

  map<string,bufferlist> current;

public:
  ConfigMonitor(Monitor *m, Paxos *p, const string& service_name);

  void init() override;

  void load_config();
  void load_changeset(version_t v, ConfigChangeSet *ch);

  bool preprocess_query(MonOpRequestRef op) override;
  bool prepare_update(MonOpRequestRef op) override;

  bool preprocess_command(MonOpRequestRef op);
  bool prepare_command(MonOpRequestRef op);

  void handle_get_config(MonOpRequestRef op);

  void create_initial() override;
  void update_from_paxos(bool *need_bootstrap) override;
  void create_pending() override;
  void encode_pending(MonitorDBStore::TransactionRef t) override;
  version_t get_trim_to() const override;

  void encode_full(MonitorDBStore::TransactionRef t) override { }

  void on_active() override;
  void tick() override;

  bool refresh_config(MonSession *s);
  bool maybe_send_config(MonSession *s);
  void send_config(MonSession *s);
  void check_sub(MonSession *s);
  void check_sub(Subscription *sub);
  void check_all_subs();
};