]>
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) 2013 Inktank, Inc. | |
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 | #ifndef CEPH_MMONSCRUB_H | |
14 | #define CEPH_MMONSCRUB_H | |
15 | ||
16 | #include "msg/Message.h" | |
17 | #include "mon/mon_types.h" | |
18 | ||
9f95a23c | 19 | class MMonScrub : public Message { |
11fdf7f2 TL |
20 | private: |
21 | static constexpr int HEAD_VERSION = 2; | |
22 | static constexpr int COMPAT_VERSION = 2; | |
7c673cae FG |
23 | |
24 | public: | |
25 | typedef enum { | |
26 | OP_SCRUB = 1, // leader->peon: scrub (a range of) keys | |
27 | OP_RESULT = 2, // peon->leader: result of a scrub | |
28 | } op_type_t; | |
29 | ||
30 | static const char *get_opname(op_type_t op) { | |
31 | switch (op) { | |
32 | case OP_SCRUB: return "scrub"; | |
33 | case OP_RESULT: return "result"; | |
11fdf7f2 | 34 | default: ceph_abort_msg("unknown op type"); return NULL; |
7c673cae FG |
35 | } |
36 | } | |
37 | ||
11fdf7f2 TL |
38 | op_type_t op = OP_SCRUB; |
39 | version_t version = 0; | |
7c673cae FG |
40 | ScrubResult result; |
41 | int32_t num_keys; | |
42 | pair<string,string> key; | |
43 | ||
44 | MMonScrub() | |
9f95a23c | 45 | : Message{MSG_MON_SCRUB, HEAD_VERSION, COMPAT_VERSION}, |
7c673cae FG |
46 | num_keys(-1) |
47 | { } | |
48 | ||
49 | MMonScrub(op_type_t op, version_t v, int32_t num_keys) | |
9f95a23c | 50 | : Message{MSG_MON_SCRUB, HEAD_VERSION, COMPAT_VERSION}, |
7c673cae FG |
51 | op(op), version(v), num_keys(num_keys) |
52 | { } | |
53 | ||
11fdf7f2 | 54 | std::string_view get_type_name() const override { return "mon_scrub"; } |
7c673cae FG |
55 | |
56 | void print(ostream& out) const override { | |
57 | out << "mon_scrub(" << get_opname((op_type_t)op); | |
58 | out << " v " << version; | |
59 | if (op == OP_RESULT) | |
60 | out << " " << result; | |
61 | out << " num_keys " << num_keys; | |
62 | out << " key (" << key << ")"; | |
63 | out << ")"; | |
64 | } | |
65 | ||
66 | void encode_payload(uint64_t features) override { | |
11fdf7f2 | 67 | using ceph::encode; |
7c673cae | 68 | uint8_t o = op; |
11fdf7f2 TL |
69 | encode(o, payload); |
70 | encode(version, payload); | |
71 | encode(result, payload); | |
72 | encode(num_keys, payload); | |
73 | encode(key, payload); | |
7c673cae FG |
74 | } |
75 | ||
76 | void decode_payload() override { | |
11fdf7f2 | 77 | auto p = payload.cbegin(); |
7c673cae | 78 | uint8_t o; |
11fdf7f2 | 79 | decode(o, p); |
7c673cae | 80 | op = (op_type_t)o; |
11fdf7f2 TL |
81 | decode(version, p); |
82 | decode(result, p); | |
83 | decode(num_keys, p); | |
84 | decode(key, p); | |
7c673cae | 85 | } |
9f95a23c TL |
86 | private: |
87 | template<class T, typename... Args> | |
88 | friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args); | |
7c673cae FG |
89 | }; |
90 | ||
91 | #endif /* CEPH_MMONSCRUB_H */ |