]>
git.proxmox.com Git - ceph.git/blob - 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
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2012 Inktank, Inc.
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.
13 #ifndef CEPH_MMONSYNC_H
14 #define CEPH_MMONSYNC_H
16 #include "msg/Message.h"
18 class MMonSync
: public Message
{
20 static constexpr int HEAD_VERSION
= 2;
21 static constexpr int COMPAT_VERSION
= 2;
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
38 * Obtain a string corresponding to the operation type @p op
40 * @param op Operation type
43 static const char *get_opname(int 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: ceph_abort_msg("unknown op type"); return NULL
;
58 version_t last_committed
= 0;
59 std::pair
<std::string
,std::string
> last_key
;
60 ceph::buffer::list chunk_bl
;
61 entity_inst_t reply_to
;
64 : Message
{MSG_MON_SYNC
, HEAD_VERSION
, COMPAT_VERSION
}
67 MMonSync(uint32_t op
, uint64_t c
= 0)
68 : Message
{MSG_MON_SYNC
, HEAD_VERSION
, COMPAT_VERSION
},
74 std::string_view
get_type_name() const override
{ return "mon_sync"; }
76 void print(std::ostream
& out
) const override
{
77 out
<< "mon_sync(" << get_opname(op
);
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
;
89 void encode_payload(uint64_t features
) override
{
92 encode(cookie
, payload
);
93 encode(last_committed
, payload
);
94 encode(last_key
.first
, payload
);
95 encode(last_key
.second
, payload
);
96 encode(chunk_bl
, payload
);
97 encode(reply_to
, payload
, features
);
100 void decode_payload() override
{
102 auto p
= payload
.cbegin();
105 decode(last_committed
, p
);
106 decode(last_key
.first
, p
);
107 decode(last_key
.second
, p
);
112 template<class T
, typename
... Args
>
113 friend boost::intrusive_ptr
<T
> ceph::make_message(Args
&&... args
);
116 #endif /* CEPH_MMONSYNC_H */