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 = 6;
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 // From active daemon to populate MgrMap::services
39 std::map<std::string, std::string> services;
41 // Only populated during activation
42 std::vector<MonCommand> command_descs;
46 : PaxosServiceMessage(MSG_MGR_BEACON, 0, HEAD_VERSION, COMPAT_VERSION),
47 gid(0), available(false)
51 MMgrBeacon(const uuid_d& fsid_, uint64_t gid_, const std::string &name_,
52 entity_addr_t server_addr_, bool available_,
53 const std::set<std::string>& module_list,
54 map<string,string>&& metadata)
55 : PaxosServiceMessage(MSG_MGR_BEACON, 0, HEAD_VERSION, COMPAT_VERSION),
56 gid(gid_), server_addr(server_addr_), available(available_), name(name_),
57 fsid(fsid_), available_modules(module_list), metadata(std::move(metadata))
61 uint64_t get_gid() const { return gid; }
62 entity_addr_t get_server_addr() const { return server_addr; }
63 bool get_available() const { return available; }
64 const std::string& get_name() const { return name; }
65 const uuid_d& get_fsid() const { return fsid; }
66 std::set<std::string>& get_available_modules() { return available_modules; }
67 const std::map<std::string,std::string>& get_metadata() const {
71 const std::map<std::string,std::string>& get_services() const {
75 void set_services(const std::map<std::string, std::string> &svcs)
80 void set_command_descs(const std::vector<MonCommand> &cmds)
85 const std::vector<MonCommand> &get_command_descs()
91 ~MMgrBeacon() override {}
95 const char *get_type_name() const override { return "mgrbeacon"; }
97 void print(ostream& out) const override {
98 out << get_type_name() << " mgr." << name << "(" << fsid << ","
99 << gid << ", " << server_addr << ", " << available
103 void encode_payload(uint64_t features) override {
105 ::encode(server_addr, payload, features);
106 ::encode(gid, payload);
107 ::encode(available, payload);
108 ::encode(name, payload);
109 ::encode(fsid, payload);
110 ::encode(available_modules, payload);
111 ::encode(command_descs, payload);
112 ::encode(metadata, payload);
113 ::encode(services, payload);
115 void decode_payload() override {
116 bufferlist::iterator p = payload.begin();
118 ::decode(server_addr, p);
120 ::decode(available, p);
122 if (header.version >= 2) {
125 if (header.version >= 3) {
126 ::decode(available_modules, p);
128 if (header.version >= 4) {
129 ::decode(command_descs, p);
131 if (header.version >= 5) {
132 ::decode(metadata, p);
134 if (header.version >= 6) {
135 ::decode(services, p);