]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | ||
4 | #pragma once | |
5 | ||
6 | #include <boost/statechart/event.hpp> | |
7 | ||
8 | #include "osd/osd_types.h" | |
9 | ||
10 | class MOSDPGLog; | |
11 | ||
12 | /// what we need to instantiate a pg | |
13 | struct PGCreateInfo { | |
14 | spg_t pgid; | |
15 | epoch_t epoch = 0; | |
16 | pg_history_t history; | |
17 | PastIntervals past_intervals; | |
18 | bool by_mon; | |
19 | PGCreateInfo(spg_t p, epoch_t e, | |
20 | const pg_history_t& h, | |
21 | const PastIntervals& pi, | |
22 | bool mon) | |
23 | : pgid(p), epoch(e), history(h), past_intervals(pi), by_mon(mon) {} | |
24 | }; | |
25 | ||
26 | class PGPeeringEvent { | |
27 | epoch_t epoch_sent; | |
28 | epoch_t epoch_requested; | |
29 | string desc; | |
30 | public: | |
31 | boost::intrusive_ptr< const boost::statechart::event_base > evt; | |
32 | bool requires_pg; | |
33 | std::unique_ptr<PGCreateInfo> create_info; | |
34 | MEMPOOL_CLASS_HELPERS(); | |
35 | template <class T> | |
36 | PGPeeringEvent( | |
37 | epoch_t epoch_sent, | |
38 | epoch_t epoch_requested, | |
39 | const T &evt_, | |
40 | bool req = true, | |
41 | PGCreateInfo *ci = 0) | |
42 | : epoch_sent(epoch_sent), | |
43 | epoch_requested(epoch_requested), | |
44 | evt(evt_.intrusive_from_this()), | |
45 | requires_pg(req), | |
46 | create_info(ci) { | |
47 | stringstream out; | |
48 | out << "epoch_sent: " << epoch_sent | |
49 | << " epoch_requested: " << epoch_requested << " "; | |
50 | evt_.print(&out); | |
51 | if (create_info) { | |
52 | out << " +create_info"; | |
53 | } | |
54 | desc = out.str(); | |
55 | } | |
56 | epoch_t get_epoch_sent() { | |
57 | return epoch_sent; | |
58 | } | |
59 | epoch_t get_epoch_requested() { | |
60 | return epoch_requested; | |
61 | } | |
62 | const boost::statechart::event_base &get_event() { | |
63 | return *evt; | |
64 | } | |
65 | const string& get_desc() { | |
66 | return desc; | |
67 | } | |
68 | }; | |
69 | typedef std::shared_ptr<PGPeeringEvent> PGPeeringEventRef; | |
70 | ||
71 | struct MInfoRec : boost::statechart::event< MInfoRec > { | |
72 | pg_shard_t from; | |
73 | pg_info_t info; | |
74 | epoch_t msg_epoch; | |
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; | |
79 | } | |
80 | }; | |
81 | ||
82 | struct MLogRec : boost::statechart::event< MLogRec > { | |
83 | pg_shard_t from; | |
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; | |
89 | } | |
90 | }; | |
91 | ||
92 | struct MNotifyRec : boost::statechart::event< MNotifyRec > { | |
93 | spg_t pgid; | |
94 | pg_shard_t from; | |
95 | pg_notify_t notify; | |
96 | uint64_t features; | |
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; | |
105 | } | |
106 | }; | |
107 | ||
108 | struct MQuery : boost::statechart::event< MQuery > { | |
109 | spg_t pgid; | |
110 | pg_shard_t from; | |
111 | pg_query_t query; | |
112 | epoch_t query_epoch; | |
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; | |
119 | } | |
120 | }; | |
121 | ||
122 | struct MTrim : boost::statechart::event<MTrim> { | |
123 | epoch_t epoch; | |
124 | int from; | |
125 | shard_id_t shard; | |
126 | eversion_t trim_to; | |
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; | |
132 | } | |
133 | }; | |
134 | ||
135 | struct RequestBackfillPrio : boost::statechart::event< RequestBackfillPrio > { | |
136 | unsigned priority; | |
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; | |
146 | } | |
147 | }; | |
148 | ||
149 | struct RequestRecoveryPrio : boost::statechart::event< RequestRecoveryPrio > { | |
150 | unsigned priority; | |
151 | explicit RequestRecoveryPrio(unsigned prio) : | |
152 | boost::statechart::event< RequestRecoveryPrio >(), | |
153 | priority(prio) {} | |
154 | void print(std::ostream *out) const { | |
155 | *out << "RequestRecoveryPrio: priority " << priority; | |
156 | } | |
157 | }; | |
158 | ||
159 | #define TrivialEvent(T) struct T : boost::statechart::event< T > { \ | |
160 | T() : boost::statechart::event< T >() {} \ | |
161 | void print(std::ostream *out) const { \ | |
162 | *out << #T; \ | |
163 | } \ | |
164 | }; | |
165 | ||
166 | TrivialEvent(NullEvt) | |
167 | TrivialEvent(RemoteBackfillReserved) | |
eafe8130 | 168 | TrivialEvent(RemoteReservationRejectedTooFull) |
11fdf7f2 TL |
169 | TrivialEvent(RemoteReservationRevokedTooFull) |
170 | TrivialEvent(RemoteReservationRevoked) | |
171 | TrivialEvent(RemoteReservationCanceled) | |
172 | TrivialEvent(RemoteRecoveryReserved) | |
173 | TrivialEvent(RecoveryDone) | |
174 | ||
175 | struct DeferRecovery : boost::statechart::event<DeferRecovery> { | |
176 | float delay; | |
177 | explicit DeferRecovery(float delay) : delay(delay) {} | |
178 | void print(std::ostream *out) const { | |
179 | *out << "DeferRecovery: delay " << delay; | |
180 | } | |
181 | }; | |
182 | ||
183 | struct DeferBackfill : boost::statechart::event<DeferBackfill> { | |
184 | float delay; | |
185 | explicit DeferBackfill(float delay) : delay(delay) {} | |
186 | void print(std::ostream *out) const { | |
187 | *out << "DeferBackfill: delay " << delay; | |
188 | } | |
189 | }; |