]>
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 | #ifndef CEPH_MOSDPGQUERY_H | |
17 | #define CEPH_MOSDPGQUERY_H | |
18 | ||
19 | #include "common/hobject.h" | |
20 | #include "msg/Message.h" | |
21 | ||
22 | /* | |
23 | * PGQuery - query another OSD as to the contents of their PGs | |
24 | */ | |
25 | ||
f67539c2 | 26 | class MOSDPGQuery final : public Message { |
11fdf7f2 TL |
27 | private: |
28 | static constexpr int HEAD_VERSION = 4; | |
29 | static constexpr int COMPAT_VERSION = 4; | |
7c673cae | 30 | |
d2e6a577 | 31 | version_t epoch = 0; |
7c673cae FG |
32 | |
33 | public: | |
34 | version_t get_epoch() const { return epoch; } | |
9f95a23c TL |
35 | using pg_list_t = std::map<spg_t, pg_query_t>; |
36 | pg_list_t pg_list; | |
7c673cae | 37 | |
9f95a23c | 38 | MOSDPGQuery() : Message{MSG_OSD_PG_QUERY, |
7c673cae | 39 | HEAD_VERSION, |
9f95a23c | 40 | COMPAT_VERSION} { |
7c673cae FG |
41 | set_priority(CEPH_MSG_PRIO_HIGH); |
42 | } | |
9f95a23c TL |
43 | MOSDPGQuery(epoch_t e, pg_list_t&& ls) : |
44 | Message{MSG_OSD_PG_QUERY, | |
7c673cae | 45 | HEAD_VERSION, |
9f95a23c TL |
46 | COMPAT_VERSION}, |
47 | epoch(e), | |
48 | pg_list(std::move(ls)) { | |
7c673cae FG |
49 | set_priority(CEPH_MSG_PRIO_HIGH); |
50 | } | |
51 | private: | |
f67539c2 | 52 | ~MOSDPGQuery() final {} |
7c673cae FG |
53 | |
54 | public: | |
11fdf7f2 | 55 | std::string_view get_type_name() const override { return "pg_query"; } |
f67539c2 | 56 | void print(std::ostream& out) const override { |
7c673cae | 57 | out << "pg_query("; |
f67539c2 | 58 | for (auto p = pg_list.begin(); p != pg_list.end(); ++p) { |
7c673cae FG |
59 | if (p != pg_list.begin()) |
60 | out << ","; | |
61 | out << p->first; | |
62 | } | |
63 | out << " epoch " << epoch << ")"; | |
64 | } | |
65 | ||
66 | void encode_payload(uint64_t features) override { | |
11fdf7f2 TL |
67 | using ceph::encode; |
68 | encode(epoch, payload); | |
69 | encode(pg_list, payload, features); | |
7c673cae FG |
70 | } |
71 | void decode_payload() override { | |
f67539c2 | 72 | using ceph::decode; |
11fdf7f2 TL |
73 | auto p = payload.cbegin(); |
74 | decode(epoch, p); | |
75 | decode(pg_list, p); | |
7c673cae | 76 | } |
9f95a23c TL |
77 | private: |
78 | template<class T, typename... Args> | |
79 | friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args); | |
7c673cae FG |
80 | }; |
81 | ||
82 | #endif |