summaryrefslogtreecommitdiffstats
path: root/src/messages/MMonScrub.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
commite6918187568dbd01842d8d1d2c808ce16a894239 (patch)
tree64f88b554b444a49f656b6c656111a145cbbaa28 /src/messages/MMonScrub.h
parentInitial commit. (diff)
downloadceph-e6918187568dbd01842d8d1d2c808ce16a894239.tar.xz
ceph-e6918187568dbd01842d8d1d2c808ce16a894239.zip
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/messages/MMonScrub.h')
-rw-r--r--src/messages/MMonScrub.h92
1 files changed, 92 insertions, 0 deletions
diff --git a/src/messages/MMonScrub.h b/src/messages/MMonScrub.h
new file mode 100644
index 000000000..b3b99b43f
--- /dev/null
+++ b/src/messages/MMonScrub.h
@@ -0,0 +1,92 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+* Ceph - scalable distributed file system
+*
+* Copyright (C) 2013 Inktank, Inc.
+*
+* This is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License version 2.1, as published by the Free Software
+* Foundation. See file COPYING.
+*/
+#ifndef CEPH_MMONSCRUB_H
+#define CEPH_MMONSCRUB_H
+
+#include "msg/Message.h"
+#include "mon/mon_types.h"
+
+class MMonScrub : public Message {
+private:
+ static constexpr int HEAD_VERSION = 2;
+ static constexpr int COMPAT_VERSION = 2;
+
+public:
+ typedef enum {
+ OP_SCRUB = 1, // leader->peon: scrub (a range of) keys
+ OP_RESULT = 2, // peon->leader: result of a scrub
+ } op_type_t;
+
+ static const char *get_opname(op_type_t op) {
+ switch (op) {
+ case OP_SCRUB: return "scrub";
+ case OP_RESULT: return "result";
+ default: ceph_abort_msg("unknown op type"); return NULL;
+ }
+ }
+
+ op_type_t op = OP_SCRUB;
+ version_t version = 0;
+ ScrubResult result;
+ int32_t num_keys;
+ std::pair<std::string,std::string> key;
+
+ MMonScrub()
+ : Message{MSG_MON_SCRUB, HEAD_VERSION, COMPAT_VERSION},
+ num_keys(-1)
+ { }
+
+ MMonScrub(op_type_t op, version_t v, int32_t num_keys)
+ : Message{MSG_MON_SCRUB, HEAD_VERSION, COMPAT_VERSION},
+ op(op), version(v), num_keys(num_keys)
+ { }
+
+ std::string_view get_type_name() const override { return "mon_scrub"; }
+
+ void print(std::ostream& out) const override {
+ out << "mon_scrub(" << get_opname((op_type_t)op);
+ out << " v " << version;
+ if (op == OP_RESULT)
+ out << " " << result;
+ out << " num_keys " << num_keys;
+ out << " key (" << key << ")";
+ out << ")";
+ }
+
+ void encode_payload(uint64_t features) override {
+ using ceph::encode;
+ uint8_t o = op;
+ encode(o, payload);
+ encode(version, payload);
+ encode(result, payload);
+ encode(num_keys, payload);
+ encode(key, payload);
+ }
+
+ void decode_payload() override {
+ using ceph::decode;
+ auto p = payload.cbegin();
+ uint8_t o;
+ decode(o, p);
+ op = (op_type_t)o;
+ decode(version, p);
+ decode(result, p);
+ decode(num_keys, p);
+ decode(key, p);
+ }
+private:
+ template<class T, typename... Args>
+ friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
+};
+
+#endif /* CEPH_MMONSCRUB_H */