]>
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 | #ifndef CEPH_MPGSTATS_H | |
16 | #define CEPH_MPGSTATS_H | |
17 | ||
18 | #include "osd/osd_types.h" | |
19 | #include "messages/PaxosServiceMessage.h" | |
20 | ||
11fdf7f2 TL |
21 | class MPGStats : public MessageInstance<MPGStats, PaxosServiceMessage> { |
22 | static constexpr int HEAD_VERSION = 2; | |
23 | static constexpr int COMPAT_VERSION = 1; | |
7c673cae | 24 | public: |
11fdf7f2 TL |
25 | friend factory; |
26 | ||
7c673cae | 27 | uuid_d fsid; |
11fdf7f2 | 28 | map<pg_t, pg_stat_t> pg_stat; |
7c673cae | 29 | osd_stat_t osd_stat; |
11fdf7f2 | 30 | map<int64_t, store_statfs_t> pool_stat; |
d2e6a577 | 31 | epoch_t epoch = 0; |
7c673cae FG |
32 | utime_t had_map_for; |
33 | ||
11fdf7f2 | 34 | MPGStats() : MessageInstance(MSG_PGSTATS, 0, HEAD_VERSION, COMPAT_VERSION) {} |
7c673cae | 35 | MPGStats(const uuid_d& f, epoch_t e, utime_t had) |
11fdf7f2 | 36 | : MessageInstance(MSG_PGSTATS, 0, HEAD_VERSION, COMPAT_VERSION), |
7c673cae FG |
37 | fsid(f), |
38 | epoch(e), | |
39 | had_map_for(had) | |
40 | {} | |
41 | ||
42 | private: | |
43 | ~MPGStats() override {} | |
44 | ||
45 | public: | |
11fdf7f2 | 46 | std::string_view get_type_name() const override { return "pg_stats"; } |
7c673cae FG |
47 | void print(ostream& out) const override { |
48 | out << "pg_stats(" << pg_stat.size() << " pgs tid " << get_tid() << " v " << version << ")"; | |
49 | } | |
50 | ||
51 | void encode_payload(uint64_t features) override { | |
11fdf7f2 | 52 | using ceph::encode; |
7c673cae | 53 | paxos_encode(); |
11fdf7f2 TL |
54 | encode(fsid, payload); |
55 | encode(osd_stat, payload, features); | |
56 | encode(pg_stat, payload); | |
57 | encode(epoch, payload); | |
58 | encode(had_map_for, payload); | |
59 | encode(pool_stat, payload, features); | |
7c673cae FG |
60 | } |
61 | void decode_payload() override { | |
11fdf7f2 | 62 | auto p = payload.cbegin(); |
7c673cae | 63 | paxos_decode(p); |
11fdf7f2 TL |
64 | decode(fsid, p); |
65 | decode(osd_stat, p); | |
81eedcae TL |
66 | if (osd_stat.num_osds == 0) { |
67 | // for the benefit of legacy OSDs who don't set this field | |
68 | osd_stat.num_osds = 1; | |
69 | } | |
11fdf7f2 TL |
70 | decode(pg_stat, p); |
71 | decode(epoch, p); | |
72 | decode(had_map_for, p); | |
73 | if (header.version >= 2) | |
74 | decode(pool_stat, p); | |
7c673cae FG |
75 | } |
76 | }; | |
77 | ||
78 | #endif |