From: Joao Eduardo Luis Date: Fri, 5 Jun 2015 15:22:46 +0000 (+0100) Subject: mon/mon_types.h: add C_MonOp abstract class X-Git-Tag: v9.1.0~535^2~32 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7e1c8c9f72be1629a4e28fb5de122f95daed6f2d;p=ceph.git mon/mon_types.h: add C_MonOp abstract class 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 --- diff --git a/src/mon/mon_types.h b/src/mon/mon_types.h index 4fa97d3a80bc..a720075dae78 100644 --- a/src/mon/mon_types.h +++ b/src/mon/mon_types.h @@ -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 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