]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 | ||
31f18b77 FG |
14 | #ifndef CEPH_MGRMONITOR_H |
15 | #define CEPH_MGRMONITOR_H | |
7c673cae | 16 | |
c07f9fc5 FG |
17 | #include <map> |
18 | #include <set> | |
19 | ||
7c673cae FG |
20 | #include "include/Context.h" |
21 | #include "MgrMap.h" | |
22 | #include "PaxosService.h" | |
c07f9fc5 | 23 | #include "MonCommand.h" |
7c673cae | 24 | |
31f18b77 | 25 | class MgrMonitor: public PaxosService |
7c673cae FG |
26 | { |
27 | MgrMap map; | |
28 | MgrMap pending_map; | |
224ce89b | 29 | bool ever_had_active_mgr = false; |
7c673cae | 30 | |
c07f9fc5 FG |
31 | std::map<std::string, bufferlist> pending_metadata; |
32 | std::set<std::string> pending_metadata_rm; | |
33 | ||
7c673cae FG |
34 | utime_t first_seen_inactive; |
35 | ||
31f18b77 | 36 | std::map<uint64_t, ceph::coarse_mono_clock::time_point> last_beacon; |
7c673cae FG |
37 | |
38 | /** | |
39 | * If a standby is available, make it active, given that | |
40 | * there is currently no active daemon. | |
41 | * | |
42 | * @return true if a standby was promoted | |
43 | */ | |
44 | bool promote_standby(); | |
45 | void drop_active(); | |
46 | void drop_standby(uint64_t gid); | |
47 | ||
31f18b77 FG |
48 | Context *digest_event = nullptr; |
49 | void cancel_timer(); | |
7c673cae FG |
50 | |
51 | bool check_caps(MonOpRequestRef op, const uuid_d& fsid); | |
52 | ||
224ce89b WB |
53 | health_status_t should_warn_about_mgr_down(); |
54 | ||
c07f9fc5 FG |
55 | // Command descriptions we've learned from the active mgr |
56 | std::vector<MonCommand> command_descs; | |
57 | std::vector<MonCommand> pending_command_descs; | |
58 | ||
7c673cae FG |
59 | public: |
60 | MgrMonitor(Monitor *mn, Paxos *p, const string& service_name) | |
31f18b77 | 61 | : PaxosService(mn, p, service_name) |
7c673cae | 62 | {} |
31f18b77 | 63 | ~MgrMonitor() override {} |
7c673cae FG |
64 | |
65 | void init() override; | |
66 | void on_shutdown() override; | |
67 | ||
68 | const MgrMap &get_map() const { return map; } | |
69 | ||
70 | bool in_use() const { return map.epoch > 0; } | |
71 | ||
72 | void create_initial() override; | |
73 | void update_from_paxos(bool *need_bootstrap) override; | |
74 | void create_pending() override; | |
75 | void encode_pending(MonitorDBStore::TransactionRef t) override; | |
76 | ||
77 | bool preprocess_query(MonOpRequestRef op) override; | |
78 | bool prepare_update(MonOpRequestRef op) override; | |
79 | ||
80 | bool preprocess_command(MonOpRequestRef op); | |
81 | bool prepare_command(MonOpRequestRef op); | |
82 | ||
83 | void encode_full(MonitorDBStore::TransactionRef t) override { } | |
84 | ||
85 | bool preprocess_beacon(MonOpRequestRef op); | |
86 | bool prepare_beacon(MonOpRequestRef op); | |
87 | ||
88 | void check_sub(Subscription *sub); | |
89 | void check_subs(); | |
90 | void send_digests(); | |
91 | ||
92 | void on_active() override; | |
224ce89b WB |
93 | void on_restart() override; |
94 | ||
7c673cae FG |
95 | void get_health(list<pair<health_status_t,string> >& summary, |
96 | list<pair<health_status_t,string> > *detail, | |
97 | CephContext *cct) const override; | |
98 | void tick() override; | |
99 | ||
100 | void print_summary(Formatter *f, std::ostream *ss) const; | |
101 | ||
c07f9fc5 FG |
102 | const std::vector<MonCommand> &get_command_descs() const { |
103 | return command_descs; | |
104 | } | |
105 | ||
106 | int load_metadata(const string& name, std::map<string, string>& m, | |
107 | ostream *err); | |
108 | int dump_metadata(const string& name, Formatter *f, ostream *err); | |
109 | void count_metadata(const string& field, Formatter *f); | |
110 | void count_metadata(const string& field, std::map<string,int> *out); | |
111 | ||
7c673cae FG |
112 | friend class C_Updated; |
113 | }; | |
114 | ||
31f18b77 | 115 | #endif |