]> git.proxmox.com Git - ceph.git/blame - ceph/src/messages/MMonJoin.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / messages / MMonJoin.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#ifndef CEPH_MMONJOIN_H
16#define CEPH_MMONJOIN_H
17
18#include "messages/PaxosServiceMessage.h"
19
20#include <vector>
21using std::vector;
22
9f95a23c 23class MMonJoin : public PaxosServiceMessage {
11fdf7f2 24public:
11fdf7f2
TL
25 static constexpr int HEAD_VERSION = 2;
26 static constexpr int COMPAT_VERSION = 2;
27
7c673cae
FG
28 uuid_d fsid;
29 string name;
11fdf7f2 30 entity_addrvec_t addrs;
7c673cae 31
9f95a23c 32 MMonJoin() : PaxosServiceMessage{MSG_MON_JOIN, 0, HEAD_VERSION, COMPAT_VERSION} {}
11fdf7f2 33 MMonJoin(uuid_d &f, string n, const entity_addrvec_t& av)
9f95a23c 34 : PaxosServiceMessage{MSG_MON_JOIN, 0, HEAD_VERSION, COMPAT_VERSION},
11fdf7f2 35 fsid(f), name(n), addrs(av)
7c673cae
FG
36 { }
37
38private:
39 ~MMonJoin() override {}
40
41public:
11fdf7f2 42 std::string_view get_type_name() const override { return "mon_join"; }
7c673cae 43 void print(ostream& o) const override {
11fdf7f2 44 o << "mon_join(" << name << " " << addrs << ")";
7c673cae
FG
45 }
46
47 void encode_payload(uint64_t features) override {
11fdf7f2 48 using ceph::encode;
7c673cae 49 paxos_encode();
11fdf7f2
TL
50 encode(fsid, payload);
51 encode(name, payload);
52 if (HAVE_FEATURE(features, SERVER_NAUTILUS)) {
53 header.version = HEAD_VERSION;
54 header.compat_version = COMPAT_VERSION;
55 encode(addrs, payload, features);
56 } else {
57 header.version = 1;
58 header.compat_version = 1;
59 encode(addrs.legacy_addr(), payload, features);
60 }
7c673cae
FG
61 }
62 void decode_payload() override {
11fdf7f2 63 auto p = payload.cbegin();
7c673cae 64 paxos_decode(p);
11fdf7f2
TL
65 decode(fsid, p);
66 decode(name, p);
67 if (header.version == 1) {
68 entity_addr_t addr;
69 decode(addr, p);
70 addrs = entity_addrvec_t(addr);
71 } else {
72 decode(addrs, p);
73 }
7c673cae
FG
74 }
75};
76
77#endif