]> git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MOSDPGInfo.h
import quincy beta 17.1.0
[ceph.git] / ceph / src / messages / MOSDPGInfo.h
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_MOSDPGINFO_H
17 #define CEPH_MOSDPGINFO_H
18
19 #include "msg/Message.h"
20 #include "osd/osd_types.h"
21
22 class MOSDPGInfo final : public Message {
23 private:
24 static constexpr int HEAD_VERSION = 6;
25 static constexpr int COMPAT_VERSION = 6;
26
27 epoch_t epoch = 0;
28
29 public:
30 using pg_list_t = std::vector<pg_notify_t>;
31 pg_list_t pg_list;
32
33 epoch_t get_epoch() const { return epoch; }
34
35 MOSDPGInfo()
36 : MOSDPGInfo{0, {}}
37 {}
38 MOSDPGInfo(epoch_t mv)
39 : MOSDPGInfo(mv, {})
40 {}
41 MOSDPGInfo(epoch_t mv, pg_list_t&& l)
42 : Message{MSG_OSD_PG_INFO, HEAD_VERSION, COMPAT_VERSION},
43 epoch{mv},
44 pg_list{std::move(l)}
45 {
46 set_priority(CEPH_MSG_PRIO_HIGH);
47 }
48 private:
49 ~MOSDPGInfo() final {}
50
51 public:
52 std::string_view get_type_name() const override { return "pg_info"; }
53 void print(std::ostream& out) const override {
54 out << "pg_info(";
55 for (auto i = pg_list.begin();
56 i != pg_list.end();
57 ++i) {
58 if (i != pg_list.begin())
59 out << " ";
60 out << *i;
61 }
62 out << " epoch " << epoch
63 << ")";
64 }
65
66 void encode_payload(uint64_t features) override {
67 using ceph::encode;
68 header.version = HEAD_VERSION;
69 encode(epoch, payload);
70 assert(HAVE_FEATURE(features, SERVER_OCTOPUS));
71 encode(pg_list, payload);
72 }
73 void decode_payload() override {
74 using ceph::decode;
75 auto p = payload.cbegin();
76 decode(epoch, p);
77 decode(pg_list, p);
78 }
79 private:
80 template<class T, typename... Args>
81 friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
82 };
83
84 #endif