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 const int HEAD_VERSION = 2;
21 static const 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: assert(0 == "unknown op type"); return NULL;
58 version_t last_committed = 0;
59 pair<string,string> last_key;
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 const char *get_type_name() const override { return "mon_sync"; }
76 void print(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 {
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);
99 void decode_payload() override {
100 bufferlist::iterator p = payload.begin();
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);
111 #endif /* CEPH_MMONSYNC_H */