]> git.proxmox.com Git - ceph.git/blob - ceph/src/mon/MgrMonitor.h
update sources to v12.1.1
[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 #ifndef CEPH_MGRMONITOR_H
15 #define CEPH_MGRMONITOR_H
16
17 #include "include/Context.h"
18 #include "MgrMap.h"
19 #include "PaxosService.h"
20
21 class MgrMonitor: public PaxosService
22 {
23 MgrMap map;
24 MgrMap pending_map;
25 bool ever_had_active_mgr = false;
26
27 utime_t first_seen_inactive;
28
29 std::map<uint64_t, ceph::coarse_mono_clock::time_point> last_beacon;
30
31 /**
32 * If a standby is available, make it active, given that
33 * there is currently no active daemon.
34 *
35 * @return true if a standby was promoted
36 */
37 bool promote_standby();
38 void drop_active();
39 void drop_standby(uint64_t gid);
40
41 Context *digest_event = nullptr;
42 void cancel_timer();
43
44 bool check_caps(MonOpRequestRef op, const uuid_d& fsid);
45
46 health_status_t should_warn_about_mgr_down();
47
48 public:
49 MgrMonitor(Monitor *mn, Paxos *p, const string& service_name)
50 : PaxosService(mn, p, service_name)
51 {}
52 ~MgrMonitor() override {}
53
54 void init() override;
55 void on_shutdown() override;
56
57 const MgrMap &get_map() const { return map; }
58
59 bool in_use() const { return map.epoch > 0; }
60
61 void create_initial() override;
62 void update_from_paxos(bool *need_bootstrap) override;
63 void create_pending() override;
64 void encode_pending(MonitorDBStore::TransactionRef t) override;
65
66 bool preprocess_query(MonOpRequestRef op) override;
67 bool prepare_update(MonOpRequestRef op) override;
68
69 bool preprocess_command(MonOpRequestRef op);
70 bool prepare_command(MonOpRequestRef op);
71
72 void encode_full(MonitorDBStore::TransactionRef t) override { }
73
74 bool preprocess_beacon(MonOpRequestRef op);
75 bool prepare_beacon(MonOpRequestRef op);
76
77 void check_sub(Subscription *sub);
78 void check_subs();
79 void send_digests();
80
81 void on_active() override;
82 void on_restart() override;
83
84 void get_health(list<pair<health_status_t,string> >& summary,
85 list<pair<health_status_t,string> > *detail,
86 CephContext *cct) const override;
87 void tick() override;
88
89 void print_summary(Formatter *f, std::ostream *ss) const;
90
91 friend class C_Updated;
92 };
93
94 #endif