diff options
author | Sage Weil <sage@newdream.net> | 2009-09-01 00:27:13 +0200 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2009-09-01 00:27:13 +0200 |
commit | 0009d675c66c29c0a708f56cf09e57b6c5d2bc8e (patch) | |
tree | 26126888b8eece444f972870d070e19a0ee9881a /src/messages/MMonSubscribe.h | |
parent | monc: resubscribe on monitor connection reset (diff) | |
download | ceph-0009d675c66c29c0a708f56cf09e57b6c5d2bc8e.tar.xz ceph-0009d675c66c29c0a708f56cf09e57b6c5d2bc8e.zip |
mon: do one-time subscriptions, too
Diffstat (limited to 'src/messages/MMonSubscribe.h')
-rw-r--r-- | src/messages/MMonSubscribe.h | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/messages/MMonSubscribe.h b/src/messages/MMonSubscribe.h index be9426b7251..05fca342ee7 100644 --- a/src/messages/MMonSubscribe.h +++ b/src/messages/MMonSubscribe.h @@ -18,10 +18,34 @@ #include "msg/Message.h" struct MMonSubscribe : public Message { - map<nstring, version_t> what; + struct sub_rec { + version_t have; + bool onetime; // just one version, or keep sending them? + + void encode(bufferlist& bl) const { + ::encode(have, bl); + ::encode(onetime, bl); + } + void decode(bufferlist::iterator& bl) { + ::decode(have, bl); + ::decode(onetime, bl); + } + }; + WRITE_CLASS_ENCODER(sub_rec) + + map<nstring, sub_rec> what; MMonSubscribe() : Message(CEPH_MSG_MON_SUBSCRIBE) {} + void sub_onetime(const char *w, version_t have) { + what[w].onetime = true; + what[w].have = have; + } + void sub_persistent(const char *w, version_t have) { + what[w].onetime = false; + what[w].have = have; + } + const char *get_type_name() { return "mon_subscribe"; } void print(ostream& o) { o << "mon_subscribe(" << what << ")"; @@ -35,5 +59,11 @@ struct MMonSubscribe : public Message { ::encode(what, payload); } }; +WRITE_CLASS_ENCODER(MMonSubscribe::sub_rec) + +static inline ostream& operator<<(ostream& out, const MMonSubscribe::sub_rec& r) +{ + return out << r.have << (r.onetime ? "(onetime)":"(persistent)"); +} #endif |