From 7cbae7020b65beed9dd8657575f409666ba9473a Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Sun, 27 Jan 2013 19:43:33 -0800 Subject: [PATCH] mds: mds_load_t now uses modern encoding Signed-off-by: Greg Farnum --- src/mds/mdstypes.cc | 45 +++++++++++++++++++++++++++++++++++++++ src/mds/mdstypes.h | 35 +++++++++++------------------- src/test/encoding/types.h | 1 + 3 files changed, 58 insertions(+), 23 deletions(-) diff --git a/src/mds/mdstypes.cc b/src/mds/mdstypes.cc index 8873a03f3c1c1..e9da4839982f5 100644 --- a/src/mds/mdstypes.cc +++ b/src/mds/mdstypes.cc @@ -799,3 +799,48 @@ void dirfrag_load_vec_t::generate_test_instances(list& ls) utime_t sample; ls.push_back(new dirfrag_load_vec_t(sample)); } + +/* + * mds_load_t + */ +void mds_load_t::encode(bufferlist &bl) const { + ENCODE_START(2, 2, bl); + ::encode(auth, bl); + ::encode(all, bl); + ::encode(req_rate, bl); + ::encode(cache_hit_rate, bl); + ::encode(queue_len, bl); + ::encode(cpu_load_avg, bl); + ENCODE_FINISH(bl); +} + +void mds_load_t::decode(const utime_t &t, bufferlist::iterator &bl) { + DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl); + ::decode(auth, t, bl); + ::decode(all, t, bl); + ::decode(req_rate, bl); + ::decode(cache_hit_rate, bl); + ::decode(queue_len, bl); + ::decode(cpu_load_avg, bl); + DECODE_FINISH(bl); +} + +void mds_load_t::dump(Formatter *f) const +{ + f->dump_float("request rate", req_rate); + f->dump_float("cache hit rate", cache_hit_rate); + f->dump_float("queue length", queue_len); + f->dump_float("cpu load", cpu_load_avg); + f->open_object_section("auth dirfrag"); + auth.dump(f); + f->close_section(); + f->open_object_section("all dirfrags"); + all.dump(f); + f->close_section(); +} + +void mds_load_t::generate_test_instances(list& ls) +{ + utime_t sample; + ls.push_back(new mds_load_t(sample)); +} diff --git a/src/mds/mdstypes.h b/src/mds/mdstypes.h index a2417c65fb3e5..ecb1ee95cbbe1 100644 --- a/src/mds/mdstypes.h +++ b/src/mds/mdstypes.h @@ -955,31 +955,20 @@ struct mds_load_t { mds_load_t(const utime_t &t) : auth(t), all(t), req_rate(0), cache_hit_rate(0), queue_len(0), cpu_load_avg(0) - { - } + {} + // mostly for the dencoder infrastructure + mds_load_t() : + auth(), all(), + req_rate(0), cache_hit_rate(0), queue_len(0), cpu_load_avg(0) + {} double mds_load(); // defiend in MDBalancer.cc - - void encode(bufferlist &bl) const { - __u8 struct_v = 1; - ::encode(struct_v, bl); - ::encode(auth, bl); - ::encode(all, bl); - ::encode(req_rate, bl); - ::encode(cache_hit_rate, bl); - ::encode(queue_len, bl); - ::encode(cpu_load_avg, bl); - } - void decode(const utime_t &t, bufferlist::iterator &bl) { - __u8 struct_v; - ::decode(struct_v, bl); - ::decode(auth, t, bl); - ::decode(all, t, bl); - ::decode(req_rate, bl); - ::decode(cache_hit_rate, bl); - ::decode(queue_len, bl); - ::decode(cpu_load_avg, bl); - } + void encode(bufferlist& bl) const; + void decode(const utime_t& now, bufferlist::iterator& bl); + //this one is for dencoder infrastructure + void decode(bufferlist::iterator& bl) { utime_t sample; decode(sample, bl); } + void dump(Formatter *f) const; + static void generate_test_instances(list& ls); }; inline void encode(const mds_load_t &c, bufferlist &bl) { c.encode(bl); } inline void decode(mds_load_t &c, const utime_t &t, bufferlist::iterator &p) { diff --git a/src/test/encoding/types.h b/src/test/encoding/types.h index 2c706a98e77b0..d3451fec42880 100644 --- a/src/test/encoding/types.h +++ b/src/test/encoding/types.h @@ -114,6 +114,7 @@ TYPE(MDSCacheObjectInfo) TYPE(mds_table_pending_t) TYPE(inode_load_vec_t) TYPE(dirfrag_load_vec_t) +TYPE(mds_load_t) #include "mds/MDSMap.h" TYPE_FEATUREFUL(MDSMap) -- 2.39.5