#define DOUT_SUBSYS mon
#include "common/debug.h"
+#include "common/Formatter.h"
+
+// --
+
+void PGMap::Incremental::encode(bufferlist &bl) const
+{
+ __u8 v = 3;
+ ::encode(v, bl);
+ ::encode(version, bl);
+ ::encode(pg_stat_updates, bl);
+ ::encode(osd_stat_updates, bl);
+ ::encode(osd_stat_rm, bl);
+ ::encode(osdmap_epoch, bl);
+ ::encode(pg_scan, bl);
+ ::encode(full_ratio, bl);
+ ::encode(nearfull_ratio, bl);
+ ::encode(pg_remove, bl);
+}
+
+void PGMap::Incremental::decode(bufferlist::iterator &bl)
+{
+ __u8 v;
+ ::decode(v, bl);
+ ::decode(version, bl);
+ if (v < 3) {
+ pg_stat_updates.clear();
+ __u32 n;
+ ::decode(n, bl);
+ while (n--) {
+ old_pg_t opgid;
+ ::decode(opgid, bl);
+ pg_t pgid = opgid;
+ ::decode(pg_stat_updates[pgid], bl);
+ }
+ } else {
+ ::decode(pg_stat_updates, bl);
+ }
+ ::decode(osd_stat_updates, bl);
+ ::decode(osd_stat_rm, bl);
+ ::decode(osdmap_epoch, bl);
+ ::decode(pg_scan, bl);
+ if (v >= 2) {
+ ::decode(full_ratio, bl);
+ ::decode(nearfull_ratio, bl);
+ }
+ if (v < 3) {
+ pg_remove.clear();
+ __u32 n;
+ ::decode(n, bl);
+ while (n--) {
+ old_pg_t opgid;
+ ::decode(opgid, bl);
+ pg_remove.insert(pg_t(opgid));
+ }
+ } else {
+ ::decode(pg_remove, bl);
+ }
+}
+
+void PGMap::Incremental::dump(Formatter *f) const
+{
+ f->dump_unsigned("version", version);
+ f->dump_unsigned("osdmap_epoch", osdmap_epoch);
+ f->dump_unsigned("pg_scan_epoch", pg_scan);
+ f->dump_float("full_ratio", full_ratio);
+ f->dump_float("nearfull_ratio", nearfull_ratio);
+
+ f->open_array_section("pg_stat_updates");
+ for (map<pg_t,pg_stat_t>::const_iterator p = pg_stat_updates.begin(); p != pg_stat_updates.end(); ++p) {
+ f->open_object_section("pg_stat");
+ f->dump_stream("pgid") << p->first;
+ p->second.dump(f);
+ f->close_section();
+ }
+ f->close_section();
+
+ f->open_array_section("osd_stat_updates");
+ for (map<int,osd_stat_t>::const_iterator p = osd_stat_updates.begin(); p != osd_stat_updates.end(); ++p) {
+ f->open_object_section("osd_stat");
+ f->dump_int("osd", p->first);
+ p->second.dump(f);
+ f->close_section();
+ }
+ f->close_section();
+
+ f->open_array_section("osd_stat_removals");
+ for (set<int>::const_iterator p = osd_stat_rm.begin(); p != osd_stat_rm.end(); ++p)
+ f->dump_int("osd", *p);
+ f->close_section();
+
+ f->open_array_section("pg_removals");
+ for (set<pg_t>::const_iterator p = pg_remove.begin(); p != pg_remove.end(); ++p)
+ f->dump_stream("pgid") << *p;
+ f->close_section();
+}
+
+void PGMap::Incremental::generate_test_instances(list<PGMap::Incremental*>& o)
+{
+ o.push_back(new Incremental);
+ o.push_back(new Incremental);
+ o.back()->version = 12;
+ o.back()->osdmap_epoch = 1;
+ o.back()->pg_scan = 2;
+ o.back()->full_ratio = .2;
+ o.back()->nearfull_ratio = .3;
+ o.back()->pg_stat_updates[pg_t(1,2,3)] = pg_stat_t();
+ o.back()->osd_stat_updates[5] = osd_stat_t();
+}
+
+
+// --
+
void PGMap::apply_incremental(const Incremental& inc)
{
assert(inc.version == version+1);
return min;
}
-void PGMap::encode(bufferlist &bl)
+void PGMap::encode(bufferlist &bl) const
{
__u8 v = 3;
::encode(v, bl);
out << "; " << ssr.str();
}
+void PGMap::generate_test_instances(list<PGMap*>& o)
+{
+ o.push_back(new PGMap);
+ o.push_back(new PGMap);
+ o.back()->version = 888;
+ o.back()->last_osdmap_epoch = 12;
+ o.back()->last_pg_scan = 34;
+ o.back()->full_osds.insert(3);
+ o.back()->nearfull_osds.insert(4);
+ o.back()->pg_stat[pg_t(1,2,3)] = pg_stat_t();
+ o.back()->osd_stat[5] = osd_stat_t();
+}
#include "common/config.h"
#include <sstream>
+namespace ceph { class Formatter; }
+
class PGMap {
public:
// the map
float full_ratio;
float nearfull_ratio;
- void encode(bufferlist &bl) const {
- __u8 v = 3;
- ::encode(v, bl);
- ::encode(version, bl);
- ::encode(pg_stat_updates, bl);
- ::encode(osd_stat_updates, bl);
- ::encode(osd_stat_rm, bl);
- ::encode(osdmap_epoch, bl);
- ::encode(pg_scan, bl);
- ::encode(full_ratio, bl);
- ::encode(nearfull_ratio, bl);
- ::encode(pg_remove, bl);
- }
- void decode(bufferlist::iterator &bl) {
- __u8 v;
- ::decode(v, bl);
- ::decode(version, bl);
- if (v < 3) {
- pg_stat_updates.clear();
- __u32 n;
- ::decode(n, bl);
- while (n--) {
- old_pg_t opgid;
- ::decode(opgid, bl);
- pg_t pgid = opgid;
- ::decode(pg_stat_updates[pgid], bl);
- }
- } else {
- ::decode(pg_stat_updates, bl);
- }
- ::decode(osd_stat_updates, bl);
- ::decode(osd_stat_rm, bl);
- ::decode(osdmap_epoch, bl);
- ::decode(pg_scan, bl);
- if (v >= 2) {
- ::decode(full_ratio, bl);
- ::decode(nearfull_ratio, bl);
- }
- if (v < 3) {
- pg_remove.clear();
- __u32 n;
- ::decode(n, bl);
- while (n--) {
- old_pg_t opgid;
- ::decode(opgid, bl);
- pg_remove.insert(pg_t(opgid));
- }
- } else {
- ::decode(pg_remove, bl);
- }
- }
+ void encode(bufferlist &bl) const;
+ void decode(bufferlist::iterator &bl);
+ void dump(Formatter *f) const;
+ static void generate_test_instances(list<Incremental*>& o);
Incremental() : version(0), osdmap_epoch(0), pg_scan(0),
full_ratio(0), nearfull_ratio(0) {}
void stat_osd_add(const osd_stat_t &s);
void stat_osd_sub(const osd_stat_t &s);
- void encode(bufferlist &bl);
+ void encode(bufferlist &bl) const;
void decode(bufferlist::iterator &bl);
void dump(Formatter *f) const;
void print_summary(ostream& out) const;
epoch_t calc_min_last_epoch_clean() const;
+
+ static void generate_test_instances(list<PGMap*>& o);
};
+WRITE_CLASS_ENCODER(PGMap::Incremental)
+WRITE_CLASS_ENCODER(PGMap)
inline ostream& operator<<(ostream& out, const PGMap& m) {
m.print_summary(out);