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_MMGRBEACON_H
16 #define CEPH_MMGRBEACON_H
18 #include "messages/PaxosServiceMessage.h"
19 #include "mon/MonCommand.h"
21 #include "include/types.h"
24 class MMgrBeacon
: public PaxosServiceMessage
{
26 static const int HEAD_VERSION
= 5;
27 static const int COMPAT_VERSION
= 1;
31 entity_addr_t server_addr
;
35 std::set
<std::string
> available_modules
;
36 map
<string
,string
> metadata
; ///< misc metadata about this osd
38 // Only populated during activation
39 std::vector
<MonCommand
> command_descs
;
43 : PaxosServiceMessage(MSG_MGR_BEACON
, 0, HEAD_VERSION
, COMPAT_VERSION
),
44 gid(0), available(false)
48 MMgrBeacon(const uuid_d
& fsid_
, uint64_t gid_
, const std::string
&name_
,
49 entity_addr_t server_addr_
, bool available_
,
50 const std::set
<std::string
>& module_list
,
51 map
<string
,string
>&& metadata
)
52 : PaxosServiceMessage(MSG_MGR_BEACON
, 0, HEAD_VERSION
, COMPAT_VERSION
),
53 gid(gid_
), server_addr(server_addr_
), available(available_
), name(name_
),
54 fsid(fsid_
), available_modules(module_list
), metadata(std::move(metadata
))
58 uint64_t get_gid() const { return gid
; }
59 entity_addr_t
get_server_addr() const { return server_addr
; }
60 bool get_available() const { return available
; }
61 const std::string
& get_name() const { return name
; }
62 const uuid_d
& get_fsid() const { return fsid
; }
63 std::set
<std::string
>& get_available_modules() { return available_modules
; }
64 const std::map
<std::string
,std::string
>& get_metadata() const {
68 void set_command_descs(const std::vector
<MonCommand
> &cmds
)
73 const std::vector
<MonCommand
> &get_command_descs()
79 ~MMgrBeacon() override
{}
83 const char *get_type_name() const override
{ return "mgrbeacon"; }
85 void print(ostream
& out
) const override
{
86 out
<< get_type_name() << " mgr." << name
<< "(" << fsid
<< ","
87 << gid
<< ", " << server_addr
<< ", " << available
91 void encode_payload(uint64_t features
) override
{
93 ::encode(server_addr
, payload
, features
);
94 ::encode(gid
, payload
);
95 ::encode(available
, payload
);
96 ::encode(name
, payload
);
97 ::encode(fsid
, payload
);
98 ::encode(available_modules
, payload
);
99 ::encode(command_descs
, payload
);
100 ::encode(metadata
, payload
);
102 void decode_payload() override
{
103 bufferlist::iterator p
= payload
.begin();
105 ::decode(server_addr
, p
);
107 ::decode(available
, p
);
109 if (header
.version
>= 2) {
112 if (header
.version
>= 3) {
113 ::decode(available_modules
, p
);
115 if (header
.version
>= 4) {
116 ::decode(command_descs
, p
);
118 if (header
.version
>= 5) {
119 ::decode(metadata
, p
);