]>
Commit | Line | Data |
---|---|---|
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 | ||
26 | class MOSDPGQuery final : public Message { | |
27 | private: | |
28 | static constexpr int HEAD_VERSION = 4; | |
29 | static constexpr int COMPAT_VERSION = 4; | |
30 | ||
31 | version_t epoch = 0; | |
32 | ||
33 | public: | |
34 | version_t get_epoch() const { return epoch; } | |
35 | using pg_list_t = std::map<spg_t, pg_query_t>; | |
36 | pg_list_t pg_list; | |
37 | ||
38 | MOSDPGQuery() : Message{MSG_OSD_PG_QUERY, | |
39 | HEAD_VERSION, | |
40 | COMPAT_VERSION} { | |
41 | set_priority(CEPH_MSG_PRIO_HIGH); | |
42 | } | |
43 | MOSDPGQuery(epoch_t e, pg_list_t&& ls) : | |
44 | Message{MSG_OSD_PG_QUERY, | |
45 | HEAD_VERSION, | |
46 | COMPAT_VERSION}, | |
47 | epoch(e), | |
48 | pg_list(std::move(ls)) { | |
49 | set_priority(CEPH_MSG_PRIO_HIGH); | |
50 | } | |
51 | private: | |
52 | ~MOSDPGQuery() final {} | |
53 | ||
54 | public: | |
55 | std::string_view get_type_name() const override { return "pg_query"; } | |
56 | void print(std::ostream& out) const override { | |
57 | out << "pg_query("; | |
58 | for (auto p = pg_list.begin(); p != pg_list.end(); ++p) { | |
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 { | |
67 | using ceph::encode; | |
68 | encode(epoch, payload); | |
69 | encode(pg_list, payload, features); | |
70 | } | |
71 | void decode_payload() override { | |
72 | using ceph::decode; | |
73 | auto p = payload.cbegin(); | |
74 | decode(epoch, p); | |
75 | decode(pg_list, p); | |
76 | } | |
77 | private: | |
78 | template<class T, typename... Args> | |
79 | friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args); | |
80 | }; | |
81 | ||
82 | #endif |