]>
Commit | Line | Data |
---|---|---|
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 |
20 | using TOPNSPC::common::cmdmap_from_json; |
21 | using TOPNSPC::common::cmd_getval; | |
22 | ||
f67539c2 | 23 | class MMonCommandAck final : public PaxosServiceMessage { |
11fdf7f2 | 24 | public: |
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) { } |
33 | private: | |
f67539c2 | 34 | ~MMonCommandAck() final {} |
7c673cae FG |
35 | |
36 | public: | |
11fdf7f2 | 37 | std::string_view get_type_name() const override { return "mon_command"; } |
9f95a23c | 38 | void print(std::ostream& o) const override { |
adb31ebb | 39 | cmdmap_t cmdmap; |
f67539c2 | 40 | std::ostringstream ss; |
20effc67 | 41 | std::string prefix; |
adb31ebb TL |
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") { | |
20effc67 | 47 | std::string name; |
adb31ebb TL |
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") { | |
20effc67 | 53 | std::string key; |
adb31ebb TL |
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 |
78 | private: |
79 | template<class T, typename... Args> | |
80 | friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args); | |
7c673cae FG |
81 | }; |
82 | ||
83 | #endif |