]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: add dump() to MDSCacheObject
authorJohn Spray <john.spray@redhat.com>
Tue, 17 Mar 2015 18:41:30 +0000 (18:41 +0000)
committerJohn Spray <john.spray@redhat.com>
Thu, 19 Mar 2015 21:27:34 +0000 (21:27 +0000)
Subclasses extend this with their own attributes.

Signed-off-by: John Spray <john.spray@redhat.com>
src/mds/mdstypes.cc
src/mds/mdstypes.h

index df2fa8bfea1aca983704c1f976bc0340772870e7..55257644da9e444e63396735487ec0bcd1bef846 100644 (file)
@@ -1018,3 +1018,63 @@ void cap_reconnect_t::generate_test_instances(list<cap_reconnect_t*>& ls)
   ls.back()->path = "/test/path";
   ls.back()->capinfo.cap_id = 1;
 }
+
+void MDSCacheObject::dump(Formatter *f) const
+{
+  f->dump_bool("is_auth", is_auth());
+
+  // Fields only meaningful for auth
+  f->open_object_section("auth_state");
+  {
+    f->open_object_section("replicas");
+    const compact_map<mds_rank_t,unsigned>& replicas = get_replicas();
+    for (compact_map<mds_rank_t,unsigned>::const_iterator i = replicas.begin();
+         i != replicas.end(); ++i) {
+      std::ostringstream rank_str;
+      rank_str << i->first;
+      f->dump_int(rank_str.str().c_str(), i->second);
+    }
+    f->close_section();
+  }
+  f->close_section(); // auth_state
+
+  // Fields only meaningful for replica
+  f->open_object_section("replica_state");
+  {
+    f->open_array_section("authority");
+    f->dump_int("first", authority().first);
+    f->dump_int("second", authority().second);
+    f->close_section();
+    f->dump_int("replica_nonce", get_replica_nonce());
+  }
+  f->close_section();  // replica_state
+
+  f->dump_int("auth_pins", auth_pins);
+  f->dump_int("nested_auth_pins", nested_auth_pins);
+  f->dump_bool("is_frozen", is_frozen());
+  f->dump_bool("is_freezing", is_freezing());
+
+#ifdef MDS_REF_SET
+    f->open_object_section("pins");
+    for(std::map<int, int>::const_iterator it = ref_map.begin();
+        it != ref_map.end(); ++it) {
+      f->dump_int(pin_name(it->first), it->second);
+    }
+    f->close_section();
+#endif
+    f->dump_int("nref", ref);
+}
+
+/*
+ * Use this in subclasses when printing their specialized
+ * states too.
+ */
+void MDSCacheObject::dump_states(Formatter *f) const
+{
+  if (state_test(STATE_AUTH)) f->dump_string("state", "auth");
+  if (state_test(STATE_DIRTY)) f->dump_string("state", "dirty");
+  if (state_test(STATE_NOTIFYREF)) f->dump_string("state", "notifyref");
+  if (state_test(STATE_REJOINING)) f->dump_string("state", "rejoining");
+  if (state_test(STATE_REJOINUNDEF))
+    f->dump_string("state", "rejoinundef");
+}
index c2ca6050ff340d34563900d9cd7ba7ed145c534d..0bffe4bec9b62dbadb3cdf526b12ed79b067e903 100644 (file)
@@ -1410,6 +1410,9 @@ protected:
   int get_num_auth_pins() const { return auth_pins; }
   int get_num_nested_auth_pins() const { return nested_auth_pins; }
 
+  void dump_states(Formatter *f) const;
+  void dump(Formatter *f) const;
+
   // --------------------------------------------
   // auth pins
   virtual bool can_auth_pin() const = 0;