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()),
47 std::stringstream out
;
48 out
<< "epoch_sent: " << epoch_sent
49 << " epoch_requested: " << epoch_requested
<< " ";
52 out
<< " +create_info";
56 epoch_t
get_epoch_sent() const {
59 epoch_t
get_epoch_requested() const {
60 return epoch_requested
;
62 const boost::statechart::event_base
&get_event() const {
65 const std::string
& get_desc() const {
69 typedef std::shared_ptr
<PGPeeringEvent
> PGPeeringEventRef
;
70 typedef std::unique_ptr
<PGPeeringEvent
> PGPeeringEventURef
;
72 struct MInfoRec
: boost::statechart::event
< MInfoRec
> {
76 std::optional
<pg_lease_t
> lease
;
77 std::optional
<pg_lease_ack_t
> lease_ack
;
78 MInfoRec(pg_shard_t from
, const pg_info_t
&info
, epoch_t msg_epoch
,
79 std::optional
<pg_lease_t
> l
= {},
80 std::optional
<pg_lease_ack_t
> la
= {})
81 : from(from
), info(info
), msg_epoch(msg_epoch
),
82 lease(l
), lease_ack(la
) {}
83 void print(std::ostream
*out
) const {
84 *out
<< "MInfoRec from " << from
<< " info: " << info
;
86 *out
<< " " << *lease
;
89 *out
<< " " << *lease_ack
;
94 struct MLogRec
: boost::statechart::event
< MLogRec
> {
96 boost::intrusive_ptr
<MOSDPGLog
> msg
;
97 MLogRec(pg_shard_t from
, MOSDPGLog
*msg
);
98 void print(std::ostream
*out
) const;
101 struct MNotifyRec
: boost::statechart::event
< MNotifyRec
> {
106 MNotifyRec(spg_t p
, pg_shard_t from
, const pg_notify_t
¬ify
, uint64_t f
)
107 : pgid(p
), from(from
), notify(notify
), features(f
) {}
108 void print(std::ostream
*out
) const {
109 *out
<< "MNotifyRec " << pgid
<< " from " << from
<< " notify: " << notify
110 << " features: 0x" << std::hex
<< features
<< std::dec
;
114 struct MQuery
: boost::statechart::event
< MQuery
> {
119 MQuery(spg_t p
, pg_shard_t from
, const pg_query_t
&query
, epoch_t query_epoch
)
120 : pgid(p
), from(from
), query(query
), query_epoch(query_epoch
) {}
121 void print(std::ostream
*out
) const {
122 *out
<< "MQuery " << pgid
<< " from " << from
123 << " query_epoch " << query_epoch
124 << " query: " << query
;
128 struct MTrim
: boost::statechart::event
<MTrim
> {
133 MTrim(epoch_t epoch
, int from
, shard_id_t shard
, eversion_t trim_to
)
134 : epoch(epoch
), from(from
), shard(shard
), trim_to(trim_to
) {}
135 void print(std::ostream
*out
) const {
136 *out
<< "MTrim epoch " << epoch
<< " from " << from
<< " shard " << shard
137 << " trim_to " << trim_to
;
141 struct MLease
: boost::statechart::event
<MLease
> {
145 MLease(epoch_t epoch
, int from
, pg_lease_t l
)
146 : epoch(epoch
), from(from
), lease(l
) {}
147 void print(std::ostream
*out
) const {
148 *out
<< "MLease epoch " << epoch
<< " from osd." << from
<< " " << lease
;
152 struct MLeaseAck
: boost::statechart::event
<MLeaseAck
> {
155 pg_lease_ack_t lease_ack
;
156 MLeaseAck(epoch_t epoch
, int from
, pg_lease_ack_t l
)
157 : epoch(epoch
), from(from
), lease_ack(l
) {}
158 void print(std::ostream
*out
) const {
159 *out
<< "MLeaseAck epoch " << epoch
<< " from osd." << from
164 struct RequestBackfillPrio
: boost::statechart::event
< RequestBackfillPrio
> {
166 int64_t primary_num_bytes
;
167 int64_t local_num_bytes
;
168 explicit RequestBackfillPrio(unsigned prio
, int64_t pbytes
, int64_t lbytes
) :
169 boost::statechart::event
< RequestBackfillPrio
>(),
170 priority(prio
), primary_num_bytes(pbytes
), local_num_bytes(lbytes
) {}
171 void print(std::ostream
*out
) const {
172 *out
<< "RequestBackfillPrio: priority " << priority
173 << " primary bytes " << primary_num_bytes
174 << " local bytes " << local_num_bytes
;
178 struct RequestRecoveryPrio
: boost::statechart::event
< RequestRecoveryPrio
> {
180 explicit RequestRecoveryPrio(unsigned prio
) :
181 boost::statechart::event
< RequestRecoveryPrio
>(),
183 void print(std::ostream
*out
) const {
184 *out
<< "RequestRecoveryPrio: priority " << priority
;
188 #define TrivialEvent(T) struct T : boost::statechart::event< T > { \
189 T() : boost::statechart::event< T >() {} \
190 void print(std::ostream *out) const { \
195 TrivialEvent(NullEvt
)
196 TrivialEvent(RemoteBackfillReserved
)
197 TrivialEvent(RemoteReservationRejectedTooFull
)
198 TrivialEvent(RemoteReservationRevokedTooFull
)
199 TrivialEvent(RemoteReservationRevoked
)
200 TrivialEvent(RemoteReservationCanceled
)
201 TrivialEvent(RemoteRecoveryReserved
)
202 TrivialEvent(RecoveryDone
)
204 struct DeferRecovery
: boost::statechart::event
<DeferRecovery
> {
206 explicit DeferRecovery(float delay
) : delay(delay
) {}
207 void print(std::ostream
*out
) const {
208 *out
<< "DeferRecovery: delay " << delay
;
212 struct DeferBackfill
: boost::statechart::event
<DeferBackfill
> {
214 explicit DeferBackfill(float delay
) : delay(delay
) {}
215 void print(std::ostream
*out
) const {
216 *out
<< "DeferBackfill: delay " << delay
;
220 TrivialEvent(RenewLease
)