]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: plain text prints for FSMap/Filesystem
authorJohn Spray <john.spray@redhat.com>
Wed, 16 Mar 2016 12:51:23 +0000 (12:51 +0000)
committerJohn Spray <john.spray@redhat.com>
Tue, 22 Mar 2016 12:08:49 +0000 (12:08 +0000)
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 <john.spray@redhat.com>
src/mds/FSMap.cc
src/mds/MDSMap.cc
src/mds/MDSMap.h

index 482ef0023081760f59a0749de6facbe7618652a1..fb667899baddedc556fa7915c33e129c27dc53d0 100644 (file)
@@ -75,12 +75,29 @@ void FSMap::generate_test_instances(list<FSMap*>& 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
index 6208ee050bdc9f2523c86d4c7b31c7ca1e929073..6732fe20ca2869b6802bd408f61aca0bbdf1c58c 100644 (file)
@@ -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<mds_info_t*>& 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";
   }
 }
 
index 314fe4ed9a15c801d69520db87ababebfaaeda61..90a3f894f3d200f026769f5272b609abec361753 100644 (file)
@@ -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<mds_info_t*>& ls);
   private:
     void encode_versioned(bufferlist& bl, uint64_t features) const;