From 69092735c4b25c88ded58b17b1c198fafcf5931b Mon Sep 17 00:00:00 2001 From: Josh Durgin Date: Tue, 31 May 2011 15:51:41 -0700 Subject: [PATCH] mon: add all_exit and exit commands all_exit makes each daemon exit(0), for gcov data collection. exit causes cmon to do this. Signed-off-by: Josh Durgin --- src/mon/MDSMonitor.cc | 12 ++++++++++++ src/mon/MDSMonitor.h | 2 ++ src/mon/Monitor.cc | 21 +++++++++++++++++++++ src/mon/Monitor.h | 1 + src/mon/OSDMonitor.cc | 12 +++++++++++- src/mon/OSDMonitor.h | 2 ++ 6 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc index b51dd384cf54c..76e6b3ff741ad 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -1179,3 +1179,15 @@ void MDSMonitor::do_stop() if (propose_osdmap) mon->osdmon()->propose_pending(); } + +void MDSMonitor::send_exits() +{ + vector cmd; + cmd.push_back("exit"); + cmd.push_back("immediately"); + for (unsigned i = 0; i < mdsmap.get_max_mds(); ++i) { + if (mdsmap.is_active(i)) { + mon->send_command(mdsmap.get_inst(i), cmd, paxos->get_version()); + } + } +} diff --git a/src/mon/MDSMonitor.h b/src/mon/MDSMonitor.h index e976122ee197e..e2675b8620f06 100644 --- a/src/mon/MDSMonitor.h +++ b/src/mon/MDSMonitor.h @@ -93,6 +93,8 @@ class MDSMonitor : public PaxosService { bool preprocess_command(MMonCommand *m); bool prepare_command(MMonCommand *m); + void send_exits(); + // beacons struct beacon_info_t { utime_t stamp; diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index c27bc03e7967e..2bb03a396eded 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -328,6 +328,15 @@ void Monitor::handle_command(MMonCommand *m) reply_command(m, 0, "initiating cluster shutdown", 0); return; } + if (m->cmd[0] == "all_exit") { + send_exit_to_all(); + reply_command(m, 0, "exiting", 0); + return; + } + if (m->cmd[0] == "exit") { + reply_command(m, 0, "exiting", 0); + exit(0); + } if (m->cmd[0] == "_injectargs") { dout(0) << "parsing injected options '" << m->cmd[1] << "'" << dendl; @@ -606,6 +615,18 @@ void Monitor::inject_args(const entity_inst_t& inst, string& args) } } +void Monitor::send_exit_to_all() +{ + dout(10) << "send_exit_to_all " << dendl; + osdmon()->send_exits(); + mdsmon()->send_exits(); + vector cmd; + cmd.push_back("exit"); + for (unsigned i = 0; i < monmap->size(); i++) { + send_command(monmap->get_inst(i), cmd, 0); + } +} + void Monitor::send_command(const entity_inst_t& inst, const vector& com, version_t version) { diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index f55b44e0080a4..a780e004e0109 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -220,6 +220,7 @@ public: void tick(); void stop_cluster(); + void send_exit_to_all(); int mkfs(bufferlist& osdmapbl); diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 6ccaeefe4acdc..ea055fbab7af4 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -520,7 +520,6 @@ void OSDMonitor::_reported_failure(MOSDFailure *m) send_latest(m, m->get_epoch()); } - // boot -- bool OSDMonitor::preprocess_boot(MOSDBoot *m) @@ -2037,3 +2036,14 @@ void OSDMonitor::_pool_op(MPoolOp *m, int replyCode, epoch_t epoch, bufferlist * mon->send_reply(m, reply); m->put(); } + +void OSDMonitor::send_exits() +{ + vector cmd; + cmd.push_back("exit"); + for (int i = 0; i < osdmap.get_max_osd(); ++i) { + if (osdmap.is_up(i)) { + mon->send_command(osdmap.get_inst(i), cmd, paxos->get_version()); + } + } +} diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index 126b50132cb33..4a41b31827eb4 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -178,6 +178,8 @@ private: void check_subs(); void check_sub(Subscription *sub); + void send_exits(); + void add_flag(int flag) { if (!(osdmap.flags & flag)) { if (pending_inc.new_flags < 0) -- 2.39.5