]> git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MMonCommand.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / messages / MMonCommand.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_MMONCOMMAND_H
16 #define CEPH_MMONCOMMAND_H
17
18 #include "messages/PaxosServiceMessage.h"
19
20 #include <vector>
21 #include <string>
22
23 class MMonCommand : public PaxosServiceMessage {
24 public:
25 // weird note: prior to octopus, MgrClient would leave fsid blank when
26 // sending commands to the mgr. Starting with octopus, this is either
27 // populated with a valid fsid (tell command) or an MMgrCommand is sent
28 // instead.
29 uuid_d fsid;
30 std::vector<std::string> cmd;
31
32 MMonCommand() : PaxosServiceMessage{MSG_MON_COMMAND, 0} {}
33 MMonCommand(const uuid_d &f)
34 : PaxosServiceMessage{MSG_MON_COMMAND, 0},
35 fsid(f)
36 { }
37
38 private:
39 ~MMonCommand() override {}
40
41 public:
42 std::string_view get_type_name() const override { return "mon_command"; }
43 void print(std::ostream& o) const override {
44 o << "mon_command(";
45 for (unsigned i=0; i<cmd.size(); i++) {
46 if (i) o << ' ';
47 o << cmd[i];
48 }
49 o << " v " << version << ")";
50 }
51
52 void encode_payload(uint64_t features) override {
53 using ceph::encode;
54 paxos_encode();
55 encode(fsid, payload);
56 encode(cmd, payload);
57 }
58 void decode_payload() override {
59 using ceph::decode;
60 auto p = payload.cbegin();
61 paxos_decode(p);
62 decode(fsid, p);
63 decode(cmd, p);
64 }
65 private:
66 template<class T, typename... Args>
67 friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
68 };
69
70 #endif