]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: 'osd dump' command; refactor sstream->bufferlist code a bit
authorSage Weil <sage@newdream.net>
Mon, 8 Dec 2008 18:11:12 +0000 (10:11 -0800)
committerSage Weil <sage@newdream.net>
Mon, 8 Dec 2008 18:11:12 +0000 (10:11 -0800)
src/include/buffer.h
src/mon/OSDMonitor.cc
src/mon/PGMonitor.cc
src/mon/PGMonitor.h

index 8e260279cb0da1568e8cffd38aa4c3e81adc2fa5..5319ad83cb6d884e634cb1888169f92d434b6ef9 100644 (file)
@@ -828,6 +828,14 @@ public:
           ++p) 
        _buffers.push_back(*p);
     }
+    void append(istream& in) {
+      while (!in.eof()) {
+       string s;
+       getline(in, s);
+       append(s.c_str(), s.length());
+       append("\n", 1);
+      }
+    }
     
     void append_zero(unsigned len) {
       ptr bp(len);
index 050bc86c4a67b49038f80bdf101253627f495996..4f08788d0c39e7192609ad411e4a8836fe7ce4d6 100644 (file)
@@ -878,6 +878,13 @@ bool OSDMonitor::preprocess_command(MMonCommand *m)
       ss << *this;
       r = 0;
     }
+    else if (m->cmd[1] == "dump") {
+      ss << "ok";
+      r = 0;
+      stringstream ds;
+      osdmap.print(ds);
+      rdata.append(ds);
+    }
     else if (m->cmd[1] == "getmap") {
       osdmap.encode(rdata);
       ss << "got osdmap epoch " << osdmap.get_epoch();
index d70e234b54496a0d22ba3a6dd6be656aefd107f5..2a35c276cac2214aa3a51c49245741d3d5712cea 100644 (file)
@@ -169,8 +169,10 @@ bool PGMonitor::update_from_paxos()
 
   // dump pgmap summaries?  (useful for debugging)
   if (1) {
+    stringstream ds;
+    pg_map.dump(ds);
     bufferlist d;
-    dump(d);
+    d.append(ds);
     mon->store->put_bl_sn(d, "pgmap_dump", paxosv);
   }
 
@@ -593,18 +595,6 @@ void PGMonitor::send_pg_creates()
   }
 }
 
-void PGMonitor::dump(bufferlist& bl)
-{
-  stringstream ss;
-  pg_map.dump(ss);
-  while (!ss.eof()) {
-    string s;
-    getline(ss, s);
-    bl.append(s.c_str(), s.length());
-    bl.append("\n", 1);
-  }
-}
-
 bool PGMonitor::preprocess_command(MMonCommand *m)
 {
   int r = -1;
@@ -627,9 +617,11 @@ bool PGMonitor::preprocess_command(MMonCommand *m)
       r = 0;
     }
     else if (m->cmd[1] == "dump") {
-      dump(rdata);
       ss << "ok";
       r = 0;
+      stringstream ds;
+      pg_map.dump(ds);
+      rdata.append(ds);
     }
     else if (m->cmd[1] == "scrub" && m->cmd.size() == 3) {
       pg_t pgid;
index 5ac9e2ead4a78c73ad7649a59ce41adc7e3af1b6..d8b0005f4d3abebf242d3e7fc6c8be007a82c10e 100644 (file)
@@ -39,8 +39,6 @@ class PGMonitor : public PaxosService {
 public:
   PGMap pg_map;
 
-  void dump(bufferlist& bl);
-
 private:
   PGMap::Incremental pending_inc;