From: John Spray Date: Wed, 16 Mar 2016 12:51:23 +0000 (+0000) Subject: mds: plain text prints for FSMap/Filesystem X-Git-Tag: v10.1.1~114^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bb7a2868676efcecfae1d64427c5a6b37d8ae5e2;p=ceph.git mds: plain text prints for FSMap/Filesystem These were just dumping JSON as a placeholder. Not strictly necessary to have the extra non-machine-readable variants of these outputs, but some users will probably appreciate it, so why not. Signed-off-by: John Spray --- diff --git a/src/mds/FSMap.cc b/src/mds/FSMap.cc index 482ef0023081..fb667899badd 100644 --- a/src/mds/FSMap.cc +++ b/src/mds/FSMap.cc @@ -75,12 +75,29 @@ void FSMap::generate_test_instances(list& ls) void FSMap::print(ostream& out) const { - // TODO add a non-json print? - JSONFormatter f(true); - f.open_object_section("fsmap"); - dump(&f); - f.close_section(); - f.flush(out); + out << "e" << epoch << std::endl; + out << "enable_multiple: " << enable_multiple << std::endl; + out << "compat: " << enable_multiple << std::endl; + out << " " << std::endl; + + if (filesystems.empty()) { + out << "No filesystems configured" << std::endl; + return; + } + + for (const auto &fs : filesystems) { + fs.second->print(out); + out << " " << std::endl << " " << std::endl; // Space out a bit + } + + if (!standby_daemons.empty()) { + out << "Standby daemons:" << std::endl << " " << std::endl; + } + + for (const auto &p : standby_daemons) { + p.second.print_summary(out); + out << std::endl; + } } @@ -427,10 +444,9 @@ int FSMap::parse_filesystem( void Filesystem::print(std::ostream &out) const { - // TODO add a non-json print? - JSONFormatter f; - dump(&f); - f.flush(out); + out << "Filesystem '" << mds_map.fs_name + << "' (" << fscid << ")" << std::endl; + mds_map.print(out); } mds_gid_t FSMap::find_standby_for(mds_role_t role, const std::string& name) const diff --git a/src/mds/MDSMap.cc b/src/mds/MDSMap.cc index 6208ee050bdc..6732fe20ca28 100644 --- a/src/mds/MDSMap.cc +++ b/src/mds/MDSMap.cc @@ -92,6 +92,33 @@ void MDSMap::mds_info_t::dump(Formatter *f) const f->dump_unsigned("features", mds_features); } +void MDSMap::mds_info_t::print_summary(ostream &out) const +{ + out << global_id << ":\t" + << addr + << " '" << name << "'" + << " mds." << rank + << "." << inc + << " " << ceph_mds_state_name(state) + << " seq " << state_seq; + if (laggy()) { + out << " laggy since " << laggy_since; + } + if (standby_for_rank != -1 || + !standby_for_name.empty()) { + out << " (standby for"; + //if (standby_for_rank >= 0) + out << " rank " << standby_for_rank; + if (!standby_for_name.empty()) { + out << " '" << standby_for_name << "'"; + } + out << ")"; + } + if (!export_targets.empty()) { + out << " export_targets=" << export_targets; + } +} + void MDSMap::mds_info_t::generate_test_instances(list& ls) { mds_info_t *sample = new mds_info_t(); @@ -210,28 +237,8 @@ void MDSMap::print(ostream& out) const for (const auto &p : foo) { const mds_info_t& info = mds_info.at(p.second); - - out << p.second << ":\t" - << info.addr - << " '" << info.name << "'" - << " mds." << info.rank - << "." << info.inc - << " " << ceph_mds_state_name(info.state) - << " seq " << info.state_seq; - if (info.laggy()) - out << " laggy since " << info.laggy_since; - if (info.standby_for_rank != -1 || - !info.standby_for_name.empty()) { - out << " (standby for"; - //if (info.standby_for_rank >= 0) - out << " rank " << info.standby_for_rank; - if (!info.standby_for_name.empty()) - out << " '" << info.standby_for_name << "'"; - out << ")"; - } - if (!info.export_targets.empty()) - out << " export_targets=" << info.export_targets; - out << "\n"; + info.print_summary(out); + out << "\n"; } } diff --git a/src/mds/MDSMap.h b/src/mds/MDSMap.h index 314fe4ed9a15..90a3f894f3d2 100644 --- a/src/mds/MDSMap.h +++ b/src/mds/MDSMap.h @@ -160,6 +160,7 @@ public: } void decode(bufferlist::iterator& p); void dump(Formatter *f) const; + void print_summary(ostream &out) const; static void generate_test_instances(list& ls); private: void encode_versioned(bufferlist& bl, uint64_t features) const;