]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/MgrMap: implement dump, add to ceph-dencoder
authorSage Weil <sage@redhat.com>
Thu, 30 Mar 2017 16:19:41 +0000 (12:19 -0400)
committerSage Weil <sage@redhat.com>
Thu, 30 Mar 2017 21:57:35 +0000 (17:57 -0400)
Signed-off-by: Sage Weil <sage@redhat.com>
src/mon/MgrMap.h
src/test/encoding/types.h

index 167573da47460b6d739b4424ad37d31fd33a63cc..1fd0500131c3aa31bbfea8e98bfcd506745b8ff9 100644 (file)
@@ -98,43 +98,48 @@ public:
     DECODE_FINISH(p);
   }
 
+  void dump(Formatter *f) const {
+    f->dump_int("epoch", epoch);
+    f->dump_int("active_gid", get_active_gid());
+    f->dump_string("active_name", get_active_name());
+    f->dump_stream("active_addr") << active_addr;
+    f->dump_bool("available", available);
+    f->open_array_section("standbys");
+    for (const auto &i : standbys) {
+      f->open_object_section("standby");
+      f->dump_int("gid", i.second.gid);
+      f->dump_string("name", i.second.name);
+      f->close_section();
+    }
+    f->close_section();
+  }
+
+  static void generate_test_instances(list<MgrMap*> &l) {
+    l.push_back(new MgrMap);
+  }
+
   void print_summary(Formatter *f, std::ostream *ss) const
   {
     // One or the other, not both
     assert((ss != nullptr) != (f != nullptr));
-
     if (f) {
-      f->dump_int("active_gid", get_active_gid());
-      f->dump_string("active_name", get_active_name());
+      dump(f);
     } else {
       if (get_active_gid() != 0) {
-        *ss << "active: " << get_active_name() << " ";
+       *ss << "active: " << get_active_name() << " ";
       } else {
-        *ss << "no daemons active ";
+       *ss << "no daemons active ";
       }
-    }
-
-
-    if (f) {
-      f->open_array_section("standbys");
-      for (const auto &i : standbys) {
-        f->open_object_section("standby");
-        f->dump_int("gid", i.second.gid);
-        f->dump_string("name", i.second.name);
-        f->close_section();
-      }
-      f->close_section();
-    } else {
       if (standbys.size()) {
-        *ss << "standbys: ";
-        bool first = true;
-        for (const auto &i : standbys) {
-          if (!first) {
-            *ss << ", ";
-          }
-          *ss << i.second.name;
-          first = false;
-        }
+       *ss << "standbys: ";
+       bool first = true;
+       for (const auto &i : standbys) {
+         if (!first) {
+           *ss << ", ";
+         }
+         *ss << i.second.name;
+         first = false;
+       }
       }
     }
   }
index a3736bdffc5575cb7c7cf9f72a3816afb456d3b5..1d7694169d2f246d628b02d802d595b454372135 100644 (file)
@@ -154,6 +154,9 @@ TYPE_FEATUREFUL(MonMap)
 #include "mon/MonCap.h"
 TYPE(MonCap)
 
+#include "mon/MgrMap.h"
+TYPE_FEATUREFUL(MgrMap)
+
 #include "mon/mon_types.h"
 TYPE(LevelDBStoreStats)