]> git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MMonCommandAck.h
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / messages / MMonCommandAck.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_MMONCOMMANDACK_H
16 #define CEPH_MMONCOMMANDACK_H
17
18 #include "messages/PaxosServiceMessage.h"
19
20 using ceph::common::cmdmap_from_json;
21 using ceph::common::cmd_getval;
22
23 class MMonCommandAck final : public PaxosServiceMessage {
24 public:
25 std::vector<std::string> cmd;
26 errorcode32_t r;
27 std::string rs;
28
29 MMonCommandAck() : PaxosServiceMessage{MSG_MON_COMMAND_ACK, 0} {}
30 MMonCommandAck(const std::vector<std::string>& c, int _r, std::string s, version_t v) :
31 PaxosServiceMessage{MSG_MON_COMMAND_ACK, v},
32 cmd(c), r(_r), rs(s) { }
33 private:
34 ~MMonCommandAck() final {}
35
36 public:
37 std::string_view get_type_name() const override { return "mon_command"; }
38 void print(std::ostream& o) const override {
39 cmdmap_t cmdmap;
40 std::ostringstream ss;
41 std::string prefix;
42 cmdmap_from_json(cmd, &cmdmap, ss);
43 cmd_getval(cmdmap, "prefix", prefix);
44 // Some config values contain sensitive data, so don't log them
45 o << "mon_command_ack(";
46 if (prefix == "config set") {
47 std::string name;
48 cmd_getval(cmdmap, "name", name);
49 o << "[{prefix=" << prefix
50 << ", name=" << name << "}]"
51 << "=" << r << " " << rs << " v" << version << ")";
52 } else if (prefix == "config-key set") {
53 std::string key;
54 cmd_getval(cmdmap, "key", key);
55 o << "[{prefix=" << prefix << ", key=" << key << "}]"
56 << "=" << r << " " << rs << " v" << version << ")";
57 } else {
58 o << cmd;
59 }
60 o << "=" << r << " " << rs << " v" << version << ")";
61 }
62
63 void encode_payload(uint64_t features) override {
64 using ceph::encode;
65 paxos_encode();
66 encode(r, payload);
67 encode(rs, payload);
68 encode(cmd, payload);
69 }
70 void decode_payload() override {
71 using ceph::decode;
72 auto p = payload.cbegin();
73 paxos_decode(p);
74 decode(r, p);
75 decode(rs, p);
76 decode(cmd, p);
77 }
78 private:
79 template<class T, typename... Args>
80 friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
81 };
82
83 #endif