diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 3554798112f..bfeeab9e4b3 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -674,13 +674,8 @@ void Monitor::slurp() bootstrap(); } -void Monitor::handle_probe_slurp(MMonProbe *m) +MMonProbe *Monitor::fill_probe_data(MMonProbe *m, Paxos *pax) { - dout(10) << "handle_probe_slurp " << *m << dendl; - - Paxos *pax = get_paxos_by_name(m->machine_name); - assert(pax); - MMonProbe *r = new MMonProbe(monmap->fsid, MMonProbe::OP_DATA, name); r->machine_name = m->machine_name; r->oldest_version = pax->get_first_committed(); @@ -691,16 +686,26 @@ void Monitor::handle_probe_slurp(MMonProbe *m) for (; v <= pax->get_version(); v++) { len += store->get_bl_sn(r->paxos_values[m->machine_name][v], m->machine_name.c_str(), v); for (list::iterator p = pax->extra_state_dirs.begin(); - p != pax->extra_state_dirs.end(); - ++p) { + p != pax->extra_state_dirs.end(); + ++p) { len += store->get_bl_sn(r->paxos_values[*p][v], p->c_str(), v); } if (len >= g_conf->mon_slurp_bytes) break; } + return r; +} + +void Monitor::handle_probe_slurp(MMonProbe *m) +{ + dout(10) << "handle_probe_slurp " << *m << dendl; + + Paxos *pax = get_paxos_by_name(m->machine_name); + assert(pax); + + MMonProbe *r = fill_probe_data(m, pax); messenger->send_message(r, m->get_connection()); - m->put(); } @@ -711,14 +716,10 @@ void Monitor::handle_probe_slurp_latest(MMonProbe *m) Paxos *pax = get_paxos_by_name(m->machine_name); assert(pax); - MMonProbe *r = new MMonProbe(monmap->fsid, MMonProbe::OP_DATA, name); - r->machine_name = m->machine_name; - r->oldest_version = pax->get_first_committed(); - r->newest_version = pax->get_version(); + MMonProbe *r = fill_probe_data(m, pax); r->latest_version = pax->get_stashed(r->latest_value); messenger->send_message(r, m->get_connection()); - m->put(); } diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index e25ab0fcb7f..d16207b46d0 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -258,6 +258,16 @@ public: void handle_probe_slurp(MMonProbe *m); void handle_probe_slurp_latest(MMonProbe *m); void handle_probe_data(MMonProbe *m); + /* Given an MMonProbe and associated Paxos machine, create a reply, + * fill it with the missing Paxos states and current commit pointers + * + * @param m The incoming MMonProbe. We use this to determine the range + * of paxos states to include in the reply. + * @param pax The Paxos state machine which m is associated with. + * + * @returns A new MMonProbe message, initialized as OP_DATA, and filled + * with the necessary Paxos states. */ + MMonProbe *fill_probe_data(MMonProbe *m, Paxos *pax); // request routing struct RoutedRequest {