]> git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MOSDPGNotify.h
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / messages / MOSDPGNotify.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 #ifndef CEPH_MOSDPGPEERNOTIFY_H
16 #define CEPH_MOSDPGPEERNOTIFY_H
17
18 #include "msg/Message.h"
19
20 #include "osd/osd_types.h"
21
22 /*
23 * PGNotify - notify primary of my PGs and versions.
24 */
25
26 class MOSDPGNotify : public MessageInstance<MOSDPGNotify> {
27 public:
28 friend factory;
29 private:
30 static constexpr int HEAD_VERSION = 6;
31 static constexpr int COMPAT_VERSION = 6;
32
33 epoch_t epoch = 0;
34 /// query_epoch is the epoch of the query being responded to, or
35 /// the current epoch if this is not being sent in response to a
36 /// query. This allows the recipient to disregard responses to old
37 /// queries.
38 vector<pair<pg_notify_t,PastIntervals> > pg_list; // pgid -> version
39
40 public:
41 version_t get_epoch() const { return epoch; }
42 const vector<pair<pg_notify_t,PastIntervals> >& get_pg_list() const {
43 return pg_list;
44 }
45
46 MOSDPGNotify()
47 : MessageInstance(MSG_OSD_PG_NOTIFY, HEAD_VERSION, COMPAT_VERSION) {
48 set_priority(CEPH_MSG_PRIO_HIGH);
49 }
50 MOSDPGNotify(epoch_t e, vector<pair<pg_notify_t,PastIntervals> >& l)
51 : MessageInstance(MSG_OSD_PG_NOTIFY, HEAD_VERSION, COMPAT_VERSION),
52 epoch(e) {
53 pg_list.swap(l);
54 set_priority(CEPH_MSG_PRIO_HIGH);
55 }
56 private:
57 ~MOSDPGNotify() override {}
58
59 public:
60 std::string_view get_type_name() const override { return "PGnot"; }
61
62 void encode_payload(uint64_t features) override {
63 using ceph::encode;
64 encode(epoch, payload);
65 encode(pg_list, payload);
66 }
67
68 void decode_payload() override {
69 auto p = payload.cbegin();
70 decode(epoch, p);
71 decode(pg_list, p);
72 }
73 void print(ostream& out) const override {
74 out << "pg_notify(";
75 for (auto i = pg_list.begin();
76 i != pg_list.end();
77 ++i) {
78 if (i != pg_list.begin())
79 out << " ";
80 out << i->first << "=" << i->second;
81 }
82 out << " epoch " << epoch
83 << ")";
84 }
85 };
86
87 #endif