]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/mon_types.h: add C_MonOp abstract class
authorJoao Eduardo Luis <joao@suse.de>
Fri, 5 Jun 2015 15:22:46 +0000 (16:22 +0100)
committerJoao Eduardo Luis <joao@suse.de>
Thu, 16 Jul 2015 17:06:07 +0000 (18:06 +0100)
To be used by monitor contexts relying on MonOpRequest, so that we can
easily track the lifespan of an event.

Signed-off-by: Joao Eduardo Luis <joao@suse.de>
src/mon/mon_types.h

index 4fa97d3a80bc77e310d816069af1b1aa07527945..a720075dae789b74394dd2f83b3f542c667e58d1 100644 (file)
@@ -18,6 +18,8 @@
 #include "include/utime.h"
 #include "include/util.h"
 #include "common/Formatter.h"
+#include "include/Context.h"
+#include "mon/MonOpRequest.h"
 
 #define PAXOS_PGMAP      0  // before osd, for pg kick to behave
 #define PAXOS_MDSMAP     1
@@ -206,4 +208,30 @@ static inline ostream& operator<<(ostream& out, const ScrubResult& r) {
 /// for information like os, kernel, hostname, memory info, cpu model.
 typedef map<string, string> Metadata;
 
+struct C_MonOp : public Context
+{
+  MonOpRequestRef op;
+
+  C_MonOp(MonOpRequestRef o) :
+    op(o) { }
+
+  void finish(int r) {
+    if (op && r == -ECANCELED) {
+      op->mark_event("callback canceled");
+    } else if (op && r == -EAGAIN) {
+      op->mark_event("callback retry");
+    } else if (op && r == 0) {
+      op->mark_event("callback finished");
+    }
+    _finish(r);
+  }
+
+  void mark_op_event(const string &event) {
+    if (op)
+      op->mark_event(event);
+  }
+
+  virtual void _finish(int r) = 0;
+};
+
 #endif