]> git.proxmox.com Git - ceph.git/blame - ceph/src/messages/MMonCommandAck.h
import 15.2.9
[ceph.git] / ceph / src / messages / MMonCommandAck.h
CommitLineData
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_MMONCOMMANDACK_H
16#define CEPH_MMONCOMMANDACK_H
17
18#include "messages/PaxosServiceMessage.h"
19
adb31ebb
TL
20using TOPNSPC::common::cmdmap_from_json;
21using TOPNSPC::common::cmd_getval;
22
9f95a23c 23class MMonCommandAck : public PaxosServiceMessage {
11fdf7f2 24public:
9f95a23c 25 std::vector<std::string> cmd;
7c673cae 26 errorcode32_t r;
9f95a23c
TL
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},
7c673cae
FG
32 cmd(c), r(_r), rs(s) { }
33private:
34 ~MMonCommandAck() override {}
35
36public:
11fdf7f2 37 std::string_view get_type_name() const override { return "mon_command"; }
9f95a23c 38 void print(std::ostream& o) const override {
adb31ebb
TL
39 cmdmap_t cmdmap;
40 stringstream ss;
41 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 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 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 << ")";
7c673cae
FG
61 }
62
63 void encode_payload(uint64_t features) override {
11fdf7f2 64 using ceph::encode;
7c673cae 65 paxos_encode();
11fdf7f2
TL
66 encode(r, payload);
67 encode(rs, payload);
68 encode(cmd, payload);
7c673cae
FG
69 }
70 void decode_payload() override {
9f95a23c 71 using ceph::decode;
11fdf7f2 72 auto p = payload.cbegin();
7c673cae 73 paxos_decode(p);
11fdf7f2
TL
74 decode(r, p);
75 decode(rs, p);
76 decode(cmd, p);
7c673cae 77 }
9f95a23c
TL
78private:
79 template<class T, typename... Args>
80 friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
7c673cae
FG
81};
82
83#endif