]>
git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MMonJoin.h
cf662f514187d9b7d732a2946069afc96aede506
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
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.
15 #ifndef CEPH_MMONJOIN_H
16 #define CEPH_MMONJOIN_H
18 #include "messages/PaxosServiceMessage.h"
20 class MMonJoin final
: public PaxosServiceMessage
{
22 static constexpr int HEAD_VERSION
= 3;
23 static constexpr int COMPAT_VERSION
= 2;
27 entity_addrvec_t addrs
;
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};
37 MMonJoin() : PaxosServiceMessage
{MSG_MON_JOIN
, 0, HEAD_VERSION
, COMPAT_VERSION
} {}
38 MMonJoin(uuid_d
&f
, std::string n
, const entity_addrvec_t
& av
)
39 : PaxosServiceMessage
{MSG_MON_JOIN
, 0, HEAD_VERSION
, COMPAT_VERSION
},
40 fsid(f
), name(n
), addrs(av
)
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
)
51 std::string_view
get_type_name() const override
{ return "mon_join"; }
52 void print(std::ostream
& o
) const override
{
53 o
<< "mon_join(" << name
<< " " << addrs
<< " " << crush_loc
<< ")";
56 void encode_payload(uint64_t features
) override
{
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
);
65 encode(crush_loc
, payload
);
66 encode(force_loc
, payload
);
69 header
.compat_version
= 1;
70 encode(addrs
.legacy_addr(), payload
, features
);
73 void decode_payload() override
{
75 auto p
= payload
.cbegin();
79 if (header
.version
== 1) {
82 addrs
= entity_addrvec_t(addr
);
85 if (header
.version
>= 3) {