]>
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) 2004-2006 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 | * Placement Group Monitor. Placement Groups are logical sets of objects | |
17 | * that are replicated by the same set of devices. | |
18 | */ | |
19 | ||
20 | #ifndef CEPH_PGMONITOR_H | |
21 | #define CEPH_PGMONITOR_H | |
22 | ||
23 | #include <map> | |
24 | #include <set> | |
25 | using namespace std; | |
26 | ||
27 | #include "PGMap.h" | |
28 | #include "PaxosService.h" | |
29 | #include "include/types.h" | |
30 | #include "include/utime.h" | |
31 | #include "common/histogram.h" | |
32 | #include "msg/Messenger.h" | |
33 | #include "mon/MonitorDBStore.h" | |
34 | ||
7c673cae | 35 | class MPGStats; |
31f18b77 FG |
36 | class MonPGStatService; |
37 | class PGMonStatService; | |
7c673cae FG |
38 | |
39 | class PGMonitor : public PaxosService { | |
7c673cae | 40 | PGMap pg_map; |
31f18b77 FG |
41 | std::unique_ptr<PGMonStatService> pgservice; |
42 | ||
43 | bool do_delete = false; ///< propose deleting pgmap data | |
44 | bool did_delete = false; ///< we already deleted pgmap data | |
7c673cae FG |
45 | |
46 | private: | |
47 | PGMap::Incremental pending_inc; | |
48 | ||
49 | bool check_all_pgs = false; | |
50 | ||
51 | const char *pgmap_meta_prefix; | |
52 | const char *pgmap_pg_prefix; | |
53 | const char *pgmap_osd_prefix; | |
54 | ||
55 | void create_initial() override; | |
56 | void update_from_paxos(bool *need_bootstrap) override; | |
57 | void upgrade_format() override; | |
58 | void on_upgrade() override; | |
59 | void post_paxos_update() override; | |
60 | void handle_osd_timeouts(); | |
61 | void create_pending() override; // prepare a new pending | |
62 | // propose pending update to peers | |
63 | version_t get_trim_to() override; | |
64 | void update_logger(); | |
65 | ||
66 | void encode_pending(MonitorDBStore::TransactionRef t) override; | |
67 | void read_pgmap_meta(); | |
68 | void read_pgmap_full(); | |
69 | void apply_pgmap_delta(bufferlist& bl); | |
70 | ||
71 | bool preprocess_query(MonOpRequestRef op) override; // true if processed. | |
72 | bool prepare_update(MonOpRequestRef op) override; | |
73 | ||
74 | bool preprocess_pg_stats(MonOpRequestRef op); | |
75 | bool pg_stats_have_changed(int from, const MPGStats *stats) const; | |
76 | bool prepare_pg_stats(MonOpRequestRef op); | |
77 | void _updated_stats(MonOpRequestRef op, MonOpRequestRef ack_op); | |
78 | ||
79 | struct C_Stats; | |
80 | ||
7c673cae FG |
81 | bool preprocess_command(MonOpRequestRef op); |
82 | bool prepare_command(MonOpRequestRef op); | |
83 | ||
84 | // when we last received PG stats from each osd | |
85 | map<int,utime_t> last_osd_report; | |
86 | ||
87 | epoch_t send_pg_creates(int osd, Connection *con, epoch_t next); | |
88 | ||
89 | public: | |
31f18b77 FG |
90 | PGMonitor(Monitor *mn, Paxos *p, const string& service_name); |
91 | ~PGMonitor() override; | |
7c673cae FG |
92 | |
93 | void get_store_prefixes(set<string>& s) override { | |
94 | s.insert(get_service_name()); | |
95 | s.insert(pgmap_meta_prefix); | |
96 | s.insert(pgmap_pg_prefix); | |
97 | s.insert(pgmap_osd_prefix); | |
98 | } | |
99 | ||
100 | void on_restart() override; | |
101 | ||
102 | /* Courtesy function provided by PaxosService, called when an election | |
103 | * finishes and the cluster goes active. We use it here to make sure we | |
104 | * haven't lost any PGs from new pools. */ | |
105 | void on_active() override; | |
106 | ||
107 | bool should_stash_full() override { | |
108 | return false; // never | |
109 | } | |
110 | void encode_full(MonitorDBStore::TransactionRef t) override { | |
111 | assert(0 == "unimplemented encode_full"); | |
112 | } | |
113 | ||
114 | ||
115 | void tick() override; // check state, take actions | |
116 | ||
117 | void check_osd_map(epoch_t epoch); | |
118 | ||
7c673cae FG |
119 | int _warn_slow_request_histogram(const pow2_hist_t& h, string suffix, |
120 | list<pair<health_status_t,string> >& summary, | |
121 | list<pair<health_status_t,string> > *detail) const; | |
122 | ||
123 | void get_health(list<pair<health_status_t,string> >& summary, | |
124 | list<pair<health_status_t,string> > *detail, | |
125 | CephContext *cct) const override; | |
31f18b77 FG |
126 | void check_full_osd_health( |
127 | list<pair<health_status_t,string> >& summary, | |
128 | list<pair<health_status_t,string> > *detail, | |
129 | const mempool::pgmap::set<int>& s, | |
130 | const char *desc, health_status_t sev) const; | |
7c673cae FG |
131 | |
132 | void check_subs(); | |
133 | bool check_sub(Subscription *sub); | |
134 | ||
31f18b77 FG |
135 | MonPGStatService *get_pg_stat_service(); |
136 | ||
7c673cae FG |
137 | private: |
138 | // no copying allowed | |
139 | PGMonitor(const PGMonitor &rhs); | |
140 | PGMonitor &operator=(const PGMonitor &rhs); | |
141 | ||
142 | // we don't want to include gtest.h just for FRIEND_TEST | |
143 | friend class pgmonitor_dump_object_stat_sum_0_Test; | |
144 | friend class pgmonitor_dump_object_stat_sum_1_Test; | |
145 | friend class pgmonitor_dump_object_stat_sum_2_Test; | |
146 | }; | |
147 | ||
148 | #endif |