]> git.proxmox.com Git - ceph.git/blame - ceph/src/messages/MMonSync.h
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / messages / MMonSync.h
CommitLineData
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) 2012 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_MMONSYNC_H
14#define CEPH_MMONSYNC_H
15
16#include "msg/Message.h"
17
11fdf7f2
TL
18class MMonSync : public MessageInstance<MMonSync> {
19public:
20 friend factory;
21private:
22 static constexpr int HEAD_VERSION = 2;
23 static constexpr int COMPAT_VERSION = 2;
7c673cae
FG
24
25public:
26 /**
27 * Operation types
28 */
29 enum {
30 OP_GET_COOKIE_FULL = 1, // -> start a session (full scan)
31 OP_GET_COOKIE_RECENT = 2, // -> start a session (only recent paxos events)
32 OP_COOKIE = 3, // <- pass the iterator cookie, or
33 OP_GET_CHUNK = 4, // -> get some keys
34 OP_CHUNK = 5, // <- return some keys
35 OP_LAST_CHUNK = 6, // <- return the last set of keys
36 OP_NO_COOKIE = 8, // <- sorry, no cookie
37 };
38
39 /**
40 * Obtain a string corresponding to the operation type @p op
41 *
42 * @param op Operation type
43 * @returns A string
44 */
45 static const char *get_opname(int op) {
46 switch (op) {
47 case OP_GET_COOKIE_FULL: return "get_cookie_full";
48 case OP_GET_COOKIE_RECENT: return "get_cookie_recent";
49 case OP_COOKIE: return "cookie";
50 case OP_GET_CHUNK: return "get_chunk";
51 case OP_CHUNK: return "chunk";
52 case OP_LAST_CHUNK: return "last_chunk";
53 case OP_NO_COOKIE: return "no_cookie";
11fdf7f2 54 default: ceph_abort_msg("unknown op type"); return NULL;
7c673cae
FG
55 }
56 }
57
d2e6a577
FG
58 uint32_t op = 0;
59 uint64_t cookie = 0;
60 version_t last_committed = 0;
7c673cae
FG
61 pair<string,string> last_key;
62 bufferlist chunk_bl;
63 entity_inst_t reply_to;
64
65 MMonSync()
11fdf7f2 66 : MessageInstance(MSG_MON_SYNC, HEAD_VERSION, COMPAT_VERSION)
7c673cae
FG
67 { }
68
69 MMonSync(uint32_t op, uint64_t c = 0)
11fdf7f2 70 : MessageInstance(MSG_MON_SYNC, HEAD_VERSION, COMPAT_VERSION),
7c673cae
FG
71 op(op),
72 cookie(c),
73 last_committed(0)
74 { }
75
11fdf7f2 76 std::string_view get_type_name() const override { return "mon_sync"; }
7c673cae
FG
77
78 void print(ostream& out) const override {
79 out << "mon_sync(" << get_opname(op);
80 if (cookie)
81 out << " cookie " << cookie;
82 if (last_committed > 0)
83 out << " lc " << last_committed;
84 if (chunk_bl.length())
85 out << " bl " << chunk_bl.length() << " bytes";
86 if (!last_key.first.empty() || !last_key.second.empty())
87 out << " last_key " << last_key.first << "," << last_key.second;
88 out << ")";
89 }
90
91 void encode_payload(uint64_t features) override {
11fdf7f2
TL
92 using ceph::encode;
93 encode(op, payload);
94 encode(cookie, payload);
95 encode(last_committed, payload);
96 encode(last_key.first, payload);
97 encode(last_key.second, payload);
98 encode(chunk_bl, payload);
99 encode(reply_to, payload, features);
7c673cae
FG
100 }
101
102 void decode_payload() override {
11fdf7f2
TL
103 auto p = payload.cbegin();
104 decode(op, p);
105 decode(cookie, p);
106 decode(last_committed, p);
107 decode(last_key.first, p);
108 decode(last_key.second, p);
109 decode(chunk_bl, p);
110 decode(reply_to, p);
7c673cae
FG
111 }
112};
113
114#endif /* CEPH_MMONSYNC_H */