summaryrefslogtreecommitdiffstats
path: root/src/mon/MgrMap.h
diff options
context:
space:
mode:
authorSage Weil <sage@redhat.com>2017-03-30 18:19:41 +0200
committerSage Weil <sage@redhat.com>2017-03-30 23:57:35 +0200
commitdc49857a6529fe80b3b1f49f6e27e393c04d939e (patch)
tree912230218b4c2224de3bd2857f00c28dc2788551 /src/mon/MgrMap.h
parentmon/MgrMonitor: print MgrMap to log on each change (diff)
downloadceph-dc49857a6529fe80b3b1f49f6e27e393c04d939e.tar.xz
ceph-dc49857a6529fe80b3b1f49f6e27e393c04d939e.zip
mon/MgrMap: implement dump, add to ceph-dencoder
Signed-off-by: Sage Weil <sage@redhat.com>
Diffstat (limited to 'src/mon/MgrMap.h')
-rw-r--r--src/mon/MgrMap.h59
1 files changed, 32 insertions, 27 deletions
diff --git a/src/mon/MgrMap.h b/src/mon/MgrMap.h
index 167573da474..1fd0500131c 100644
--- a/src/mon/MgrMap.h
+++ b/src/mon/MgrMap.h
@@ -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;
+ }
}
}
}