From: Greg Farnum Date: Mon, 4 Feb 2013 00:07:44 +0000 (-0800) Subject: mds: ESessions more modernization for dencoder X-Git-Tag: v0.58~100^2~22 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3cea0ca7c267030f15bd3b43ac33644c1da668c6;p=ceph.git mds: ESessions more modernization for dencoder Signed-off-by: Greg Farnum --- diff --git a/src/mds/events/ESessions.h b/src/mds/events/ESessions.h index ebc5edaec92b..e239a0da8e97 100644 --- a/src/mds/events/ESessions.h +++ b/src/mds/events/ESessions.h @@ -37,33 +37,16 @@ public: } void mark_old_encoding() { old_style_encode = true; } - - void encode(bufferlist &bl) const { - ENCODE_START(1, 1, bl); - ::encode(client_map, bl); - ::encode(cmapv, bl); - ::encode(stamp, bl); - ENCODE_FINISH(bl); - } - void decode_old(bufferlist::iterator &bl) { - ::decode(client_map, bl); - ::decode(cmapv, bl); - if (!bl.end()) - ::decode(stamp, bl); - } - void decode_new(bufferlist::iterator &bl) { - DECODE_START(1, bl); - ::decode(client_map, bl); - ::decode(cmapv, bl); - if (!bl.end()) - ::decode(stamp, bl); - DECODE_FINISH(bl); - } + + void encode(bufferlist &bl) const; + void decode_old(bufferlist::iterator &bl); + void decode_new(bufferlist::iterator &bl); void decode(bufferlist::iterator &bl) { if (old_style_encode) decode_old(bl); else decode_new(bl); } - + void dump(Formatter *f) const; + static void generate_test_instances(list& ls); void print(ostream& out) { out << "ESessions " << client_map.size() << " opens cmapv " << cmapv; diff --git a/src/mds/journal.cc b/src/mds/journal.cc index 3968eee7dac5..1e1280585aef 100644 --- a/src/mds/journal.cc +++ b/src/mds/journal.cc @@ -1416,6 +1416,53 @@ void ESession::generate_test_instances(list& ls) // ----------------------- // ESessions +void ESessions::encode(bufferlist &bl) const +{ + ENCODE_START(1, 1, bl); + ::encode(client_map, bl); + ::encode(cmapv, bl); + ::encode(stamp, bl); + ENCODE_FINISH(bl); +} + +void ESessions::decode_old(bufferlist::iterator &bl) +{ + ::decode(client_map, bl); + ::decode(cmapv, bl); + if (!bl.end()) + ::decode(stamp, bl); +} + +void ESessions::decode_new(bufferlist::iterator &bl) +{ + DECODE_START(1, bl); + ::decode(client_map, bl); + ::decode(cmapv, bl); + if (!bl.end()) + ::decode(stamp, bl); + DECODE_FINISH(bl); +} + +void ESessions::dump(Formatter *f) const +{ + f->dump_int("client map version", cmapv); + + f->open_array_section("client map"); + for (map::const_iterator i = client_map.begin(); + i != client_map.end(); ++i) { + f->open_object_section("client"); + f->dump_int("client id", i->first.v); + f->dump_stream("client entity") << i->second; + f->close_section(); // client + } + f->close_section(); // client map +} + +void ESessions::generate_test_instances(list& ls) +{ + ls.push_back(new ESessions()); +} + void ESessions::update_segment() { _segment->sessionmapv = cmapv; diff --git a/src/test/encoding/types.h b/src/test/encoding/types.h index 75a73e11e5ea..2e4cd8210dbc 100644 --- a/src/test/encoding/types.h +++ b/src/test/encoding/types.h @@ -145,6 +145,8 @@ TYPE(EOpen) TYPE(EResetJournal) #include "mds/events/ESession.h" TYPE(ESession) +#include "mds/events/ESessions.h" +TYPE(ESessions) #ifdef WITH_RADOSGW