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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
#pragma once
#include <boost/statechart/event.hpp>
#include "osd/osd_types.h"
class MOSDPGLog;
/// what we need to instantiate a pg
struct PGCreateInfo {
spg_t pgid;
epoch_t epoch = 0;
pg_history_t history;
PastIntervals past_intervals;
bool by_mon;
PGCreateInfo(spg_t p, epoch_t e,
const pg_history_t& h,
const PastIntervals& pi,
bool mon)
: pgid(p), epoch(e), history(h), past_intervals(pi), by_mon(mon) {}
};
class PGPeeringEvent {
epoch_t epoch_sent;
epoch_t epoch_requested;
string desc;
public:
boost::intrusive_ptr< const boost::statechart::event_base > evt;
bool requires_pg;
std::unique_ptr<PGCreateInfo> create_info;
MEMPOOL_CLASS_HELPERS();
template <class T>
PGPeeringEvent(
epoch_t epoch_sent,
epoch_t epoch_requested,
const T &evt_,
bool req = true,
PGCreateInfo *ci = 0)
: epoch_sent(epoch_sent),
epoch_requested(epoch_requested),
evt(evt_.intrusive_from_this()),
requires_pg(req),
create_info(ci) {
stringstream out;
out << "epoch_sent: " << epoch_sent
<< " epoch_requested: " << epoch_requested << " ";
evt_.print(&out);
if (create_info) {
out << " +create_info";
}
desc = out.str();
}
epoch_t get_epoch_sent() {
return epoch_sent;
}
epoch_t get_epoch_requested() {
return epoch_requested;
}
const boost::statechart::event_base &get_event() {
return *evt;
}
const string& get_desc() {
return desc;
}
};
typedef std::shared_ptr<PGPeeringEvent> PGPeeringEventRef;
struct MInfoRec : boost::statechart::event< MInfoRec > {
pg_shard_t from;
pg_info_t info;
epoch_t msg_epoch;
MInfoRec(pg_shard_t from, const pg_info_t &info, epoch_t msg_epoch) :
from(from), info(info), msg_epoch(msg_epoch) {}
void print(std::ostream *out) const {
*out << "MInfoRec from " << from << " info: " << info;
}
};
struct MLogRec : boost::statechart::event< MLogRec > {
pg_shard_t from;
boost::intrusive_ptr<MOSDPGLog> msg;
MLogRec(pg_shard_t from, MOSDPGLog *msg) :
from(from), msg(msg) {}
void print(std::ostream *out) const {
*out << "MLogRec from " << from;
}
};
struct MNotifyRec : boost::statechart::event< MNotifyRec > {
spg_t pgid;
pg_shard_t from;
pg_notify_t notify;
uint64_t features;
PastIntervals past_intervals;
MNotifyRec(spg_t p, pg_shard_t from, const pg_notify_t ¬ify, uint64_t f,
const PastIntervals& pi)
: pgid(p), from(from), notify(notify), features(f), past_intervals(pi) {}
void print(std::ostream *out) const {
*out << "MNotifyRec " << pgid << " from " << from << " notify: " << notify
<< " features: 0x" << hex << features << dec
<< " " << past_intervals;
}
};
struct MQuery : boost::statechart::event< MQuery > {
spg_t pgid;
pg_shard_t from;
pg_query_t query;
epoch_t query_epoch;
MQuery(spg_t p, pg_shard_t from, const pg_query_t &query, epoch_t query_epoch)
: pgid(p), from(from), query(query), query_epoch(query_epoch) {}
void print(std::ostream *out) const {
*out << "MQuery " << pgid << " from " << from
<< " query_epoch " << query_epoch
<< " query: " << query;
}
};
struct MTrim : boost::statechart::event<MTrim> {
epoch_t epoch;
int from;
shard_id_t shard;
eversion_t trim_to;
MTrim(epoch_t epoch, int from, shard_id_t shard, eversion_t trim_to)
: epoch(epoch), from(from), shard(shard), trim_to(trim_to) {}
void print(std::ostream *out) const {
*out << "MTrim epoch " << epoch << " from " << from << " shard " << shard
<< " trim_to " << trim_to;
}
};
struct RequestBackfillPrio : boost::statechart::event< RequestBackfillPrio > {
unsigned priority;
int64_t primary_num_bytes;
int64_t local_num_bytes;
explicit RequestBackfillPrio(unsigned prio, int64_t pbytes, int64_t lbytes) :
boost::statechart::event< RequestBackfillPrio >(),
priority(prio), primary_num_bytes(pbytes), local_num_bytes(lbytes) {}
void print(std::ostream *out) const {
*out << "RequestBackfillPrio: priority " << priority
<< " primary bytes " << primary_num_bytes
<< " local bytes " << local_num_bytes;
}
};
struct RequestRecoveryPrio : boost::statechart::event< RequestRecoveryPrio > {
unsigned priority;
explicit RequestRecoveryPrio(unsigned prio) :
boost::statechart::event< RequestRecoveryPrio >(),
priority(prio) {}
void print(std::ostream *out) const {
*out << "RequestRecoveryPrio: priority " << priority;
}
};
#define TrivialEvent(T) struct T : boost::statechart::event< T > { \
T() : boost::statechart::event< T >() {} \
void print(std::ostream *out) const { \
*out << #T; \
} \
};
TrivialEvent(NullEvt)
TrivialEvent(RemoteBackfillReserved)
TrivialEvent(RemoteReservationRejectedTooFull)
TrivialEvent(RemoteReservationRevokedTooFull)
TrivialEvent(RemoteReservationRevoked)
TrivialEvent(RemoteReservationCanceled)
TrivialEvent(RemoteRecoveryReserved)
TrivialEvent(RecoveryDone)
struct DeferRecovery : boost::statechart::event<DeferRecovery> {
float delay;
explicit DeferRecovery(float delay) : delay(delay) {}
void print(std::ostream *out) const {
*out << "DeferRecovery: delay " << delay;
}
};
struct DeferBackfill : boost::statechart::event<DeferBackfill> {
float delay;
explicit DeferBackfill(float delay) : delay(delay) {}
void print(std::ostream *out) const {
*out << "DeferBackfill: delay " << delay;
}
};
|