#define dout_prefix (*_dout << context< RecoveryMachine >().pg->gen_prefix() \
<< "state<" << get_state_name() << ">: ")
+/*------Initial-------*/
+PG::RecoveryState::Initial::Initial(my_context ctx) : my_base(ctx) {
+ state_name = "Initial";
+ dout(10) << "entered state" << dendl;
+}
+
/*------Started-------*/
+PG::RecoveryState::Started::Started(my_context ctx) : my_base(ctx) {
+ state_name = "Started";
+ dout(10) << "entered state" << dendl;
+}
+
boost::statechart::result
PG::RecoveryState::Started::react(const AdvMap& advmap) {
dout(10) << "Started advmap" << dendl;
}
/*--------Reset---------*/
+PG::RecoveryState::Reset::Reset(my_context ctx) : my_base(ctx) {
+ state_name = "Reset";
+ dout(10) << "entered state" << dendl;
+}
+
boost::statechart::result
PG::RecoveryState::Reset::react(const AdvMap& advmap) {
PG *pg = context< RecoveryMachine >().pg;
/*-------Start---------*/
PG::RecoveryState::Start::Start(my_context ctx) : my_base(ctx) {
+ state_name = "Start";
+ dout(10) << "entered state" << dendl;
PG *pg = context< RecoveryMachine >().pg;
if (pg->is_primary()) {
dout(1) << "transitioning to Primary" << dendl;
}
/*---------Primary--------*/
+PG::RecoveryState::Primary::Primary(my_context ctx) : my_base(ctx) {
+ state_name = "Primary";
+ dout(10) << "entered state" << dendl;
+}
+
boost::statechart::result
PG::RecoveryState::Primary::react(const BacklogComplete&) {
PG *pg = context< RecoveryMachine >().pg;
/*---------Peering--------*/
PG::RecoveryState::Peering::Peering(my_context ctx)
: my_base(ctx) {
+ state_name = "Peering";
+ dout(10) << "entered state" << dendl;
PG *pg = context< RecoveryMachine >().pg;
assert(!pg->is_active());
assert(!pg->is_peering());
/*---------Active---------*/
PG::RecoveryState::Active::Active(my_context ctx) : my_base(ctx) {
+ state_name = "Active";
+ dout(10) << "entered state" << dendl;
PG *pg = context< RecoveryMachine >().pg;
assert(pg->is_primary());
dout(10) << "In Active, about to call activate" << dendl;
/*------ReplicaActive-----*/
PG::RecoveryState::ReplicaActive::ReplicaActive(my_context ctx)
: my_base(ctx) {
+ state_name = "ReplicaActive";
dout(10) << "In ReplicaActive, about to call activate" << dendl;
PG *pg = context< RecoveryMachine >().pg;
map< int, map< pg_t, Query> > query_map;
/*-------Stray---*/
PG::RecoveryState::Stray::Stray(my_context ctx)
: my_base(ctx), backlog_requested(false) {
+ state_name = "Stray";
+ dout(10) << "entered state" << dendl;
PG *pg = context< RecoveryMachine >().pg;
assert(!pg->is_active());
assert(!pg->is_peering());
/*--------GetInfo---------*/
PG::RecoveryState::GetInfo::GetInfo(my_context ctx) : my_base(ctx) {
+ state_name = "GetInfo";
+ dout(10) << "entered state" << dendl;
PG *pg = context< RecoveryMachine >().pg;
pg->generate_past_intervals();
auto_ptr<PgPriorSet> &prior_set = context< Peering >().prior_set;
/*------GetLog------------*/
PG::RecoveryState::GetLog::GetLog(my_context ctx) :
my_base(ctx), newest_update_osd(-1), need_backlog(false), msg(0) {
+ state_name = "GetLog";
+ dout(10) << "entered state" << dendl;
PG *pg = context< RecoveryMachine >().pg;
dout(10) << "In GetLog, selecting log location" << dendl;
eversion_t newest_update;
/*------GetMissing--------*/
PG::RecoveryState::GetMissing::GetMissing(my_context ctx) : my_base(ctx) {
+ state_name = "GetMissing";
+ dout(10) << "entered state" << dendl;
PG *pg = context< RecoveryMachine >().pg;
map<int, Missing> &peer_missing = pg->peer_missing;
for (vector<int>::iterator i = pg->acting.begin()++;
/* States */
struct NamedState {
- virtual const char *get_state_name() = 0;
+ string state_name;
+ virtual string &get_state_name() { return state_name; }
virtual ~NamedState() {}
};
struct Crashed :
boost::statechart::state< Crashed, RecoveryMachine >, NamedState {
- const char *get_state_name() { return "Crashed"; }
Crashed(my_context ctx) : my_base(ctx) { assert(0); }
};
struct Started;
struct Initial :
- boost::statechart::simple_state< Initial, RecoveryMachine >, NamedState {
- const char *get_state_name() { return "Initial"; }
+ boost::statechart::state< Initial, RecoveryMachine >, NamedState {
typedef boost::mpl::list <
boost::statechart::transition< Initialize, Started >,
boost::statechart::transition< MNotifyRec, Crashed >,
boost::statechart::transition< AdvMap, Crashed >,
boost::statechart::transition< ActMap, Crashed >
> reactions;
+ Initial(my_context ctx);
};
struct Reset :
- boost::statechart::simple_state< Reset, RecoveryMachine >, NamedState {
- const char *get_state_name() { return "Reset"; }
+ boost::statechart::state< Reset, RecoveryMachine >, NamedState {
typedef boost::mpl::list <
boost::statechart::custom_reaction< AdvMap >,
boost::statechart::custom_reaction< ActMap >,
> reactions;
boost::statechart::result react(const AdvMap&);
boost::statechart::result react(const ActMap&);
+ Reset(my_context ctx);
};
struct Start;
struct Started :
- boost::statechart::simple_state< Started, RecoveryMachine, Start >, NamedState {
- const char *get_state_name() { return "Started"; }
+ boost::statechart::state< Started, RecoveryMachine, Start >, NamedState {
typedef boost::mpl::list <
boost::statechart::custom_reaction< AdvMap >,
boost::statechart::transition< ActMap, Crashed >,
boost::statechart::transition< Activate, Crashed >
> reactions;
boost::statechart::result react(const AdvMap&);
+ Started(my_context ctx);
};
struct MakePrimary : boost::statechart::event< MakePrimary > {};
struct Stray;
struct Start :
boost::statechart::state< Start, Started >, NamedState {
- const char *get_state_name() { return "Start"; }
typedef boost::mpl::list <
boost::statechart::transition< MakePrimary, Primary >,
boost::statechart::transition< MakeStray, Stray >
struct Pending;
struct NeedNewMap : boost::statechart::event< NeedNewMap > {};
struct Primary :
- boost::statechart::simple_state< Primary, Started, Peering >, NamedState {
- const char *get_state_name() { return "Primary"; }
+ boost::statechart::state< Primary, Started, Peering >, NamedState {
typedef boost::mpl::list <
boost::statechart::custom_reaction< ActMap >,
boost::statechart::custom_reaction< BacklogComplete >,
boost::statechart::result react(const BacklogComplete&);
boost::statechart::result react(const ActMap&);
boost::statechart::result react(const MNotifyRec&);
+ Primary(my_context ctx);
};
struct Pending :
struct Active;
struct Peering :
boost::statechart::state< Peering, Primary, GetInfo >, NamedState {
- const char *get_state_name() { return "Peering"; }
typedef boost::mpl::list <
boost::statechart::transition< Activate, Active >,
boost::statechart::custom_reaction< AdvMap >
struct Active :
boost::statechart::state< Active, Primary >, NamedState {
- const char *get_state_name() { return "Active"; }
typedef boost::mpl::list <
boost::statechart::custom_reaction< ActMap >,
boost::statechart::custom_reaction< AdvMap >,
};
struct ReplicaActive : boost::statechart::state< ReplicaActive, Started >, NamedState {
- const char *get_state_name() { return "ReplicaActive"; }
typedef boost::mpl::list <
boost::statechart::transition< MQuery, Crashed >,
boost::statechart::custom_reaction< ActMap >,
};
struct Stray : boost::statechart::state< Stray, Started >, NamedState {
- const char *get_state_name() { return "Stray"; }
bool backlog_requested;
map<int, Query> pending_queries;
typedef boost::mpl::list <
struct GotInfo : boost::statechart::event< GotInfo > {};
struct GetInfo :
boost::statechart::state< GetInfo, Peering >, NamedState {
- const char *get_state_name() { return "Peering::GetInfo"; }
set<int> peer_info_requested;
typedef boost::mpl::list <
boost::statechart::transition< GotInfo, GetLog >,
struct GotLog : boost::statechart::event< GotLog > {};
struct GetLog :
boost::statechart::state< GetLog, Peering >, NamedState {
- const char *get_state_name() { return "Peering::GetLog"; }
int newest_update_osd;
bool need_backlog;
bool wait_on_backlog;
struct GetMissing :
boost::statechart::state< GetMissing, Peering >, NamedState {
- const char *get_state_name() { return "Peering::GetMissing"; }
set<int> peer_missing_requested;
typedef boost::mpl::list <
boost::statechart::custom_reaction< MLogRec >