]> git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MMgrOpen.h
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / messages / MMgrOpen.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) 2016 John Spray <john.spray@redhat.com>
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_MMGROPEN_H_
16 #define CEPH_MMGROPEN_H_
17
18 #include "msg/Message.h"
19
20 class MMgrOpen : public Message {
21 private:
22 static constexpr int HEAD_VERSION = 3;
23 static constexpr int COMPAT_VERSION = 1;
24
25 public:
26
27 std::string daemon_name;
28 std::string service_name; // optional; otherwise infer from entity type
29
30 bool service_daemon = false;
31 std::map<std::string,std::string> daemon_metadata;
32 std::map<std::string,std::string> daemon_status;
33
34 // encode map<string,map<int32_t,string>> of current config
35 ceph::buffer::list config_bl;
36
37 // encode map<string,string> of compiled-in defaults
38 ceph::buffer::list config_defaults_bl;
39
40 void decode_payload() override
41 {
42 using ceph::decode;
43 auto p = payload.cbegin();
44 decode(daemon_name, p);
45 if (header.version >= 2) {
46 decode(service_name, p);
47 decode(service_daemon, p);
48 if (service_daemon) {
49 decode(daemon_metadata, p);
50 decode(daemon_status, p);
51 }
52 }
53 if (header.version >= 3) {
54 decode(config_bl, p);
55 decode(config_defaults_bl, p);
56 }
57 }
58
59 void encode_payload(uint64_t features) override {
60 using ceph::encode;
61 encode(daemon_name, payload);
62 encode(service_name, payload);
63 encode(service_daemon, payload);
64 if (service_daemon) {
65 encode(daemon_metadata, payload);
66 encode(daemon_status, payload);
67 }
68 encode(config_bl, payload);
69 encode(config_defaults_bl, payload);
70 }
71
72 std::string_view get_type_name() const override { return "mgropen"; }
73 void print(std::ostream& out) const override {
74 out << get_type_name() << "(";
75 if (service_name.length()) {
76 out << service_name;
77 } else {
78 out << ceph_entity_type_name(get_source().type());
79 }
80 out << "." << daemon_name;
81 if (service_daemon) {
82 out << " daemon";
83 }
84 out << ")";
85 }
86
87 private:
88 MMgrOpen()
89 : Message{MSG_MGR_OPEN, HEAD_VERSION, COMPAT_VERSION}
90 {}
91 using RefCountedObject::put;
92 using RefCountedObject::get;
93 template<class T, typename... Args>
94 friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
95 };
96
97 #endif
98