]> git.proxmox.com Git - ceph.git/blame - ceph/src/messages/MRoute.h
d/control: depend on python3-yaml for ceph-mgr
[ceph.git] / ceph / src / messages / MRoute.h
CommitLineData
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
17#ifndef CEPH_MROUTE_H
18#define CEPH_MROUTE_H
19
20#include "msg/Message.h"
21#include "include/encoding.h"
22
9f95a23c 23class MRoute : public Message {
11fdf7f2 24public:
11fdf7f2
TL
25 static constexpr int HEAD_VERSION = 3;
26 static constexpr int COMPAT_VERSION = 3;
7c673cae
FG
27
28 uint64_t session_mon_tid;
29 Message *msg;
7c673cae
FG
30 epoch_t send_osdmap_first;
31
9f95a23c 32 MRoute() : Message{MSG_ROUTE, HEAD_VERSION, COMPAT_VERSION},
7c673cae
FG
33 session_mon_tid(0),
34 msg(NULL),
35 send_osdmap_first(0) {}
36 MRoute(uint64_t t, Message *m)
9f95a23c 37 : Message{MSG_ROUTE, HEAD_VERSION, COMPAT_VERSION},
7c673cae
FG
38 session_mon_tid(t),
39 msg(m),
40 send_osdmap_first(0) {}
7c673cae
FG
41private:
42 ~MRoute() override {
43 if (msg)
44 msg->put();
45 }
46
47public:
48 void decode_payload() override {
11fdf7f2
TL
49 auto p = payload.cbegin();
50 decode(session_mon_tid, p);
51 entity_inst_t dest_unused;
52 decode(dest_unused, p);
7c673cae 53 bool m;
11fdf7f2 54 decode(m, p);
7c673cae
FG
55 if (m)
56 msg = decode_message(NULL, 0, p);
11fdf7f2 57 decode(send_osdmap_first, p);
7c673cae
FG
58 }
59 void encode_payload(uint64_t features) override {
11fdf7f2
TL
60 using ceph::encode;
61 encode(session_mon_tid, payload);
62 entity_inst_t dest_unused;
63 encode(dest_unused, payload, features);
7c673cae 64 bool m = msg ? true : false;
11fdf7f2 65 encode(m, payload);
7c673cae
FG
66 if (msg)
67 encode_message(msg, features, payload);
11fdf7f2 68 encode(send_osdmap_first, payload);
7c673cae
FG
69 }
70
11fdf7f2 71 std::string_view get_type_name() const override { return "route"; }
7c673cae
FG
72 void print(ostream& o) const override {
73 if (msg)
74 o << "route(" << *msg;
75 else
76 o << "route(no-reply";
77 if (send_osdmap_first)
78 o << " send_osdmap_first " << send_osdmap_first;
79 if (session_mon_tid)
80 o << " tid " << session_mon_tid << ")";
81 else
11fdf7f2 82 o << " tid (none)";
7c673cae 83 }
9f95a23c
TL
84private:
85 template<class T, typename... Args>
86 friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
7c673cae
FG
87};
88
89#endif