]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: pull initial monmap from monmap/latest OR mkfs/monmap
authorSage Weil <sage@newdream.net>
Fri, 11 Nov 2011 18:15:23 +0000 (10:15 -0800)
committerSage Weil <sage@newdream.net>
Fri, 11 Nov 2011 18:15:23 +0000 (10:15 -0800)
Signed-off-by: Sage Weil <sage@newdream.net>
src/ceph_mon.cc

index 8301c6650d86e4997214f8416eafe1ee3dba8f1f..a9d6138869371a0143d543e7efd3d764b0afe7d4 100644 (file)
@@ -226,19 +226,27 @@ int main(int argc, const char **argv)
   // monmap?
   MonMap monmap;
   {
+    bufferlist mapbl;
     bufferlist latest;
-    store.get_bl_ss(latest, "monmap/latest", 0);
-    if (latest.length() == 0) {
-      cerr << "mon fs missing 'monmap'" << std::endl;
-      exit(1);
+    store.get_bl_ss(latest, "monmap", "latest");
+    if (latest.length() > 0) {
+      bufferlist::iterator p = latest.begin();
+      version_t v;
+      ::decode(v, p);
+      ::decode(mapbl, p);
+    } else {
+      store.get_bl_ss(mapbl, "mkfs", "monmap");
+      if (mapbl.length() == 0) {
+       cerr << "mon fs missing 'monmap/latest' and 'mkfs/monmap'" << std::endl;
+       exit(1);
+      }
+    }
+    try {
+      monmap.decode(mapbl);
+    }
+    catch (const buffer::error& e) {
+      cerr << "can't decode monmap: " << e.what() << std::endl;
     }
-    bufferlist::iterator p = latest.begin();
-    version_t v;
-    ::decode(v, p);
-    bufferlist mapbl;
-    ::decode(mapbl, p);
-    monmap.decode(mapbl);
-    assert(v == monmap.get_epoch());
   }
 
   if (!monmap.contains(g_conf->name.get_id())) {
@@ -252,7 +260,7 @@ int main(int argc, const char **argv)
   g_conf->get_my_sections(my_sections);
   std::string mon_addr_str;
   if (g_conf->get_val_from_conf_file(my_sections, "mon addr",
-                                   mon_addr_str, true) == 0)
+                                    mon_addr_str, true) == 0)
   {
     if (conf_addr.parse(mon_addr_str.c_str()) && (ipaddr != conf_addr)) {
       cerr << "WARNING: 'mon addr' config option " << conf_addr