- class CephPeeringEvt {
- epoch_t epoch_sent;
- epoch_t epoch_requested;
- boost::intrusive_ptr< const boost::statechart::event_base > evt;
- string desc;
- public:
- MEMPOOL_CLASS_HELPERS();
- template <class T>
- CephPeeringEvt(epoch_t epoch_sent,
- epoch_t epoch_requested,
- const T &evt_) :
- epoch_sent(epoch_sent), epoch_requested(epoch_requested),
- evt(evt_.intrusive_from_this()) {
- stringstream out;
- out << "epoch_sent: " << epoch_sent
- << " epoch_requested: " << epoch_requested << " ";
- evt_.print(&out);
- 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; }
- string get_desc() { return desc; }
- };
- typedef ceph::shared_ptr<CephPeeringEvt> CephPeeringEvtRef;
- list<CephPeeringEvtRef> peering_queue; // op queue
- list<CephPeeringEvtRef> peering_waiters;
-
- struct QueryState : boost::statechart::event< QueryState > {
- Formatter *f;
- explicit QueryState(Formatter *f) : f(f) {}
- void print(std::ostream *out) const {
- *out << "Query";
- }
- };
-
- 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 > {
- pg_shard_t from;
- pg_notify_t notify;
- uint64_t features;
- MNotifyRec(pg_shard_t from, const pg_notify_t ¬ify, uint64_t f) :
- from(from), notify(notify), features(f) {}
- void print(std::ostream *out) const {
- *out << "MNotifyRec from " << from << " notify: " << notify
- << " features: 0x" << hex << features << dec;
- }
- };
-
- struct MQuery : boost::statechart::event< MQuery > {
- pg_shard_t from;
- pg_query_t query;
- epoch_t query_epoch;
- MQuery(pg_shard_t from, const pg_query_t &query, epoch_t query_epoch):
- from(from), query(query), query_epoch(query_epoch) {}
- void print(std::ostream *out) const {
- *out << "MQuery from " << from
- << " query_epoch " << query_epoch
- << " query: " << query;
- }
- };
-
- struct AdvMap : boost::statechart::event< AdvMap > {
- OSDMapRef osdmap;
- OSDMapRef lastmap;
- vector<int> newup, newacting;
- int up_primary, acting_primary;
- AdvMap(
- OSDMapRef osdmap, OSDMapRef lastmap,
- vector<int>& newup, int up_primary,
- vector<int>& newacting, int acting_primary):
- osdmap(osdmap), lastmap(lastmap),
- newup(newup),
- newacting(newacting),
- up_primary(up_primary),
- acting_primary(acting_primary) {}
- void print(std::ostream *out) const {
- *out << "AdvMap";
- }
- };
-
- struct ActMap : boost::statechart::event< ActMap > {
- ActMap() : boost::statechart::event< ActMap >() {}
- void print(std::ostream *out) const {
- *out << "ActMap";
- }
- };
- struct Activate : boost::statechart::event< Activate > {
- epoch_t activation_epoch;
- explicit Activate(epoch_t q) : boost::statechart::event< Activate >(),
- activation_epoch(q) {}
- void print(std::ostream *out) const {
- *out << "Activate from " << activation_epoch;
- }
- };
- struct RequestBackfillPrio : boost::statechart::event< RequestBackfillPrio > {
- unsigned priority;
- explicit RequestBackfillPrio(unsigned prio) :
- boost::statechart::event< RequestBackfillPrio >(),
- priority(prio) {}
- void print(std::ostream *out) const {
- *out << "RequestBackfillPrio: 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(Initialize)
- TrivialEvent(Load)
- TrivialEvent(GotInfo)
- TrivialEvent(NeedUpThru)
- TrivialEvent(NullEvt)
- TrivialEvent(FlushedEvt)
- TrivialEvent(Backfilled)
- TrivialEvent(LocalBackfillReserved)
- TrivialEvent(RemoteBackfillReserved)
- TrivialEvent(RemoteReservationRejected)
- TrivialEvent(RequestBackfill)
- TrivialEvent(RequestRecovery)
- TrivialEvent(RecoveryDone)
- TrivialEvent(BackfillTooFull)
- TrivialEvent(RecoveryTooFull)
-
- TrivialEvent(AllReplicasRecovered)
- TrivialEvent(DoRecovery)
- TrivialEvent(LocalRecoveryReserved)
- TrivialEvent(RemoteRecoveryReserved)
- TrivialEvent(AllRemotesReserved)
- TrivialEvent(AllBackfillsReserved)
- TrivialEvent(GoClean)
-
- TrivialEvent(AllReplicasActivated)
-
- TrivialEvent(IntervalFlush)
-
- /* Encapsulates PG recovery process */
- class RecoveryState {
- void start_handle(RecoveryCtx *new_ctx);
- void end_handle();
- public:
- void begin_block_outgoing();
- void end_block_outgoing();
- void clear_blocked_outgoing();
- private:
-
- /* States */
- struct Initial;
- class RecoveryMachine : public boost::statechart::state_machine< RecoveryMachine, Initial > {
- RecoveryState *state;
- public:
- PG *pg;
-
- utime_t event_time;
- uint64_t event_count;
-
- void clear_event_counters() {
- event_time = utime_t();
- event_count = 0;
- }
-
- void log_enter(const char *state_name);
- void log_exit(const char *state_name, utime_t duration);
-
- RecoveryMachine(RecoveryState *state, PG *pg) : state(state), pg(pg), event_count(0) {}
-
- /* Accessor functions for state methods */
- ObjectStore::Transaction* get_cur_transaction() {
- assert(state->rctx);
- assert(state->rctx->transaction);
- return state->rctx->transaction;
- }
-
- void send_query(pg_shard_t to, const pg_query_t &query) {
- assert(state->rctx);
- assert(state->rctx->query_map);
- (*state->rctx->query_map)[to.osd][spg_t(pg->info.pgid.pgid, to.shard)] =
- query;
- }
-
- map<int, map<spg_t, pg_query_t> > *get_query_map() {
- assert(state->rctx);
- assert(state->rctx->query_map);
- return state->rctx->query_map;
- }
-
- map<int, vector<pair<pg_notify_t, PastIntervals> > > *get_info_map() {
- assert(state->rctx);
- assert(state->rctx->info_map);
- return state->rctx->info_map;
- }
-
- list< Context* > *get_on_safe_context_list() {
- assert(state->rctx);
- assert(state->rctx->on_safe);
- return &(state->rctx->on_safe->contexts);
- }
-
- list< Context * > *get_on_applied_context_list() {
- assert(state->rctx);
- assert(state->rctx->on_applied);
- return &(state->rctx->on_applied->contexts);
- }
-
- RecoveryCtx *get_recovery_ctx() { return &*(state->rctx); }
-
- void send_notify(pg_shard_t to,
- const pg_notify_t &info, const PastIntervals &pi) {
- assert(state->rctx);
- assert(state->rctx->notify_list);
- (*state->rctx->notify_list)[to.osd].push_back(make_pair(info, pi));
- }
- };
- friend class RecoveryMachine;
-
- /* States */
-
- struct Crashed : boost::statechart::state< Crashed, RecoveryMachine >, NamedState {
- explicit Crashed(my_context ctx);
- };
-
- struct Reset;
-
- struct Initial : boost::statechart::state< Initial, RecoveryMachine >, NamedState {
- explicit Initial(my_context ctx);
- void exit();
-
- typedef boost::mpl::list <
- boost::statechart::transition< Initialize, Reset >,
- boost::statechart::custom_reaction< Load >,
- boost::statechart::custom_reaction< NullEvt >,
- boost::statechart::transition< boost::statechart::event_base, Crashed >
- > reactions;
-
- boost::statechart::result react(const Load&);
- boost::statechart::result react(const MNotifyRec&);
- boost::statechart::result react(const MInfoRec&);
- boost::statechart::result react(const MLogRec&);
- boost::statechart::result react(const boost::statechart::event_base&) {
- return discard_event();
- }
- };
-
- struct Reset : boost::statechart::state< Reset, RecoveryMachine >, NamedState {
- explicit Reset(my_context ctx);
- void exit();
-
- typedef boost::mpl::list <
- boost::statechart::custom_reaction< QueryState >,
- boost::statechart::custom_reaction< AdvMap >,
- boost::statechart::custom_reaction< ActMap >,
- boost::statechart::custom_reaction< NullEvt >,
- boost::statechart::custom_reaction< FlushedEvt >,
- boost::statechart::custom_reaction< IntervalFlush >,
- boost::statechart::transition< boost::statechart::event_base, Crashed >
- > reactions;
- boost::statechart::result react(const QueryState& q);
- boost::statechart::result react(const AdvMap&);
- boost::statechart::result react(const ActMap&);
- boost::statechart::result react(const FlushedEvt&);
- boost::statechart::result react(const IntervalFlush&);
- boost::statechart::result react(const boost::statechart::event_base&) {
- return discard_event();
- }
- };
-
- struct Start;
-
- struct Started : boost::statechart::state< Started, RecoveryMachine, Start >, NamedState {
- explicit Started(my_context ctx);
- void exit();
-
- typedef boost::mpl::list <
- boost::statechart::custom_reaction< QueryState >,
- boost::statechart::custom_reaction< AdvMap >,
- boost::statechart::custom_reaction< NullEvt >,
- boost::statechart::custom_reaction< FlushedEvt >,
- boost::statechart::custom_reaction< IntervalFlush >,
- boost::statechart::transition< boost::statechart::event_base, Crashed >
- > reactions;
- boost::statechart::result react(const QueryState& q);
- boost::statechart::result react(const AdvMap&);
- boost::statechart::result react(const FlushedEvt&);
- boost::statechart::result react(const IntervalFlush&);
- boost::statechart::result react(const boost::statechart::event_base&) {
- return discard_event();
- }
- };
-
- struct MakePrimary : boost::statechart::event< MakePrimary > {
- MakePrimary() : boost::statechart::event< MakePrimary >() {}
- };
- struct MakeStray : boost::statechart::event< MakeStray > {
- MakeStray() : boost::statechart::event< MakeStray >() {}
- };
- struct Primary;
- struct Stray;
-
- struct Start : boost::statechart::state< Start, Started >, NamedState {
- explicit Start(my_context ctx);
- void exit();
-
- typedef boost::mpl::list <
- boost::statechart::transition< MakePrimary, Primary >,
- boost::statechart::transition< MakeStray, Stray >
- > reactions;
- };
-
- struct Peering;
- struct WaitActingChange;
- struct NeedActingChange : boost::statechart::event< NeedActingChange > {
- NeedActingChange() : boost::statechart::event< NeedActingChange >() {}
- };
- struct Incomplete;
- struct IsIncomplete : boost::statechart::event< IsIncomplete > {
- IsIncomplete() : boost::statechart::event< IsIncomplete >() {}
- };
- struct Down;
- struct IsDown : boost::statechart::event< IsDown > {
- IsDown() : boost::statechart::event< IsDown >() {}
- };
-
- struct Primary : boost::statechart::state< Primary, Started, Peering >, NamedState {
- explicit Primary(my_context ctx);
- void exit();
-
- typedef boost::mpl::list <
- boost::statechart::custom_reaction< ActMap >,
- boost::statechart::custom_reaction< MNotifyRec >,
- boost::statechart::transition< NeedActingChange, WaitActingChange >
- > reactions;
- boost::statechart::result react(const ActMap&);
- boost::statechart::result react(const MNotifyRec&);
- };
-
- struct WaitActingChange : boost::statechart::state< WaitActingChange, Primary>,
- NamedState {
- typedef boost::mpl::list <
- boost::statechart::custom_reaction< QueryState >,
- boost::statechart::custom_reaction< AdvMap >,
- boost::statechart::custom_reaction< MLogRec >,
- boost::statechart::custom_reaction< MInfoRec >,
- boost::statechart::custom_reaction< MNotifyRec >
- > reactions;
- explicit WaitActingChange(my_context ctx);
- boost::statechart::result react(const QueryState& q);
- boost::statechart::result react(const AdvMap&);
- boost::statechart::result react(const MLogRec&);
- boost::statechart::result react(const MInfoRec&);
- boost::statechart::result react(const MNotifyRec&);
- void exit();
- };
-
- struct GetInfo;
- struct Active;
-
- struct Peering : boost::statechart::state< Peering, Primary, GetInfo >, NamedState {
- PastIntervals::PriorSet prior_set;
- bool history_les_bound; //< need osd_find_best_info_ignore_history_les
-
- explicit Peering(my_context ctx);
- void exit();
-
- typedef boost::mpl::list <
- boost::statechart::custom_reaction< QueryState >,
- boost::statechart::transition< Activate, Active >,
- boost::statechart::custom_reaction< AdvMap >
- > reactions;
- boost::statechart::result react(const QueryState& q);
- boost::statechart::result react(const AdvMap &advmap);
- };
-
- struct WaitLocalRecoveryReserved;
- struct Activating;
- struct Active : boost::statechart::state< Active, Primary, Activating >, NamedState {
- explicit Active(my_context ctx);
- void exit();
-
- const set<pg_shard_t> remote_shards_to_reserve_recovery;
- const set<pg_shard_t> remote_shards_to_reserve_backfill;
- bool all_replicas_activated;
-
- typedef boost::mpl::list <
- boost::statechart::custom_reaction< QueryState >,
- boost::statechart::custom_reaction< ActMap >,
- boost::statechart::custom_reaction< AdvMap >,
- boost::statechart::custom_reaction< MInfoRec >,
- boost::statechart::custom_reaction< MNotifyRec >,
- boost::statechart::custom_reaction< MLogRec >,
- boost::statechart::custom_reaction< Backfilled >,
- boost::statechart::custom_reaction< AllReplicasActivated >
- > reactions;
- boost::statechart::result react(const QueryState& q);
- boost::statechart::result react(const ActMap&);
- boost::statechart::result react(const AdvMap&);
- boost::statechart::result react(const MInfoRec& infoevt);
- boost::statechart::result react(const MNotifyRec& notevt);
- boost::statechart::result react(const MLogRec& logevt);
- boost::statechart::result react(const Backfilled&) {
- return discard_event();
- }
- boost::statechart::result react(const AllReplicasActivated&);
- };
-
- struct Clean : boost::statechart::state< Clean, Active >, NamedState {
- typedef boost::mpl::list<
- boost::statechart::transition< DoRecovery, WaitLocalRecoveryReserved >
- > reactions;
- explicit Clean(my_context ctx);
- void exit();
- };
-
- struct Recovered : boost::statechart::state< Recovered, Active >, NamedState {
- typedef boost::mpl::list<
- boost::statechart::transition< GoClean, Clean >,
- boost::statechart::custom_reaction< AllReplicasActivated >
- > reactions;
- explicit Recovered(my_context ctx);
- void exit();
- boost::statechart::result react(const AllReplicasActivated&) {
- post_event(GoClean());
- return forward_event();
- }
- };
-
- struct Backfilling : boost::statechart::state< Backfilling, Active >, NamedState {
- typedef boost::mpl::list<
- boost::statechart::transition< Backfilled, Recovered >,
- boost::statechart::custom_reaction< RemoteReservationRejected >
- > reactions;
- explicit Backfilling(my_context ctx);
- boost::statechart::result react(const RemoteReservationRejected& evt);
- void exit();
- };
-
- struct WaitRemoteBackfillReserved : boost::statechart::state< WaitRemoteBackfillReserved, Active >, NamedState {
- typedef boost::mpl::list<
- boost::statechart::custom_reaction< RemoteBackfillReserved >,
- boost::statechart::custom_reaction< RemoteReservationRejected >,
- boost::statechart::transition< AllBackfillsReserved, Backfilling >
- > reactions;
- set<pg_shard_t>::const_iterator backfill_osd_it;
- explicit WaitRemoteBackfillReserved(my_context ctx);
- void exit();
- boost::statechart::result react(const RemoteBackfillReserved& evt);
- boost::statechart::result react(const RemoteReservationRejected& evt);
- };
-
- struct WaitLocalBackfillReserved : boost::statechart::state< WaitLocalBackfillReserved, Active >, NamedState {
- typedef boost::mpl::list<
- boost::statechart::transition< LocalBackfillReserved, WaitRemoteBackfillReserved >
- > reactions;
- explicit WaitLocalBackfillReserved(my_context ctx);
- void exit();
- };
-
- struct NotBackfilling : boost::statechart::state< NotBackfilling, Active>, NamedState {
- typedef boost::mpl::list<
- boost::statechart::transition< RequestBackfill, WaitLocalBackfillReserved>,
- boost::statechart::custom_reaction< RemoteBackfillReserved >,
- boost::statechart::custom_reaction< RemoteReservationRejected >
- > reactions;
- explicit NotBackfilling(my_context ctx);
- void exit();
- boost::statechart::result react(const RemoteBackfillReserved& evt);
- boost::statechart::result react(const RemoteReservationRejected& evt);
- };
-
- struct NotRecovering : boost::statechart::state< NotRecovering, Active>, NamedState {
- typedef boost::mpl::list<
- boost::statechart::transition< DoRecovery, WaitLocalRecoveryReserved >
- > reactions;
- explicit NotRecovering(my_context ctx);
- void exit();
- };
-
- struct RepNotRecovering;
- struct ReplicaActive : boost::statechart::state< ReplicaActive, Started, RepNotRecovering >, NamedState {
- explicit ReplicaActive(my_context ctx);
- void exit();
-
- typedef boost::mpl::list <
- boost::statechart::custom_reaction< QueryState >,
- boost::statechart::custom_reaction< ActMap >,
- boost::statechart::custom_reaction< MQuery >,
- boost::statechart::custom_reaction< MInfoRec >,
- boost::statechart::custom_reaction< MLogRec >,
- boost::statechart::custom_reaction< Activate >
- > reactions;
- boost::statechart::result react(const QueryState& q);
- boost::statechart::result react(const MInfoRec& infoevt);
- boost::statechart::result react(const MLogRec& logevt);
- boost::statechart::result react(const ActMap&);
- boost::statechart::result react(const MQuery&);
- boost::statechart::result react(const Activate&);
- };
-
- struct RepRecovering : boost::statechart::state< RepRecovering, ReplicaActive >, NamedState {
- typedef boost::mpl::list<
- boost::statechart::transition< RecoveryDone, RepNotRecovering >,
- boost::statechart::transition< RemoteReservationRejected, RepNotRecovering >,
- boost::statechart::custom_reaction< BackfillTooFull >
- > reactions;
- explicit RepRecovering(my_context ctx);
- boost::statechart::result react(const BackfillTooFull &evt);
- void exit();
- };
-
- struct RepWaitBackfillReserved : boost::statechart::state< RepWaitBackfillReserved, ReplicaActive >, NamedState {
- typedef boost::mpl::list<
- boost::statechart::custom_reaction< RemoteBackfillReserved >,
- boost::statechart::custom_reaction< RemoteReservationRejected >
- > reactions;
- explicit RepWaitBackfillReserved(my_context ctx);
- void exit();
- boost::statechart::result react(const RemoteBackfillReserved &evt);
- boost::statechart::result react(const RemoteReservationRejected &evt);
- };
-
- struct RepWaitRecoveryReserved : boost::statechart::state< RepWaitRecoveryReserved, ReplicaActive >, NamedState {
- typedef boost::mpl::list<
- boost::statechart::custom_reaction< RemoteRecoveryReserved >
- > reactions;
- explicit RepWaitRecoveryReserved(my_context ctx);
- void exit();
- boost::statechart::result react(const RemoteRecoveryReserved &evt);
- };
-
- struct RepNotRecovering : boost::statechart::state< RepNotRecovering, ReplicaActive>, NamedState {
- typedef boost::mpl::list<
- boost::statechart::custom_reaction< RequestBackfillPrio >,
- boost::statechart::transition< RequestRecovery, RepWaitRecoveryReserved >,
- boost::statechart::transition< RecoveryDone, RepNotRecovering > // for compat with pre-reservation peers
- > reactions;
- explicit RepNotRecovering(my_context ctx);
- boost::statechart::result react(const RequestBackfillPrio &evt);
- void exit();
- };
-
- struct Recovering : boost::statechart::state< Recovering, Active >, NamedState {
- typedef boost::mpl::list <
- boost::statechart::custom_reaction< AllReplicasRecovered >,
- boost::statechart::custom_reaction< RequestBackfill >
- > reactions;
- explicit Recovering(my_context ctx);
- void exit();
- void release_reservations();
- boost::statechart::result react(const AllReplicasRecovered &evt);
- boost::statechart::result react(const RequestBackfill &evt);
- };
-
- struct WaitRemoteRecoveryReserved : boost::statechart::state< WaitRemoteRecoveryReserved, Active >, NamedState {
- typedef boost::mpl::list <
- boost::statechart::custom_reaction< RemoteRecoveryReserved >,
- boost::statechart::transition< AllRemotesReserved, Recovering >
- > reactions;
- set<pg_shard_t>::const_iterator remote_recovery_reservation_it;
- explicit WaitRemoteRecoveryReserved(my_context ctx);
- boost::statechart::result react(const RemoteRecoveryReserved &evt);
- void exit();
- };
-
- struct WaitLocalRecoveryReserved : boost::statechart::state< WaitLocalRecoveryReserved, Active >, NamedState {
- typedef boost::mpl::list <
- boost::statechart::transition< LocalRecoveryReserved, WaitRemoteRecoveryReserved >,
- boost::statechart::custom_reaction< RecoveryTooFull >
- > reactions;
- explicit WaitLocalRecoveryReserved(my_context ctx);
- void exit();
- boost::statechart::result react(const RecoveryTooFull &evt);
- };
-
- struct Activating : boost::statechart::state< Activating, Active >, NamedState {
- typedef boost::mpl::list <
- boost::statechart::transition< AllReplicasRecovered, Recovered >,
- boost::statechart::transition< DoRecovery, WaitLocalRecoveryReserved >,
- boost::statechart::transition< RequestBackfill, WaitLocalBackfillReserved >
- > reactions;
- explicit Activating(my_context ctx);
- void exit();
- };
-
- struct Stray : boost::statechart::state< Stray, Started >, NamedState {
- map<int, pair<pg_query_t, epoch_t> > pending_queries;
-
- explicit Stray(my_context ctx);
- void exit();
-
- typedef boost::mpl::list <
- boost::statechart::custom_reaction< MQuery >,
- boost::statechart::custom_reaction< MLogRec >,
- boost::statechart::custom_reaction< MInfoRec >,
- boost::statechart::custom_reaction< ActMap >,
- boost::statechart::custom_reaction< RecoveryDone >
- > reactions;
- boost::statechart::result react(const MQuery& query);
- boost::statechart::result react(const MLogRec& logevt);
- boost::statechart::result react(const MInfoRec& infoevt);
- boost::statechart::result react(const ActMap&);
- boost::statechart::result react(const RecoveryDone&) {
- return discard_event();
- }
- };
-
- struct GetLog;
-
- struct GetInfo : boost::statechart::state< GetInfo, Peering >, NamedState {
- set<pg_shard_t> peer_info_requested;
-
- explicit GetInfo(my_context ctx);
- void exit();
- void get_infos();
-
- typedef boost::mpl::list <
- boost::statechart::custom_reaction< QueryState >,
- boost::statechart::transition< GotInfo, GetLog >,
- boost::statechart::custom_reaction< MNotifyRec >,
- boost::statechart::transition< IsDown, Down >
- > reactions;
- boost::statechart::result react(const QueryState& q);
- boost::statechart::result react(const MNotifyRec& infoevt);
- };
-
- struct GotLog : boost::statechart::event< GotLog > {
- GotLog() : boost::statechart::event< GotLog >() {}
- };
-
- struct GetLog : boost::statechart::state< GetLog, Peering >, NamedState {
- pg_shard_t auth_log_shard;
- boost::intrusive_ptr<MOSDPGLog> msg;
-
- explicit GetLog(my_context ctx);
- void exit();
-
- typedef boost::mpl::list <
- boost::statechart::custom_reaction< QueryState >,
- boost::statechart::custom_reaction< MLogRec >,
- boost::statechart::custom_reaction< GotLog >,
- boost::statechart::custom_reaction< AdvMap >,
- boost::statechart::transition< IsIncomplete, Incomplete >
- > reactions;
- boost::statechart::result react(const AdvMap&);
- boost::statechart::result react(const QueryState& q);
- boost::statechart::result react(const MLogRec& logevt);
- boost::statechart::result react(const GotLog&);
- };
-
- struct WaitUpThru;
-
- struct GetMissing : boost::statechart::state< GetMissing, Peering >, NamedState {
- set<pg_shard_t> peer_missing_requested;
-
- explicit GetMissing(my_context ctx);
- void exit();
-
- typedef boost::mpl::list <
- boost::statechart::custom_reaction< QueryState >,
- boost::statechart::custom_reaction< MLogRec >,
- boost::statechart::transition< NeedUpThru, WaitUpThru >
- > reactions;
- boost::statechart::result react(const QueryState& q);
- boost::statechart::result react(const MLogRec& logevt);
- };
-
- struct WaitUpThru : boost::statechart::state< WaitUpThru, Peering >, NamedState {
- explicit WaitUpThru(my_context ctx);
- void exit();
-
- typedef boost::mpl::list <
- boost::statechart::custom_reaction< QueryState >,
- boost::statechart::custom_reaction< ActMap >,
- boost::statechart::custom_reaction< MLogRec >
- > reactions;
- boost::statechart::result react(const QueryState& q);
- boost::statechart::result react(const ActMap& am);
- boost::statechart::result react(const MLogRec& logrec);
- };
-
- struct Down : boost::statechart::state< Down, Peering>, NamedState {
- explicit Down(my_context ctx);
- typedef boost::mpl::list <
- boost::statechart::custom_reaction< QueryState >
- > reactions;
- boost::statechart::result react(const QueryState& infoevt);
- void exit();
- };
-
- struct Incomplete : boost::statechart::state< Incomplete, Peering>, NamedState {
- typedef boost::mpl::list <
- boost::statechart::custom_reaction< AdvMap >,
- boost::statechart::custom_reaction< MNotifyRec >,
- boost::statechart::custom_reaction< QueryState >
- > reactions;
- explicit Incomplete(my_context ctx);
- boost::statechart::result react(const AdvMap &advmap);
- boost::statechart::result react(const MNotifyRec& infoevt);
- boost::statechart::result react(const QueryState& infoevt);
- void exit();
- };
-
-
- RecoveryMachine machine;
- PG *pg;
-
- /// context passed in by state machine caller
- RecoveryCtx *orig_ctx;
-
- /// populated if we are buffering messages pending a flush
- boost::optional<BufferedRecoveryMessages> messages_pending_flush;
-
- /**
- * populated between start_handle() and end_handle(), points into
- * the message lists for messages_pending_flush while blocking messages
- * or into orig_ctx otherwise
- */
- boost::optional<RecoveryCtx> rctx;
-
- public:
- explicit RecoveryState(PG *pg)
- : machine(this, pg), pg(pg), orig_ctx(0) {
- machine.initiate();
- }
-
- void handle_event(const boost::statechart::event_base &evt,
- RecoveryCtx *rctx) {
- start_handle(rctx);
- machine.process_event(evt);
- end_handle();
- }
-
- void handle_event(CephPeeringEvtRef evt,
- RecoveryCtx *rctx) {
- start_handle(rctx);
- machine.process_event(evt->get_event());
- end_handle();
- }
-
- } recovery_state;