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