]> git.proxmox.com Git - ceph.git/blob - ceph/src/osd/PGPeeringEvent.h
buildsys: switch source download to quincy
[ceph.git] / ceph / src / osd / PGPeeringEvent.h
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 std::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 std::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() const {
57 return epoch_sent;
58 }
59 epoch_t get_epoch_requested() const {
60 return epoch_requested;
61 }
62 const boost::statechart::event_base &get_event() const {
63 return *evt;
64 }
65 const std::string& get_desc() const {
66 return desc;
67 }
68 };
69 typedef std::shared_ptr<PGPeeringEvent> PGPeeringEventRef;
70 typedef std::unique_ptr<PGPeeringEvent> PGPeeringEventURef;
71
72 struct MInfoRec : boost::statechart::event< MInfoRec > {
73 pg_shard_t from;
74 pg_info_t info;
75 epoch_t msg_epoch;
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;
85 if (lease) {
86 *out << " " << *lease;
87 }
88 if (lease_ack) {
89 *out << " " << *lease_ack;
90 }
91 }
92 };
93
94 struct MLogRec : boost::statechart::event< MLogRec > {
95 pg_shard_t from;
96 boost::intrusive_ptr<MOSDPGLog> msg;
97 MLogRec(pg_shard_t from, MOSDPGLog *msg);
98 void print(std::ostream *out) const;
99 };
100
101 struct MNotifyRec : boost::statechart::event< MNotifyRec > {
102 spg_t pgid;
103 pg_shard_t from;
104 pg_notify_t notify;
105 uint64_t features;
106 MNotifyRec(spg_t p, pg_shard_t from, const pg_notify_t &notify, 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;
111 }
112 };
113
114 struct MQuery : boost::statechart::event< MQuery > {
115 spg_t pgid;
116 pg_shard_t from;
117 pg_query_t query;
118 epoch_t query_epoch;
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;
125 }
126 };
127
128 struct MTrim : boost::statechart::event<MTrim> {
129 epoch_t epoch;
130 int from;
131 shard_id_t shard;
132 eversion_t trim_to;
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;
138 }
139 };
140
141 struct MLease : boost::statechart::event<MLease> {
142 epoch_t epoch;
143 int from;
144 pg_lease_t lease;
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;
149 }
150 };
151
152 struct MLeaseAck : boost::statechart::event<MLeaseAck> {
153 epoch_t epoch;
154 int from;
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
160 << " " << lease_ack;
161 }
162 };
163
164 struct RequestBackfillPrio : boost::statechart::event< RequestBackfillPrio > {
165 unsigned priority;
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;
175 }
176 };
177
178 struct RequestRecoveryPrio : boost::statechart::event< RequestRecoveryPrio > {
179 unsigned priority;
180 explicit RequestRecoveryPrio(unsigned prio) :
181 boost::statechart::event< RequestRecoveryPrio >(),
182 priority(prio) {}
183 void print(std::ostream *out) const {
184 *out << "RequestRecoveryPrio: priority " << priority;
185 }
186 };
187
188 #define TrivialEvent(T) struct T : boost::statechart::event< T > { \
189 T() : boost::statechart::event< T >() {} \
190 void print(std::ostream *out) const { \
191 *out << #T; \
192 } \
193 };
194
195 TrivialEvent(NullEvt)
196 TrivialEvent(RemoteBackfillReserved)
197 TrivialEvent(RemoteReservationRejectedTooFull)
198 TrivialEvent(RemoteReservationRevokedTooFull)
199 TrivialEvent(RemoteReservationRevoked)
200 TrivialEvent(RemoteReservationCanceled)
201 TrivialEvent(RemoteRecoveryReserved)
202 TrivialEvent(RecoveryDone)
203
204 struct DeferRecovery : boost::statechart::event<DeferRecovery> {
205 float delay;
206 explicit DeferRecovery(float delay) : delay(delay) {}
207 void print(std::ostream *out) const {
208 *out << "DeferRecovery: delay " << delay;
209 }
210 };
211
212 struct DeferBackfill : boost::statechart::event<DeferBackfill> {
213 float delay;
214 explicit DeferBackfill(float delay) : delay(delay) {}
215 void print(std::ostream *out) const {
216 *out << "DeferBackfill: delay " << delay;
217 }
218 };
219
220 TrivialEvent(RenewLease)