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