]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/AsyncReserver: add dump()
authorSage Weil <sage@inktank.com>
Wed, 2 Jul 2014 04:49:53 +0000 (21:49 -0700)
committerSage Weil <sage@inktank.com>
Wed, 2 Jul 2014 04:49:53 +0000 (21:49 -0700)
Signed-off-by: Sage Weil <sage@inktank.com>
src/common/AsyncReserver.h

index fa49cfab8b42daf8bca69bd1fa3847887398ba31..467e2570460be837c9f1c300518ba7a47e140ac8 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "common/Mutex.h"
 #include "common/Finisher.h"
+#include "common/Formatter.h"
 
 /**
  * Manages a configurable number of asyncronous reservations.
@@ -79,6 +80,33 @@ public:
     do_queues();
   }
 
+  void dump(Formatter *f) {
+    Mutex::Locker l(lock);
+    f->dump_unsigned("max_allowed", max_allowed);
+    f->dump_unsigned("min_priority", min_priority);
+    f->open_array_section("queues");
+    for (typename map<unsigned, list<pair<T, Context*> > > ::const_iterator p =
+          queues.begin(); p != queues.end(); ++p) {
+      f->open_object_section("queue");
+      f->dump_unsigned("priority", p->first);
+      f->open_array_section("items");
+      for (typename list<pair<T, Context*> >::const_iterator q =
+            p->second.begin(); q != p->second.end(); ++q) {
+       f->dump_stream("item") << q->first;
+      }
+      f->close_section();
+      f->close_section();
+    }
+    f->close_section();
+    f->open_array_section("in_progress");
+    for (typename set<T>::const_iterator p = in_progress.begin();
+        p != in_progress.end();
+        ++p) {
+      f->dump_stream("item") << *p;
+    }
+    f->close_section();
+  }
+
   /**
    * Requests a reservation
    *