From: Kefu Chai Date: Wed, 20 May 2015 06:24:48 +0000 (+0800) Subject: osdmap, mon: switch the params of print_tree() X-Git-Tag: v9.0.2~85^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F4727%2Fhead;p=ceph.git osdmap, mon: switch the params of print_tree() * 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 --- diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 1e8723d9336e..94dd8ed2bdaa 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -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") { diff --git a/src/osd/OSDMap.cc b/src/osd/OSDMap.cc index 4ce89840204c..8d291474d3d4 100644 --- a/src/osd/OSDMap.cc +++ b/src/osd/OSDMap.cc @@ -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 diff --git a/src/osd/OSDMap.h b/src/osd/OSDMap.h index 3e17d30774a5..643ee106b33a 100644 --- a/src/osd/OSDMap.h +++ b/src/osd/OSDMap.h @@ -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); diff --git a/src/tools/osdmaptool.cc b/src/tools/osdmaptool.cc index fd344c99fc8d..b547b7ab98d0 100644 --- a/src/tools/osdmaptool.cc +++ b/src/tools/osdmaptool.cc @@ -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) {