]>
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) 2009 Sage Weil <sage@newdream.net> | |
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 | /* | |
16 | * The Monmap Monitor is used to track the monitors in the cluster. | |
17 | */ | |
18 | ||
19 | #ifndef CEPH_MONMAPMONITOR_H | |
20 | #define CEPH_MONMAPMONITOR_H | |
21 | ||
22 | #include <map> | |
23 | #include <set> | |
24 | ||
7c673cae FG |
25 | #include "include/types.h" |
26 | #include "msg/Messenger.h" | |
27 | ||
28 | #include "PaxosService.h" | |
29 | #include "MonMap.h" | |
30 | #include "MonitorDBStore.h" | |
31 | ||
7c673cae FG |
32 | class MonmapMonitor : public PaxosService { |
33 | public: | |
f67539c2 | 34 | MonmapMonitor(Monitor &mn, Paxos &p, const std::string& service_name) |
7c673cae FG |
35 | : PaxosService(mn, p, service_name) |
36 | { | |
37 | } | |
38 | MonMap pending_map; //the pending map awaiting passage | |
39 | ||
40 | void create_initial() override; | |
41 | ||
42 | void update_from_paxos(bool *need_bootstrap) override; | |
43 | ||
44 | void create_pending() override; | |
45 | ||
46 | void encode_pending(MonitorDBStore::TransactionRef t) override; | |
47 | // we always encode the full map; we have no use for full versions | |
48 | void encode_full(MonitorDBStore::TransactionRef t) override { } | |
49 | ||
50 | void on_active() override; | |
11fdf7f2 | 51 | void apply_mon_features(const mon_feature_t& features, |
9f95a23c | 52 | ceph_release_t min_mon_release); |
7c673cae | 53 | |
f67539c2 | 54 | void dump_info(ceph::Formatter *f); |
7c673cae FG |
55 | |
56 | bool preprocess_query(MonOpRequestRef op) override; | |
57 | bool prepare_update(MonOpRequestRef op) override; | |
58 | ||
59 | bool preprocess_join(MonOpRequestRef op); | |
60 | bool prepare_join(MonOpRequestRef op); | |
61 | ||
62 | bool preprocess_command(MonOpRequestRef op); | |
63 | bool prepare_command(MonOpRequestRef op); | |
64 | ||
f67539c2 | 65 | int get_monmap(ceph::buffer::list &bl); |
7c673cae FG |
66 | |
67 | /* | |
68 | * Since monitors are pretty | |
69 | * important, this implementation will just write 0.0. | |
70 | */ | |
71 | bool should_propose(double& delay) override; | |
72 | ||
7c673cae FG |
73 | void check_sub(Subscription *sub); |
74 | ||
11fdf7f2 | 75 | void tick() override; |
7c673cae FG |
76 | |
77 | private: | |
11fdf7f2 | 78 | void check_subs(); |
f67539c2 TL |
79 | ceph::buffer::list monmap_bl; |
80 | /** | |
81 | * Check validity of inputs and monitor state to | |
82 | * engage stretch mode. Designed to be used with | |
83 | * OSDMonitor::try_enable_stretch_mode() where we call both twice, | |
84 | * first with commit=false to validate. | |
85 | * @param ss: a stringstream to write errors into | |
86 | * @param okay: Filled to true if okay, false if validation fails | |
87 | * @param errcode: filled with -errno if there's a problem | |
88 | * @param commit: true if we should commit the change, false if just testing | |
89 | * @param tiebreaker_mon: the name of the monitor to declare tiebreaker | |
90 | * @param dividing_bucket: the bucket type (eg 'dc') that divides the cluster | |
91 | */ | |
92 | void try_enable_stretch_mode(stringstream& ss, bool *okay, | |
93 | int *errcode, bool commit, | |
94 | const string& tiebreaker_mon, | |
95 | const string& dividing_bucket); | |
96 | ||
97 | public: | |
98 | /** | |
99 | * Set us to degraded stretch mode. Put the dead_mons in | |
100 | * the MonMap. | |
101 | */ | |
102 | void trigger_degraded_stretch_mode(const set<string>& dead_mons); | |
103 | /** | |
104 | * Set us to healthy stretch mode: clear out the | |
105 | * down list to allow any non-tiebreaker mon to be the leader again. | |
106 | */ | |
107 | void trigger_healthy_stretch_mode(); | |
7c673cae FG |
108 | }; |
109 | ||
110 | ||
111 | #endif |