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