// -------------------
-void SessionMap::encode(bufferlist& bl)
+void SessionMap::encode(bufferlist& bl) const
{
uint64_t pre = -1; // for 0.19 compatibility; we forgot an encoding prefix.
::encode(pre, bl);
- __u8 struct_v = 2;
- ::encode(struct_v, bl);
-
+ ENCODE_START(3, 3, bl);
::encode(version, bl);
- for (hash_map<entity_name_t,Session*>::iterator p = session_map.begin();
+ for (hash_map<entity_name_t,Session*>::const_iterator p = session_map.begin();
p != session_map.end();
- ++p)
+ ++p) {
if (p->second->is_open() ||
p->second->is_closing() ||
p->second->is_stale() ||
::encode(p->first, bl);
p->second->info.encode(bl);
}
+ }
+ ENCODE_FINISH(bl);
}
void SessionMap::decode(bufferlist::iterator& p)
uint64_t pre;
::decode(pre, p);
if (pre == (uint64_t)-1) {
- __u8 struct_v;
- ::decode(struct_v, p);
- assert(struct_v == 2);
-
+ DECODE_START_LEGACY_COMPAT_LEN(3, 3, 3, p);
+ assert(struct_v >= 2);
+
::decode(version, p);
-
+
while (!p.end()) {
entity_inst_t inst;
::decode(inst.name, p);
s->info.decode(p);
}
+ DECODE_FINISH(p);
} else {
// --- old format ----
version = pre;
}
}
+void SessionMap::dump(Formatter *f) const
+{
+ f->open_array_section("Sessions");
+ for (hash_map<entity_name_t,Session*>::const_iterator p = session_map.begin();
+ p != session_map.end();
+ ++p) {
+ f->open_object_section("Session");
+ f->open_object_section("entity name");
+ p->first.dump(f);
+ f->close_section(); // entity name
+ f->open_object_section("Session info");
+ p->second->info.dump(f);
+ f->close_section(); // Session info
+ f->close_section(); // Session
+ }
+ f->close_section(); // Sessions
+}
+void SessionMap::generate_test_instances(list<SessionMap*>& ls)
+{
+ // pretty boring for now
+ ls.push_back(new SessionMap(NULL));
+}
void SessionMap::wipe()
{
SessionMap(MDS *m) : mds(m),
version(0), projected(0), committing(0), committed(0)
{ }
+
+ //for the dencoder
+ SessionMap() : mds(NULL), version(0), projected(0),
+ committing(0), committed(0) {}
// sessions
bool empty() { return session_map.empty(); }
inodeno_t ino;
list<Context*> waiting_for_load;
- void encode(bufferlist& bl);
+ void encode(bufferlist& bl) const;
void decode(bufferlist::iterator& blp);
+ void dump(Formatter *f) const;
+ static void generate_test_instances(list<SessionMap*>& ls);
object_t get_object_name();