]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/osd_types: add pg_hit_set_{info,history}_t
authorSage Weil <sage@inktank.com>
Thu, 3 Oct 2013 22:29:15 +0000 (15:29 -0700)
committerSage Weil <sage@inktank.com>
Fri, 6 Dec 2013 22:37:26 +0000 (14:37 -0800)
Signed-off-by: Sage Weil <sage@inktank.com>
src/osd/osd_types.cc
src/osd/osd_types.h
src/test/encoding/types.h

index 5c71b75d8e6d08228dae2f476e90548534cadebb..38fd623def33a5567b006e8f7a6c5316afc8ef86 100644 (file)
@@ -2678,6 +2678,102 @@ void pg_create_t::generate_test_instances(list<pg_create_t*>& o)
 }
 
 
+// -- pg_hit_set_info_t --
+
+void pg_hit_set_info_t::encode(bufferlist& bl) const
+{
+  ENCODE_START(1, 1, bl);
+  ::encode(size, bl);
+  ::encode(target_size, bl);
+  ::encode(begin, bl);
+  ::encode(end, bl);
+  ::encode(version, bl);
+  ENCODE_FINISH(bl);
+}
+
+void pg_hit_set_info_t::decode(bufferlist::iterator& p)
+{
+  DECODE_START(1, p);
+  ::decode(size, p);
+  ::decode(target_size, p);
+  ::decode(begin, p);
+  ::decode(end, p);
+  ::decode(version, p);
+  DECODE_FINISH(p);
+}
+
+void pg_hit_set_info_t::dump(Formatter *f) const
+{
+  f->dump_unsigned("size", size);
+  f->dump_unsigned("target_size", target_size);
+  f->dump_stream("begin") << begin;
+  f->dump_stream("end") << end;
+  f->dump_stream("version") << version;
+}
+
+void pg_hit_set_info_t::generate_test_instances(list<pg_hit_set_info_t*>& ls)
+{
+  ls.push_back(new pg_hit_set_info_t);
+  ls.push_back(new pg_hit_set_info_t);
+  ls.back()->size = 123;
+  ls.back()->target_size = 345;
+  ls.back()->begin = utime_t(1, 2);
+  ls.back()->end = utime_t(3, 4);
+}
+
+
+// -- pg_hit_set_history_t --
+
+void pg_hit_set_history_t::encode(bufferlist& bl) const
+{
+  ENCODE_START(1, 1, bl);
+  ::encode(current_last_update, bl);
+  ::encode(current_last_stamp, bl);
+  ::encode(current_info, bl);
+  ::encode(history, bl);
+  ENCODE_FINISH(bl);
+}
+
+void pg_hit_set_history_t::decode(bufferlist::iterator& p)
+{
+  DECODE_START(1, p);
+  ::decode(current_last_update, p);
+  ::decode(current_last_stamp, p);
+  ::decode(current_info, p);
+  ::decode(history, p);
+  DECODE_FINISH(p);
+}
+
+void pg_hit_set_history_t::dump(Formatter *f) const
+{
+  f->dump_stream("current_last_update") << current_last_update;
+  f->dump_stream("current_last_stamp") << current_last_stamp;
+  f->open_object_section("current_info");
+  current_info.dump(f);
+  f->close_section();
+  f->open_array_section("history");
+  for (list<pg_hit_set_info_t>::const_iterator p = history.begin();
+       p != history.end(); ++p) {
+    f->open_object_section("info");
+    p->dump(f);
+    f->close_section();
+  }
+  f->close_section();
+}
+
+void pg_hit_set_history_t::generate_test_instances(list<pg_hit_set_history_t*>& ls)
+{
+  ls.push_back(new pg_hit_set_history_t);
+  ls.push_back(new pg_hit_set_history_t);
+  ls.back()->current_last_update = eversion_t(1, 2);
+  ls.back()->current_last_stamp = utime_t(100, 123);
+  ls.back()->current_info.size = 3;
+  ls.back()->current_info.begin = utime_t(2, 4);
+  ls.back()->current_info.end = utime_t(62, 24);
+  ls.back()->history.push_back(ls.back()->current_info);
+  ls.back()->history.push_back(pg_hit_set_info_t());
+}
+
 // -- osd_peer_stat_t --
 
 void osd_peer_stat_t::encode(bufferlist& bl) const
index cb51d8133491141348bc9556fc2a61369873aa4a..5bd357ca724f8ea9f03b9a4e078c83f07cfcceef 100644 (file)
@@ -1217,6 +1217,57 @@ struct pool_stat_t {
 WRITE_CLASS_ENCODER_FEATURES(pool_stat_t)
 
 
+// -----------------------------------------
+
+/**
+ * pg_hit_set_info_t - information about a single recorded HitSet
+ *
+ * Track basic metadata about a HitSet, like the nubmer of insertions
+ * and the time range it covers.
+ */
+struct pg_hit_set_info_t {
+  uint32_t size;        ///< number of insertions
+  uint32_t target_size; ///< expected insertions
+  utime_t begin, end;   ///< time interval
+  eversion_t version;   ///< version this HitSet object was written
+
+  pg_hit_set_info_t() : size(0), target_size(0) {}
+  pg_hit_set_info_t(uint32_t target, utime_t st)
+    : size(0), target_size(target), begin(st) {}
+
+  bool is_full() const {
+    return size && size >= target_size;
+  }
+
+  void encode(bufferlist &bl) const;
+  void decode(bufferlist::iterator &bl);
+  void dump(Formatter *f) const;
+  static void generate_test_instances(list<pg_hit_set_info_t*>& o);
+};
+WRITE_CLASS_ENCODER(pg_hit_set_info_t)
+
+/**
+ * pg_hit_set_history_t - information about a history of hitsets
+ *
+ * Include information about the currently accumulating hit set as well
+ * as archived/historical ones.
+ */
+struct pg_hit_set_history_t {
+  eversion_t current_last_update;  ///< last version inserted into current set
+  utime_t current_last_stamp;      ///< timestamp of last insert
+  pg_hit_set_info_t current_info;  ///< metadata about the current set
+  list<pg_hit_set_info_t> history; ///< archived sets, sorted oldest -> newest
+
+  void encode(bufferlist &bl) const;
+  void decode(bufferlist::iterator &bl);
+  void dump(Formatter *f) const;
+  static void generate_test_instances(list<pg_hit_set_history_t*>& o);
+};
+WRITE_CLASS_ENCODER(pg_hit_set_history_t)
+
+
+// -----------------------------------------
+
 /**
  * pg_history_t - information about recent pg peering/mapping history
  *
index b250cbdbc27d064dfeec794886b9118b6bf37aab..105760068ed32d3254edda22497b713281a72aa3 100644 (file)
@@ -73,6 +73,8 @@ TYPE(ObjectRecoveryInfo)
 TYPE(ObjectRecoveryProgress)
 TYPE(ScrubMap::object)
 TYPE(ScrubMap)
+TYPE(pg_hit_set_info_t)
+TYPE(pg_hit_set_history_t)
 TYPE(osd_peer_stat_t)
 TYPE(clone_info)
 TYPE(obj_list_snap_response_t)