]> git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MOSDBoot.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / messages / MOSDBoot.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_MOSDBOOT_H
16 #define CEPH_MOSDBOOT_H
17
18 #include "messages/PaxosServiceMessage.h"
19
20 #include "include/ceph_features.h"
21 #include "include/types.h"
22 #include "osd/osd_types.h"
23
24 class MOSDBoot : public PaxosServiceMessage {
25 private:
26 static constexpr int HEAD_VERSION = 7;
27 static constexpr int COMPAT_VERSION = 7;
28
29 public:
30 OSDSuperblock sb;
31 entity_addrvec_t hb_back_addrs, hb_front_addrs;
32 entity_addrvec_t cluster_addrs;
33 epoch_t boot_epoch; // last epoch this daemon was added to the map (if any)
34 map<string,string> metadata; ///< misc metadata about this osd
35 uint64_t osd_features;
36
37 MOSDBoot()
38 : PaxosServiceMessage{MSG_OSD_BOOT, 0, HEAD_VERSION, COMPAT_VERSION},
39 boot_epoch(0), osd_features(0)
40 { }
41 MOSDBoot(OSDSuperblock& s, epoch_t e, epoch_t be,
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,
45 uint64_t feat)
46 : PaxosServiceMessage{MSG_OSD_BOOT, e, HEAD_VERSION, COMPAT_VERSION},
47 sb(s),
48 hb_back_addrs(hb_back_addr_ref),
49 hb_front_addrs(hb_front_addr_ref),
50 cluster_addrs(cluster_addr_ref),
51 boot_epoch(be),
52 osd_features(feat)
53 { }
54
55 private:
56 ~MOSDBoot() override { }
57
58 public:
59 std::string_view get_type_name() const override { return "osd_boot"; }
60 void print(ostream& out) const override {
61 out << "osd_boot(osd." << sb.whoami << " booted " << boot_epoch
62 << " features " << osd_features
63 << " v" << version << ")";
64 }
65
66 void encode_payload(uint64_t features) override {
67 header.version = HEAD_VERSION;
68 header.compat_version = COMPAT_VERSION;
69 using ceph::encode;
70 paxos_encode();
71 if (!HAVE_FEATURE(features, SERVER_NAUTILUS)) {
72 header.version = 6;
73 header.compat_version = 6;
74 encode(sb, payload);
75 hb_back_addrs.legacy_addr().encode(payload, features);
76 cluster_addrs.legacy_addr().encode(payload, features);
77 encode(boot_epoch, payload);
78 hb_front_addrs.legacy_addr().encode(payload, features);
79 encode(metadata, payload);
80 encode(osd_features, payload);
81 return;
82 }
83 encode(sb, payload);
84 encode(hb_back_addrs, payload, features);
85 encode(cluster_addrs, payload, features);
86 encode(boot_epoch, payload);
87 encode(hb_front_addrs, payload, features);
88 encode(metadata, payload);
89 encode(osd_features, payload);
90 }
91 void decode_payload() override {
92 auto p = payload.cbegin();
93 paxos_decode(p);
94 if (header.version < 7) {
95 entity_addr_t a;
96 decode(sb, p);
97 decode(a, p);
98 hb_back_addrs = entity_addrvec_t(a);
99 decode(a, p);
100 cluster_addrs = entity_addrvec_t(a);
101 decode(boot_epoch, p);
102 decode(a, p);
103 hb_front_addrs = entity_addrvec_t(a);
104 decode(metadata, p);
105 decode(osd_features, p);
106 return;
107 }
108 decode(sb, p);
109 decode(hb_back_addrs, p);
110 decode(cluster_addrs, p);
111 decode(boot_epoch, p);
112 decode(hb_front_addrs, p);
113 decode(metadata, p);
114 decode(osd_features, p);
115 }
116 private:
117 template<class T, typename... Args>
118 friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
119 };
120
121 #endif