]> git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MMgrBeacon.h
2962d9c9a1f9149f85b04bf7e89a349cd22cfa51
[ceph.git] / ceph / src / messages / MMgrBeacon.h
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"
19
20 #include "include/types.h"
21
22
23 class MMgrBeacon : public PaxosServiceMessage {
24
25 static const int HEAD_VERSION = 2;
26 static const int COMPAT_VERSION = 1;
27
28 protected:
29 uint64_t gid;
30 entity_addr_t server_addr;
31 bool available;
32 std::string name;
33 uuid_d fsid;
34
35 public:
36 MMgrBeacon()
37 : PaxosServiceMessage(MSG_MGR_BEACON, 0, HEAD_VERSION, COMPAT_VERSION),
38 gid(0), available(false)
39 {
40 }
41
42 MMgrBeacon(const uuid_d& fsid_, uint64_t gid_, const std::string &name_,
43 entity_addr_t server_addr_, bool available_)
44 : PaxosServiceMessage(MSG_MGR_BEACON, 0, HEAD_VERSION, COMPAT_VERSION),
45 gid(gid_), server_addr(server_addr_), available(available_), name(name_),
46 fsid(fsid_)
47 {
48 }
49
50 uint64_t get_gid() const { return gid; }
51 entity_addr_t get_server_addr() const { return server_addr; }
52 bool get_available() const { return available; }
53 const std::string& get_name() const { return name; }
54 const uuid_d& get_fsid() const { return fsid; }
55
56 private:
57 ~MMgrBeacon() override {}
58
59 public:
60
61 const char *get_type_name() const override { return "mgrbeacon"; }
62
63 void print(ostream& out) const override {
64 out << get_type_name() << " mgr." << name << "(" << fsid << ","
65 << gid << ", " << server_addr << ", " << available << ")";
66 }
67
68 void encode_payload(uint64_t features) override {
69 paxos_encode();
70 ::encode(server_addr, payload, features);
71 ::encode(gid, payload);
72 ::encode(available, payload);
73 ::encode(name, payload);
74 ::encode(fsid, payload);
75 }
76 void decode_payload() override {
77 bufferlist::iterator p = payload.begin();
78 paxos_decode(p);
79 ::decode(server_addr, p);
80 ::decode(gid, p);
81 ::decode(available, p);
82 ::decode(name, p);
83 if (header.version >= 2) {
84 ::decode(fsid, p);
85 }
86 }
87 };
88
89 #endif