From: Sage Weil Date: Fri, 4 Sep 2009 19:49:41 +0000 (-0700) Subject: monc: explicit init(); subscribe to mdsmap on mds X-Git-Tag: v0.14~28 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c6ddbdb4671b3594f9b4d5f54b65f8525935758b;p=ceph.git monc: explicit init(); subscribe to mdsmap on mds --- diff --git a/src/client/Client.cc b/src/client/Client.cc index d214c8b4db3..9c8b73af141 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -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(); } diff --git a/src/librados.cc b/src/librados.cc index 4ee02c41f80..6544319c92a 100644 --- a/src/librados.cc +++ b/src/librados.cc @@ -300,6 +300,7 @@ bool RadosClient::init() if (!objecter) return false; + monclient.init(); monclient.mount(g_conf.client_mount_timeout); lock.Lock(); diff --git a/src/mds/MDS.cc b/src/mds/MDS.cc index cc27e39241f..f5eb963ba1e 100644 --- a/src/mds/MDS.cc +++ b/src/mds/MDS.cc @@ -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(); } diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc index a68f09bb8b0..01fa40bea34 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -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(); diff --git a/src/mon/MonClient.cc b/src/mon/MonClient.cc index 0d7d609f062..aa5768d4c41 100644 --- a/src/mon/MonClient.cc +++ b/src/mon/MonClient.cc @@ -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; diff --git a/src/mon/MonClient.h b/src/mon/MonClient.h index 93c99dfae3b..cee70673447 100644 --- a/src/mon/MonClient.h +++ b/src/mon/MonClient.h @@ -125,6 +125,9 @@ public: timer.cancel_all_events(); } + void init(); + void shutdown(); + int build_initial_monmap(); int get_monmap(); diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 88c6bd1edc9..f22033373d0 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -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; }