From 3cea0ca7c267030f15bd3b43ac33644c1da668c6 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Sun, 3 Feb 2013 16:07:44 -0800 Subject: [PATCH] mds: ESessions more modernization for dencoder Signed-off-by: Greg Farnum --- src/mds/events/ESessions.h | 29 +++++------------------ src/mds/journal.cc | 47 ++++++++++++++++++++++++++++++++++++++ src/test/encoding/types.h | 2 ++ 3 files changed, 55 insertions(+), 23 deletions(-) diff --git a/src/mds/events/ESessions.h b/src/mds/events/ESessions.h index ebc5edaec92b0..e239a0da8e974 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 3968eee7dac58..1e1280585aef6 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 75a73e11e5ead..2e4cd8210dbc4 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 -- 2.39.5