1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
6 #include <boost/statechart/event.hpp>
8 #include "osd/osd_types.h"
12 /// what we need to instantiate a pg
17 PastIntervals past_intervals
;
19 PGCreateInfo(spg_t p
, epoch_t e
,
20 const pg_history_t
& h
,
21 const PastIntervals
& pi
,
23 : pgid(p
), epoch(e
), history(h
), past_intervals(pi
), by_mon(mon
) {}
26 class PGPeeringEvent
{
28 epoch_t epoch_requested
;
31 boost::intrusive_ptr
< const boost::statechart::event_base
> evt
;
33 std::unique_ptr
<PGCreateInfo
> create_info
;
34 MEMPOOL_CLASS_HELPERS();
38 epoch_t epoch_requested
,
42 : epoch_sent(epoch_sent
),
43 epoch_requested(epoch_requested
),
44 evt(evt_
.intrusive_from_this()),
48 out
<< "epoch_sent: " << epoch_sent
49 << " epoch_requested: " << epoch_requested
<< " ";
52 out
<< " +create_info";
56 epoch_t
get_epoch_sent() {
59 epoch_t
get_epoch_requested() {
60 return epoch_requested
;
62 const boost::statechart::event_base
&get_event() {
65 const string
& get_desc() {
69 typedef std::shared_ptr
<PGPeeringEvent
> PGPeeringEventRef
;
71 struct MInfoRec
: boost::statechart::event
< MInfoRec
> {
75 MInfoRec(pg_shard_t from
, const pg_info_t
&info
, epoch_t msg_epoch
) :
76 from(from
), info(info
), msg_epoch(msg_epoch
) {}
77 void print(std::ostream
*out
) const {
78 *out
<< "MInfoRec from " << from
<< " info: " << info
;
82 struct MLogRec
: boost::statechart::event
< MLogRec
> {
84 boost::intrusive_ptr
<MOSDPGLog
> msg
;
85 MLogRec(pg_shard_t from
, MOSDPGLog
*msg
) :
86 from(from
), msg(msg
) {}
87 void print(std::ostream
*out
) const {
88 *out
<< "MLogRec from " << from
;
92 struct MNotifyRec
: boost::statechart::event
< MNotifyRec
> {
97 PastIntervals past_intervals
;
98 MNotifyRec(spg_t p
, pg_shard_t from
, const pg_notify_t
¬ify
, uint64_t f
,
99 const PastIntervals
& pi
)
100 : pgid(p
), from(from
), notify(notify
), features(f
), past_intervals(pi
) {}
101 void print(std::ostream
*out
) const {
102 *out
<< "MNotifyRec " << pgid
<< " from " << from
<< " notify: " << notify
103 << " features: 0x" << hex
<< features
<< dec
104 << " " << past_intervals
;
108 struct MQuery
: boost::statechart::event
< MQuery
> {
113 MQuery(spg_t p
, pg_shard_t from
, const pg_query_t
&query
, epoch_t query_epoch
)
114 : pgid(p
), from(from
), query(query
), query_epoch(query_epoch
) {}
115 void print(std::ostream
*out
) const {
116 *out
<< "MQuery " << pgid
<< " from " << from
117 << " query_epoch " << query_epoch
118 << " query: " << query
;
122 struct MTrim
: boost::statechart::event
<MTrim
> {
127 MTrim(epoch_t epoch
, int from
, shard_id_t shard
, eversion_t trim_to
)
128 : epoch(epoch
), from(from
), shard(shard
), trim_to(trim_to
) {}
129 void print(std::ostream
*out
) const {
130 *out
<< "MTrim epoch " << epoch
<< " from " << from
<< " shard " << shard
131 << " trim_to " << trim_to
;
135 struct RequestBackfillPrio
: boost::statechart::event
< RequestBackfillPrio
> {
137 int64_t primary_num_bytes
;
138 int64_t local_num_bytes
;
139 explicit RequestBackfillPrio(unsigned prio
, int64_t pbytes
, int64_t lbytes
) :
140 boost::statechart::event
< RequestBackfillPrio
>(),
141 priority(prio
), primary_num_bytes(pbytes
), local_num_bytes(lbytes
) {}
142 void print(std::ostream
*out
) const {
143 *out
<< "RequestBackfillPrio: priority " << priority
144 << " primary bytes " << primary_num_bytes
145 << " local bytes " << local_num_bytes
;
149 struct RequestRecoveryPrio
: boost::statechart::event
< RequestRecoveryPrio
> {
151 explicit RequestRecoveryPrio(unsigned prio
) :
152 boost::statechart::event
< RequestRecoveryPrio
>(),
154 void print(std::ostream
*out
) const {
155 *out
<< "RequestRecoveryPrio: priority " << priority
;
159 #define TrivialEvent(T) struct T : boost::statechart::event< T > { \
160 T() : boost::statechart::event< T >() {} \
161 void print(std::ostream *out) const { \
166 TrivialEvent(NullEvt
)
167 TrivialEvent(RemoteBackfillReserved
)
168 TrivialEvent(RemoteReservationRejected
)
169 TrivialEvent(RemoteReservationRevokedTooFull
)
170 TrivialEvent(RemoteReservationRevoked
)
171 TrivialEvent(RemoteReservationCanceled
)
172 TrivialEvent(RemoteRecoveryReserved
)
173 TrivialEvent(RecoveryDone
)
175 struct DeferRecovery
: boost::statechart::event
<DeferRecovery
> {
177 explicit DeferRecovery(float delay
) : delay(delay
) {}
178 void print(std::ostream
*out
) const {
179 *out
<< "DeferRecovery: delay " << delay
;
183 struct DeferBackfill
: boost::statechart::event
<DeferBackfill
> {
185 explicit DeferBackfill(float delay
) : delay(delay
) {}
186 void print(std::ostream
*out
) const {
187 *out
<< "DeferBackfill: delay " << delay
;