]>
Commit | Line | Data |
---|---|---|
f67539c2 TL |
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_MMDSSCRUBSTATS_H | |
16 | #define CEPH_MMDSSCRUBSTATS_H | |
17 | ||
18 | #include "messages/MMDSOp.h" | |
19 | ||
20 | class MMDSScrubStats : public MMDSOp { | |
21 | static constexpr int HEAD_VERSION = 1; | |
22 | static constexpr int COMPAT_VERSION = 1; | |
23 | ||
24 | public: | |
25 | std::string_view get_type_name() const override { return "mds_scrub_stats"; } | |
20effc67 | 26 | void print(std::ostream& o) const override { |
f67539c2 TL |
27 | o << "mds_scrub_stats(e" << epoch; |
28 | if (update_scrubbing) | |
29 | o << " [" << scrubbing_tags << "]"; | |
30 | if (aborting) | |
31 | o << " aborting"; | |
32 | o << ")"; | |
33 | } | |
34 | ||
35 | unsigned get_epoch() const { return epoch; } | |
36 | const auto& get_scrubbing_tags() const { return scrubbing_tags; } | |
37 | bool is_aborting() const { return aborting; } | |
38 | bool is_finished(const std::string& tag) const { | |
39 | return update_scrubbing && !scrubbing_tags.count(tag); | |
40 | } | |
41 | ||
42 | void encode_payload(uint64_t features) override { | |
43 | using ceph::encode; | |
44 | encode(epoch, payload); | |
45 | encode(scrubbing_tags, payload); | |
46 | encode(update_scrubbing, payload); | |
47 | encode(aborting, payload); | |
48 | } | |
49 | void decode_payload() override { | |
50 | using ceph::decode; | |
51 | auto p = payload.cbegin(); | |
52 | decode(epoch, p); | |
53 | decode(scrubbing_tags, p); | |
54 | decode(update_scrubbing, p); | |
55 | decode(aborting, p); | |
56 | } | |
57 | ||
58 | protected: | |
59 | MMDSScrubStats(unsigned e=0) : | |
60 | MMDSOp(MSG_MDS_SCRUB_STATS, HEAD_VERSION, COMPAT_VERSION), | |
61 | epoch(e) {} | |
62 | MMDSScrubStats(unsigned e, std::set<std::string>&& tags, bool abrt=false) : | |
63 | MMDSOp(MSG_MDS_SCRUB_STATS, HEAD_VERSION, COMPAT_VERSION), | |
64 | epoch(e), scrubbing_tags(std::move(tags)), update_scrubbing(true), aborting(abrt) {} | |
65 | MMDSScrubStats(unsigned e, const std::set<std::string>& tags, bool abrt=false) : | |
66 | MMDSOp(MSG_MDS_SCRUB_STATS, HEAD_VERSION, COMPAT_VERSION), | |
67 | epoch(e), scrubbing_tags(tags), update_scrubbing(true), aborting(abrt) {} | |
68 | ~MMDSScrubStats() override {} | |
69 | ||
70 | private: | |
71 | unsigned epoch; | |
72 | std::set<std::string> scrubbing_tags; | |
73 | bool update_scrubbing = false; | |
74 | bool aborting = false; | |
75 | ||
76 | template<class T, typename... Args> | |
77 | friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args); | |
20effc67 TL |
78 | template<class T, typename... Args> |
79 | friend MURef<T> crimson::make_message(Args&&... args); | |
f67539c2 TL |
80 | }; |
81 | ||
82 | #endif |