-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMMonProbe.h
128 lines (116 loc) · 3.23 KB
/
MMonProbe.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// -*- 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) 2004-2006 Sage Weil <[email protected]>
*
* 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_MMONPROBE_H
#define CEPH_MMONPROBE_H
#include "include/ceph_features.h"
#include "msg/Message.h"
#include "mon/MonMap.h"
class MMonProbe : public Message {
public:
static const int HEAD_VERSION = 6;
static const int COMPAT_VERSION = 5;
enum {
OP_PROBE = 1,
OP_REPLY = 2,
OP_SLURP = 3,
OP_SLURP_LATEST = 4,
OP_DATA = 5,
OP_MISSING_FEATURES = 6,
};
static const char *get_opname(int o) {
switch (o) {
case OP_PROBE: return "probe";
case OP_REPLY: return "reply";
case OP_SLURP: return "slurp";
case OP_SLURP_LATEST: return "slurp_latest";
case OP_DATA: return "data";
case OP_MISSING_FEATURES: return "missing_features";
default: assert(0); return 0;
}
}
uuid_d fsid;
int32_t op;
string name;
set<int32_t> quorum;
bufferlist monmap_bl;
version_t paxos_first_version;
version_t paxos_last_version;
bool has_ever_joined;
uint64_t required_features;
MMonProbe()
: Message(MSG_MON_PROBE, HEAD_VERSION, COMPAT_VERSION) {}
MMonProbe(const uuid_d& f, int o, const string& n, bool hej)
: Message(MSG_MON_PROBE, HEAD_VERSION, COMPAT_VERSION),
fsid(f),
op(o),
name(n),
paxos_first_version(0),
paxos_last_version(0),
has_ever_joined(hej),
required_features(0) {}
private:
~MMonProbe() {}
public:
const char *get_type_name() const { return "mon_probe"; }
void print(ostream& out) const {
out << "mon_probe(" << get_opname(op) << " " << fsid << " name " << name;
if (quorum.size())
out << " quorum " << quorum;
if (op == OP_REPLY) {
out << " paxos("
<< " fc " << paxos_first_version
<< " lc " << paxos_last_version
<< " )";
}
if (!has_ever_joined)
out << " new";
if (required_features)
out << " required_features " << required_features;
out << ")";
}
void encode_payload(uint64_t features) {
if (monmap_bl.length() && (features & CEPH_FEATURE_MONENC) == 0) {
// reencode old-format monmap
MonMap t;
t.decode(monmap_bl);
monmap_bl.clear();
t.encode(monmap_bl, features);
}
::encode(fsid, payload);
::encode(op, payload);
::encode(name, payload);
::encode(quorum, payload);
::encode(monmap_bl, payload);
::encode(has_ever_joined, payload);
::encode(paxos_first_version, payload);
::encode(paxos_last_version, payload);
::encode(required_features, payload);
}
void decode_payload() {
bufferlist::iterator p = payload.begin();
::decode(fsid, p);
::decode(op, p);
::decode(name, p);
::decode(quorum, p);
::decode(monmap_bl, p);
::decode(has_ever_joined, p);
::decode(paxos_first_version, p);
::decode(paxos_last_version, p);
if (header.version >= 6)
::decode(required_features, p);
else
required_features = 0;
}
};
#endif