]> git.proxmox.com Git - ceph.git/blame - ceph/src/messages/MMonJoin.h
import ceph pacific 16.2.5
[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
f67539c2 20class MMonJoin final : public PaxosServiceMessage {
11fdf7f2 21public:
b3b6e05e 22 static constexpr int HEAD_VERSION = 3;
11fdf7f2
TL
23 static constexpr int COMPAT_VERSION = 2;
24
7c673cae 25 uuid_d fsid;
f67539c2 26 std::string name;
11fdf7f2 27 entity_addrvec_t addrs;
b3b6e05e
TL
28 /* The location members are for stretch mode. crush_loc is the location
29 * (generally just a "datacenter=<foo>" statement) of the monitor. The
30 * force_loc is whether the mon cluster should replace a previously-known
31 * location. Generally the monitor will force an update if it's given a
32 * location from the CLI on boot-up, and then never force again (so that it
33 * can be moved/updated via the ceph tool from elsewhere). */
34 map<string,string> crush_loc;
35 bool force_loc{false};
7c673cae 36
9f95a23c 37 MMonJoin() : PaxosServiceMessage{MSG_MON_JOIN, 0, HEAD_VERSION, COMPAT_VERSION} {}
f67539c2 38 MMonJoin(uuid_d &f, std::string n, const entity_addrvec_t& av)
9f95a23c 39 : PaxosServiceMessage{MSG_MON_JOIN, 0, HEAD_VERSION, COMPAT_VERSION},
11fdf7f2 40 fsid(f), name(n), addrs(av)
7c673cae 41 { }
b3b6e05e
TL
42 MMonJoin(uuid_d &f, std::string n, const entity_addrvec_t& av, const map<string,string>& cloc, bool force)
43 : PaxosServiceMessage{MSG_MON_JOIN, 0, HEAD_VERSION, COMPAT_VERSION},
44 fsid(f), name(n), addrs(av), crush_loc(cloc), force_loc(force)
45 { }
7c673cae
FG
46
47private:
f67539c2 48 ~MMonJoin() final {}
7c673cae 49
f67539c2 50public:
11fdf7f2 51 std::string_view get_type_name() const override { return "mon_join"; }
f67539c2 52 void print(std::ostream& o) const override {
b3b6e05e 53 o << "mon_join(" << name << " " << addrs << " " << crush_loc << ")";
7c673cae 54 }
f67539c2 55
7c673cae 56 void encode_payload(uint64_t features) override {
11fdf7f2 57 using ceph::encode;
7c673cae 58 paxos_encode();
11fdf7f2
TL
59 encode(fsid, payload);
60 encode(name, payload);
61 if (HAVE_FEATURE(features, SERVER_NAUTILUS)) {
62 header.version = HEAD_VERSION;
63 header.compat_version = COMPAT_VERSION;
64 encode(addrs, payload, features);
b3b6e05e
TL
65 encode(crush_loc, payload);
66 encode(force_loc, payload);
11fdf7f2
TL
67 } else {
68 header.version = 1;
69 header.compat_version = 1;
70 encode(addrs.legacy_addr(), payload, features);
71 }
7c673cae
FG
72 }
73 void decode_payload() override {
f67539c2 74 using ceph::decode;
11fdf7f2 75 auto p = payload.cbegin();
7c673cae 76 paxos_decode(p);
11fdf7f2
TL
77 decode(fsid, p);
78 decode(name, p);
79 if (header.version == 1) {
80 entity_addr_t addr;
81 decode(addr, p);
82 addrs = entity_addrvec_t(addr);
83 } else {
84 decode(addrs, p);
b3b6e05e
TL
85 if (header.version >= 3) {
86 decode(crush_loc, p);
87 decode(force_loc, p);
88 }
11fdf7f2 89 }
7c673cae
FG
90 }
91};
92
93#endif