]> git.proxmox.com Git - ceph.git/blob - ceph/src/mon/MgrMonitor.h
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / mon / MgrMonitor.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 /*
4 * Ceph - scalable distributed file system
5 *
6 * Copyright (C) 2016 John Spray <john.spray@redhat.com>
7 *
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
12 */
13
14
15 #include "include/Context.h"
16 #include "MgrMap.h"
17 #include "PaxosService.h"
18
19
20 class MgrMonitor : public PaxosService
21 {
22 MgrMap map;
23 MgrMap pending_map;
24
25 utime_t first_seen_inactive;
26
27 std::map<uint64_t, utime_t> last_beacon;
28
29 /**
30 * If a standby is available, make it active, given that
31 * there is currently no active daemon.
32 *
33 * @return true if a standby was promoted
34 */
35 bool promote_standby();
36 void drop_active();
37 void drop_standby(uint64_t gid);
38
39 Context *digest_callback;
40
41 bool check_caps(MonOpRequestRef op, const uuid_d& fsid);
42
43 public:
44 MgrMonitor(Monitor *mn, Paxos *p, const string& service_name)
45 : PaxosService(mn, p, service_name), digest_callback(nullptr)
46 {}
47
48 void init() override;
49 void on_shutdown() override;
50
51 const MgrMap &get_map() const { return map; }
52
53 bool in_use() const { return map.epoch > 0; }
54
55 void create_initial() override;
56 void update_from_paxos(bool *need_bootstrap) override;
57 void create_pending() override;
58 void encode_pending(MonitorDBStore::TransactionRef t) override;
59
60 bool preprocess_query(MonOpRequestRef op) override;
61 bool prepare_update(MonOpRequestRef op) override;
62
63 bool preprocess_command(MonOpRequestRef op);
64 bool prepare_command(MonOpRequestRef op);
65
66 void encode_full(MonitorDBStore::TransactionRef t) override { }
67
68 bool preprocess_beacon(MonOpRequestRef op);
69 bool prepare_beacon(MonOpRequestRef op);
70
71 void check_sub(Subscription *sub);
72 void check_subs();
73 void send_digests();
74
75 void on_active() override;
76 void get_health(list<pair<health_status_t,string> >& summary,
77 list<pair<health_status_t,string> > *detail,
78 CephContext *cct) const override;
79 void tick() override;
80
81 void print_summary(Formatter *f, std::ostream *ss) const;
82
83 friend class C_Updated;
84 };
85