]>
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 | #ifndef CEPH_MOSDBOOT_H | |
16 | #define CEPH_MOSDBOOT_H | |
17 | ||
18 | #include "messages/PaxosServiceMessage.h" | |
19 | ||
11fdf7f2 | 20 | #include "include/ceph_features.h" |
7c673cae FG |
21 | #include "include/types.h" |
22 | #include "osd/osd_types.h" | |
23 | ||
f67539c2 | 24 | class MOSDBoot final : public PaxosServiceMessage { |
11fdf7f2 TL |
25 | private: |
26 | static constexpr int HEAD_VERSION = 7; | |
27 | static constexpr int COMPAT_VERSION = 7; | |
7c673cae FG |
28 | |
29 | public: | |
30 | OSDSuperblock sb; | |
11fdf7f2 TL |
31 | entity_addrvec_t hb_back_addrs, hb_front_addrs; |
32 | entity_addrvec_t cluster_addrs; | |
7c673cae | 33 | epoch_t boot_epoch; // last epoch this daemon was added to the map (if any) |
f67539c2 | 34 | std::map<std::string,std::string> metadata; ///< misc metadata about this osd |
7c673cae FG |
35 | uint64_t osd_features; |
36 | ||
37 | MOSDBoot() | |
9f95a23c | 38 | : PaxosServiceMessage{MSG_OSD_BOOT, 0, HEAD_VERSION, COMPAT_VERSION}, |
7c673cae FG |
39 | boot_epoch(0), osd_features(0) |
40 | { } | |
f67539c2 | 41 | MOSDBoot(const OSDSuperblock& s, epoch_t e, epoch_t be, |
11fdf7f2 TL |
42 | const entity_addrvec_t& hb_back_addr_ref, |
43 | const entity_addrvec_t& hb_front_addr_ref, | |
44 | const entity_addrvec_t& cluster_addr_ref, | |
7c673cae | 45 | uint64_t feat) |
9f95a23c | 46 | : PaxosServiceMessage{MSG_OSD_BOOT, e, HEAD_VERSION, COMPAT_VERSION}, |
7c673cae | 47 | sb(s), |
11fdf7f2 TL |
48 | hb_back_addrs(hb_back_addr_ref), |
49 | hb_front_addrs(hb_front_addr_ref), | |
50 | cluster_addrs(cluster_addr_ref), | |
7c673cae FG |
51 | boot_epoch(be), |
52 | osd_features(feat) | |
53 | { } | |
54 | ||
55 | private: | |
f67539c2 | 56 | ~MOSDBoot() final { } |
7c673cae FG |
57 | |
58 | public: | |
11fdf7f2 | 59 | std::string_view get_type_name() const override { return "osd_boot"; } |
f67539c2 | 60 | void print(std::ostream& out) const override { |
7c673cae FG |
61 | out << "osd_boot(osd." << sb.whoami << " booted " << boot_epoch |
62 | << " features " << osd_features | |
63 | << " v" << version << ")"; | |
64 | } | |
f67539c2 | 65 | |
7c673cae | 66 | void encode_payload(uint64_t features) override { |
11fdf7f2 TL |
67 | header.version = HEAD_VERSION; |
68 | header.compat_version = COMPAT_VERSION; | |
69 | using ceph::encode; | |
7c673cae | 70 | paxos_encode(); |
20effc67 | 71 | assert(HAVE_FEATURE(features, SERVER_NAUTILUS)); |
11fdf7f2 TL |
72 | encode(sb, payload); |
73 | encode(hb_back_addrs, payload, features); | |
74 | encode(cluster_addrs, payload, features); | |
75 | encode(boot_epoch, payload); | |
76 | encode(hb_front_addrs, payload, features); | |
77 | encode(metadata, payload); | |
78 | encode(osd_features, payload); | |
7c673cae FG |
79 | } |
80 | void decode_payload() override { | |
11fdf7f2 | 81 | auto p = payload.cbegin(); |
f67539c2 | 82 | using ceph::decode; |
7c673cae | 83 | paxos_decode(p); |
20effc67 | 84 | assert(header.version >= 7); |
11fdf7f2 TL |
85 | decode(sb, p); |
86 | decode(hb_back_addrs, p); | |
87 | decode(cluster_addrs, p); | |
88 | decode(boot_epoch, p); | |
89 | decode(hb_front_addrs, p); | |
90 | decode(metadata, p); | |
91 | decode(osd_features, p); | |
7c673cae | 92 | } |
9f95a23c TL |
93 | private: |
94 | template<class T, typename... Args> | |
95 | friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args); | |
7c673cae FG |
96 | }; |
97 | ||
98 | #endif |