]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
monc: explicit init(); subscribe to mdsmap on mds
authorSage Weil <sage@newdream.net>
Fri, 4 Sep 2009 19:49:41 +0000 (12:49 -0700)
committerSage Weil <sage@newdream.net>
Fri, 4 Sep 2009 19:49:41 +0000 (12:49 -0700)
src/client/Client.cc
src/librados.cc
src/mds/MDS.cc
src/mon/MDSMonitor.cc
src/mon/MonClient.cc
src/mon/MonClient.h
src/osd/OSD.cc

index d214c8b4db3827926b438b608edd2569fdbbc326..9c8b73af141fb2cb43dc747226483a89b65b7063 100644 (file)
@@ -259,6 +259,8 @@ void Client::init()
   messenger->set_dispatcher(this);
   link_dispatcher(monclient);
 
+  monclient->init();
+
   tick();
 
   // do logger crap only once per process.
@@ -289,6 +291,7 @@ void Client::shutdown()
 {
   dout(1) << "shutdown" << dendl;
   objecter->shutdown();
+  monclient->shutdown();
   messenger->shutdown();
 }
 
index 4ee02c41f80cfd4f49513f89353703638d69fdae..6544319c92a515fba867b18bf758261795e4772b 100644 (file)
@@ -300,6 +300,7 @@ bool RadosClient::init()
   if (!objecter)
     return false;
 
+  monclient.init();
   monclient.mount(g_conf.client_mount_timeout);
 
   lock.Lock();
index cc27e39241f583721860e82a9e978797d484d327..f5eb963ba1ec2266dcf7411131742fad27f6269d 100644 (file)
@@ -379,8 +379,11 @@ int MDS::init()
   monc->set_messenger(messenger);
   link_dispatcher(monc);
 
+  monc->init();
   monc->get_monmap();
 
+  monc->sub_want("mdsmap", 0);
+
   mds_lock.Lock();
 
   // starting beacon.  this will induce an MDSMap from the monitor
@@ -487,9 +490,6 @@ void MDS::beacon_send()
           << " (currently " << ceph_mds_state_name(state) << ")"
           << dendl;
 
-  // pick new random mon if we have any outstanding beacons...
-  bool newmon = beacon_seq_stamp.size();
-
   beacon_seq_stamp[beacon_last_seq] = g_clock.now();
   
   MMDSBeacon *beacon = new MMDSBeacon(monc->get_fsid(), name, mdsmap->get_epoch(), 
@@ -497,8 +497,6 @@ void MDS::beacon_send()
   beacon->set_standby_for_rank(standby_for_rank);
   beacon->set_standby_for_name(standby_for_name);
 
-  if (newmon)
-    monc->pick_new_mon();
   monc->send_mon_message(beacon);
 
   // schedule next sender
@@ -603,13 +601,7 @@ void MDS::handle_mds_map(MMDSMap *m)
   mdsmap = new MDSMap;
   mdsmap->decode(m->get_encoded());
 
-  // do i exist?
-  if (mdsmap->is_dne(messenger->get_myaddr())) {
-    dout(1) << "handle_mds_map i (" << addr
-           << ") dne in the mdsmap, killing myself" << dendl;
-    suicide();
-    goto out;
-  }
+  monc->sub_got("mdsmap", mdsmap->get_epoch());
 
   // see who i am
   addr = messenger->get_myaddr();
@@ -617,6 +609,17 @@ void MDS::handle_mds_map(MMDSMap *m)
   state = mdsmap->get_state(addr);
   dout(10) << "map says i am " << addr << " mds" << whoami << " state " << ceph_mds_state_name(state) << dendl;
 
+  if (whoami < 0) {
+    if (want_state == MDSMap::STATE_BOOT) {
+      dout(10) << "not in map yet" << dendl;
+    } else {
+      dout(1) << "handle_mds_map i (" << addr
+             << ") dne in the mdsmap, killing myself" << dendl;
+      suicide();
+    }
+    goto out;
+  }
+
   if (state != oldstate)
     last_state = oldstate;
 
@@ -1142,6 +1145,8 @@ void MDS::suicide()
   // shut down messenger
   unlink_dispatcher(&logclient);
   messenger->shutdown();
+
+  monc->shutdown();
 }
 
 
index a68f09bb8b0d92e2ee7929a653acb555ff9dab9e..01fa40bea34580e171d964200dc2d56291ec9564 100644 (file)
@@ -94,7 +94,7 @@ bool MDSMonitor::update_from_paxos()
 
   if (mon->is_leader()) {
     // bcast map to mds
-    bcast_latest_mds();
+    //bcast_latest_mds();
   }
 
   send_to_waiting();
index 0d7d609f0627d034732c606b9e9a4dc3b34c9f76..aa5768d4c41cc1e14fd583b53195395f5a4d467c 100644 (file)
@@ -198,6 +198,20 @@ void MonClient::_send_mount()
   mount_started = g_clock.now();
 }
 
+void MonClient::init()
+{
+  dout(10) << "init" << dendl;
+  messenger->set_dispatcher(this);
+
+  Mutex::Locker l(monc_lock);
+  timer.add_event_after(10.0, new C_Tick(this));
+}
+
+void MonClient::shutdown()
+{
+  timer.cancel_all_events();
+}
+
 int MonClient::mount(double mount_timeout)
 {
   Mutex::Locker lock(monc_lock);
@@ -209,10 +223,6 @@ int MonClient::mount(double mount_timeout)
 
   // only first mounter does the work
   if (!mounters) {
-    // init
-    messenger->set_dispatcher(this);
-    timer.add_event_after(10.0, new C_Tick(this));
-  
     _send_mount();
   } else
     dout(5) << "additional mounter" << dendl;
index 93c99dfae3b48acaf4668d5125a7e9ac05523080..cee70673447dbd5564340d34dd8d82d9ad7d8d60 100644 (file)
@@ -125,6 +125,9 @@ public:
     timer.cancel_all_events();
   }
 
+  void init();
+  void shutdown();
+
   int build_initial_monmap();
   int get_monmap();
 
index 88c6bd1edc979032bd00080687dee4619b852e7a..f22033373d040fa80e19f0d08518f94d8e917c55 100644 (file)
@@ -419,6 +419,8 @@ int OSD::init()
   link_dispatcher(&logclient);
   heartbeat_messenger->set_dispatcher(&heartbeat_dispatcher);
   
+  monc->init();
+
   // announce to monitor i exist and have booted.
   do_mon_report();
   
@@ -535,6 +537,9 @@ int OSD::shutdown()
   messenger->shutdown();
   if (heartbeat_messenger)
     heartbeat_messenger->shutdown();
+
+  monc->shutdown();
+
   return r;
 }