]>
Commit | Line | Data |
---|---|---|
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_MMGRBEACON_H | |
16 | #define CEPH_MMGRBEACON_H | |
17 | ||
18 | #include "messages/PaxosServiceMessage.h" | |
c07f9fc5 | 19 | #include "mon/MonCommand.h" |
7c673cae FG |
20 | |
21 | #include "include/types.h" | |
22 | ||
23 | ||
24 | class MMgrBeacon : public PaxosServiceMessage { | |
25 | ||
c07f9fc5 | 26 | static const int HEAD_VERSION = 5; |
7c673cae FG |
27 | static const int COMPAT_VERSION = 1; |
28 | ||
29 | protected: | |
30 | uint64_t gid; | |
31 | entity_addr_t server_addr; | |
32 | bool available; | |
33 | std::string name; | |
34 | uuid_d fsid; | |
224ce89b | 35 | std::set<std::string> available_modules; |
c07f9fc5 FG |
36 | map<string,string> metadata; ///< misc metadata about this osd |
37 | ||
38 | // Only populated during activation | |
39 | std::vector<MonCommand> command_descs; | |
7c673cae FG |
40 | |
41 | public: | |
42 | MMgrBeacon() | |
43 | : PaxosServiceMessage(MSG_MGR_BEACON, 0, HEAD_VERSION, COMPAT_VERSION), | |
44 | gid(0), available(false) | |
45 | { | |
46 | } | |
47 | ||
48 | MMgrBeacon(const uuid_d& fsid_, uint64_t gid_, const std::string &name_, | |
224ce89b | 49 | entity_addr_t server_addr_, bool available_, |
c07f9fc5 FG |
50 | const std::set<std::string>& module_list, |
51 | map<string,string>&& metadata) | |
7c673cae FG |
52 | : PaxosServiceMessage(MSG_MGR_BEACON, 0, HEAD_VERSION, COMPAT_VERSION), |
53 | gid(gid_), server_addr(server_addr_), available(available_), name(name_), | |
c07f9fc5 | 54 | fsid(fsid_), available_modules(module_list), metadata(std::move(metadata)) |
7c673cae FG |
55 | { |
56 | } | |
57 | ||
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; } | |
224ce89b | 63 | std::set<std::string>& get_available_modules() { return available_modules; } |
c07f9fc5 FG |
64 | const std::map<std::string,std::string>& get_metadata() const { |
65 | return metadata; | |
66 | } | |
67 | ||
68 | void set_command_descs(const std::vector<MonCommand> &cmds) | |
69 | { | |
70 | command_descs = cmds; | |
71 | } | |
72 | ||
73 | const std::vector<MonCommand> &get_command_descs() | |
74 | { | |
75 | return command_descs; | |
76 | } | |
7c673cae FG |
77 | |
78 | private: | |
79 | ~MMgrBeacon() override {} | |
80 | ||
81 | public: | |
82 | ||
83 | const char *get_type_name() const override { return "mgrbeacon"; } | |
84 | ||
85 | void print(ostream& out) const override { | |
86 | out << get_type_name() << " mgr." << name << "(" << fsid << "," | |
224ce89b WB |
87 | << gid << ", " << server_addr << ", " << available |
88 | << ")"; | |
7c673cae FG |
89 | } |
90 | ||
91 | void encode_payload(uint64_t features) override { | |
92 | paxos_encode(); | |
93 | ::encode(server_addr, payload, features); | |
94 | ::encode(gid, payload); | |
95 | ::encode(available, payload); | |
96 | ::encode(name, payload); | |
97 | ::encode(fsid, payload); | |
224ce89b | 98 | ::encode(available_modules, payload); |
c07f9fc5 FG |
99 | ::encode(command_descs, payload); |
100 | ::encode(metadata, payload); | |
7c673cae FG |
101 | } |
102 | void decode_payload() override { | |
103 | bufferlist::iterator p = payload.begin(); | |
104 | paxos_decode(p); | |
105 | ::decode(server_addr, p); | |
106 | ::decode(gid, p); | |
107 | ::decode(available, p); | |
108 | ::decode(name, p); | |
109 | if (header.version >= 2) { | |
110 | ::decode(fsid, p); | |
111 | } | |
224ce89b WB |
112 | if (header.version >= 3) { |
113 | ::decode(available_modules, p); | |
114 | } | |
c07f9fc5 FG |
115 | if (header.version >= 4) { |
116 | ::decode(command_descs, p); | |
117 | } | |
118 | if (header.version >= 5) { | |
119 | ::decode(metadata, p); | |
120 | } | |
7c673cae FG |
121 | } |
122 | }; | |
123 | ||
124 | #endif |