]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osdmap, mon: switch the params of print_tree() 4727/head
authorKefu Chai <kchai@redhat.com>
Wed, 20 May 2015 06:24:48 +0000 (14:24 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 28 May 2015 08:39:35 +0000 (01:39 -0700)
* change from
    print_tree(ostream*, Formatter*)
  to
    print_tree(Formatter*, ostream*)
  this is more consistent with other map's print
  functions. e.g.
    MDSMap::print_summary(Formatter *f, ostream *out)
* and in print_tree(Formatter* f, ostream* os),
  - `f` and `os` will be mutual exclusive.
  - will assert(0) if both of them are NULL.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/mon/OSDMonitor.cc
src/osd/OSDMap.cc
src/osd/OSDMap.h
src/tools/osdmaptool.cc

index 1e8723d9336e0a5cbdf0de33a0f720a303102783..94dd8ed2bdaa7f9de7571ed3c0f18038fe8368d7 100644 (file)
@@ -2945,11 +2945,11 @@ bool OSDMonitor::preprocess_command(MMonCommand *m)
     } else if (prefix == "osd tree") {
       if (f) {
        f->open_object_section("tree");
-       p->print_tree(NULL, f.get());
+       p->print_tree(f.get(), NULL);
        f->close_section();
        f->flush(ds);
       } else {
-       p->print_tree(&ds, NULL);
+       p->print_tree(NULL, &ds);
       }
       rdata.append(ds);
     } else if (prefix == "osd getmap") {
index 4ce89840204c9322ba2b145803bccf2f02dfe638..8d291474d3d47b58e6d2b384a4ea062ab2d5d345 100644 (file)
@@ -2561,15 +2561,16 @@ private:
   const OSDMap *osdmap;
 };
 
-void OSDMap::print_tree(ostream *out, Formatter *f) const
+void OSDMap::print_tree(Formatter *f, ostream *out) const
 {
-  if (out) {
+  if (f)
+    OSDTreeFormattingDumper(crush.get(), this).dump(f);
+  else {
+    assert(out);
     TextTable tbl;
     OSDTreePlainDumper(crush.get(), this).dump(&tbl);
     *out << tbl;
   }
-  if (f)
-    OSDTreeFormattingDumper(crush.get(), this).dump(f);
 }
 
 void OSDMap::print_summary(Formatter *f, ostream& out) const
index 3e17d30774a5505d4af140fc735268e039258056..643ee106b33aa52d755416ab9e40cc4d60d46f8d 100644 (file)
@@ -842,7 +842,7 @@ public:
   void print_pools(ostream& out) const;
   void print_summary(Formatter *f, ostream& out) const;
   void print_oneline_summary(ostream& out) const;
-  void print_tree(ostream *out, Formatter *f) const;
+  void print_tree(Formatter *f, ostream *out) const;
 
   string get_flag_string() const;
   static string get_flag_string(unsigned flags);
index fd344c99fc8d767125c60986cefffc25a16cf53b..b547b7ab98d047d7b022b2546324d4fedfc0f35a 100644 (file)
@@ -472,12 +472,12 @@ int main(int argc, const char **argv)
   if (tree) {
     if (tree_formatter) {
       tree_formatter->open_object_section("tree");
-      osdmap.print_tree(NULL, tree_formatter.get());
+      osdmap.print_tree(tree_formatter.get(), NULL);
       tree_formatter->close_section();
       tree_formatter->flush(cout);
       cout << std::endl;
     } else {
-      osdmap.print_tree(&cout, NULL);
+      osdmap.print_tree(NULL, &cout);
     }
   }
   if (modified) {