]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osdmaptool: kludge to load a range of maps into memory
authorSage Weil <sage@newdream.net>
Wed, 25 Apr 2012 22:44:24 +0000 (15:44 -0700)
committerSage Weil <sage@newdream.net>
Fri, 27 Apr 2012 01:49:19 +0000 (18:49 -0700)
Signed-off-by: Sage Weil <sage@newdream.net>
src/osdmaptool.cc

index 6dc62b46e5415ade15c3d30c3a94a17e1b60ef7c..3fe61d73974d5bc18f3fcef42e3cff9c3f301165 100644 (file)
@@ -66,6 +66,8 @@ int main(int argc, const char **argv)
   std::string export_crush, import_crush, test_map_pg, test_map_object;
   list<entity_addr_t> add, rm;
   bool test_crush = false;
+  int range_first = -1;
+  int range_last = -1;
 
   std::string val;
   std::ostringstream err;
@@ -115,6 +117,8 @@ int main(int argc, const char **argv)
       test_map_object = val;
     } else if (ceph_argparse_flag(args, i, "--test_crush", (char*)NULL)) {
       test_crush = true;
+    } else if (ceph_argparse_withint(args, i, &range_first, &err, "--range_first", (char*)NULL)) {
+    } else if (ceph_argparse_withint(args, i, &range_last, &err, "--range_last", (char*)NULL)) {
     } else {
       ++i;
     }
@@ -128,6 +132,26 @@ int main(int argc, const char **argv)
     usage();
   }
   fn = args[0];
+
+  if (range_first >= 0 && range_last >= 0) {
+    set<OSDMap*> maps;
+    OSDMap *prev = NULL;
+    for (int i=range_first; i <= range_last; i++) {
+      ostringstream f;
+      f << fn << "/" << i;
+      bufferlist bl;
+      string error, s = f.str();
+      bl.read_file(s.c_str(), &error);
+      cout << s << " got " << bl.length() << " bytes" << std::endl;
+      OSDMap *o = new OSDMap;
+      o->decode(bl);
+      maps.insert(o);
+      if (prev)
+       OSDMap::dedup(prev, o);
+      prev = o;
+    }
+    exit(0);
+  }
   
   OSDMap osdmap;
   bufferlist bl;