]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: add all_exit and exit commands
authorJosh Durgin <josh.durgin@dreamhost.com>
Tue, 31 May 2011 22:51:41 +0000 (15:51 -0700)
committerJosh Durgin <josh.durgin@dreamhost.com>
Tue, 7 Jun 2011 19:04:29 +0000 (12:04 -0700)
all_exit makes each daemon exit(0), for gcov data collection.
exit causes cmon to do this.

Signed-off-by: Josh Durgin <josh.durgin@dreamhost.com>
src/mon/MDSMonitor.cc
src/mon/MDSMonitor.h
src/mon/Monitor.cc
src/mon/Monitor.h
src/mon/OSDMonitor.cc
src/mon/OSDMonitor.h

index b51dd384cf54c5abc223d03b8b9ec23dcd353d54..76e6b3ff741ad43e61b1397e004052e6fed12525 100644 (file)
@@ -1179,3 +1179,15 @@ void MDSMonitor::do_stop()
   if (propose_osdmap)
     mon->osdmon()->propose_pending();
 }
+
+void MDSMonitor::send_exits()
+{
+  vector<string> 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());
+    }
+  }
+}
index e976122ee197e741943de08aa1b15bba9c7ecf11..e2675b8620f06f7201137d6cdf7a798107f1e152 100644 (file)
@@ -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;
index c27bc03e7967e02751847dd295e8a51288f360a3..2bb03a396ededac18c7e47a792619b4ae5bc51b3 100644 (file)
@@ -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<string> 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<string>& com, version_t version)
 {
index f55b44e0080a48d6f31cd48d8a13a1199fa93864..a780e004e01092d79260c2e8da8a6216a2cf9dd2 100644 (file)
@@ -220,6 +220,7 @@ public:
   void tick();
 
   void stop_cluster();
+  void send_exit_to_all();
 
   int mkfs(bufferlist& osdmapbl);
 
index 6ccaeefe4acdc195dfd9d513fc519dcd754e4f8a..ea055fbab7af432633b49c2e44b948caeae1da33 100644 (file)
@@ -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<string> 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());
+    }
+  }
+}
index 126b50132cb337ec0b6284909faac40645ace51b..4a41b31827eb4c4fe132dc8252f50bd25bfc5628 100644 (file)
@@ -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)