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"
20 #include "include/types.h"
23 class MMgrBeacon
: public PaxosServiceMessage
{
25 static const int HEAD_VERSION
= 3;
26 static const int COMPAT_VERSION
= 1;
30 entity_addr_t server_addr
;
34 std::set
<std::string
> available_modules
;
38 : PaxosServiceMessage(MSG_MGR_BEACON
, 0, HEAD_VERSION
, COMPAT_VERSION
),
39 gid(0), available(false)
43 MMgrBeacon(const uuid_d
& fsid_
, uint64_t gid_
, const std::string
&name_
,
44 entity_addr_t server_addr_
, bool available_
,
45 const std::set
<std::string
>& module_list
)
46 : PaxosServiceMessage(MSG_MGR_BEACON
, 0, HEAD_VERSION
, COMPAT_VERSION
),
47 gid(gid_
), server_addr(server_addr_
), available(available_
), name(name_
),
48 fsid(fsid_
), available_modules(module_list
)
52 uint64_t get_gid() const { return gid
; }
53 entity_addr_t
get_server_addr() const { return server_addr
; }
54 bool get_available() const { return available
; }
55 const std::string
& get_name() const { return name
; }
56 const uuid_d
& get_fsid() const { return fsid
; }
57 std::set
<std::string
>& get_available_modules() { return available_modules
; }
60 ~MMgrBeacon() override
{}
64 const char *get_type_name() const override
{ return "mgrbeacon"; }
66 void print(ostream
& out
) const override
{
67 out
<< get_type_name() << " mgr." << name
<< "(" << fsid
<< ","
68 << gid
<< ", " << server_addr
<< ", " << available
72 void encode_payload(uint64_t features
) override
{
74 ::encode(server_addr
, payload
, features
);
75 ::encode(gid
, payload
);
76 ::encode(available
, payload
);
77 ::encode(name
, payload
);
78 ::encode(fsid
, payload
);
79 ::encode(available_modules
, payload
);
81 void decode_payload() override
{
82 bufferlist::iterator p
= payload
.begin();
84 ::decode(server_addr
, p
);
86 ::decode(available
, p
);
88 if (header
.version
>= 2) {
91 if (header
.version
>= 3) {
92 ::decode(available_modules
, p
);