public:
const char *get_type_name() const override { return "pg_info"; }
void print(ostream& out) const override {
- out << "pg_info(" << pg_list.size() << " pgs e" << epoch << ":";
-
- for (vector<pair<pg_notify_t,PastIntervals> >::const_iterator i = pg_list.begin();
+ out << "pg_info(";
+ for (auto i = pg_list.begin();
i != pg_list.end();
++i) {
if (i != pg_list.begin())
- out << ",";
- out << i->first.info.pgid;
- if (i->second.size())
- out << "(" << i->second.size() << ")";
+ out << " ";
+ out << i->first << "=" << i->second;
}
-
- out << ")";
+ out << " epoch " << epoch
+ << ")";
}
void encode_payload(uint64_t features) override {
- ::encode(epoch, payload);
-
- // v1 was vector<pg_info_t>
- __u32 n = pg_list.size();
- ::encode(n, payload);
- for (vector<pair<pg_notify_t,PastIntervals> >::iterator p = pg_list.begin();
- p != pg_list.end();
- p++)
- ::encode(p->first.info, payload);
-
- // v2 needs the PastIntervals for each record
- for (vector<pair<pg_notify_t,PastIntervals> >::iterator p = pg_list.begin();
- p != pg_list.end();
- p++) {
- if (HAVE_FEATURE(features, SERVER_LUMINOUS)) {
- ::encode(p->second, payload);
- } else {
- header.version = 4;
+ if (!HAVE_FEATURE(features, SERVER_LUMINOUS)) {
+ header.version = 4;
+
+ // for kraken+jewel only
+ ::encode(epoch, payload);
+
+ // v1 was vector<pg_info_t>
+ __u32 n = pg_list.size();
+ ::encode(n, payload);
+ for (auto p = pg_list.begin();
+ p != pg_list.end();
+ p++)
+ ::encode(p->first.info, payload);
+
+ // v2 needs the PastIntervals for each record
+ for (auto p = pg_list.begin();
+ p != pg_list.end();
+ p++) {
p->second.encode_classic(payload);
}
- }
- // v3 needs epoch_sent, query_epoch
- for (vector<pair<pg_notify_t,PastIntervals> >::iterator p = pg_list.begin();
- p != pg_list.end();
- p++)
- ::encode(pair<epoch_t, epoch_t>(
- p->first.epoch_sent, p->first.query_epoch), payload);
-
- // v4 needs from, to
- for (vector<pair<pg_notify_t, PastIntervals> >::iterator p = pg_list.begin();
- p != pg_list.end();
- ++p) {
- ::encode(p->first.from, payload);
- ::encode(p->first.to, payload);
+ // v3 needs epoch_sent, query_epoch
+ for (auto p = pg_list.begin();
+ p != pg_list.end();
+ p++)
+ ::encode(pair<epoch_t, epoch_t>(
+ p->first.epoch_sent, p->first.query_epoch), payload);
+
+ // v4 needs from, to
+ for (auto p = pg_list.begin();
+ p != pg_list.end();
+ ++p) {
+ ::encode(p->first.from, payload);
+ ::encode(p->first.to, payload);
+ }
+ return;
}
+ ::encode(epoch, payload);
+ ::encode(pg_list, payload);
}
void decode_payload() override {
bufferlist::iterator p = payload.begin();
- ::decode(epoch, p);
+ if (header.version < 5) {
+ ::decode(epoch, p);
- // decode pg_info_t portion of the vector
- __u32 n;
- ::decode(n, p);
- pg_list.resize(n);
- for (unsigned i=0; i<n; i++) {
- ::decode(pg_list[i].first.info, p);
- }
-
- if (header.version >= 2) {
- // get the PastIntervals portion
+ // decode pg_info_t portion of the vector
+ __u32 n;
+ ::decode(n, p);
+ pg_list.resize(n);
for (unsigned i=0; i<n; i++) {
- if (header.version >= 5) {
- ::decode(pg_list[i].second, p);
- } else {
- pg_list[i].second.decode_classic(p);
+ ::decode(pg_list[i].first.info, p);
+ }
+
+ if (header.version >= 2) {
+ // get the PastIntervals portion
+ for (unsigned i=0; i<n; i++) {
+ if (header.version >= 5) {
+ ::decode(pg_list[i].second, p);
+ } else {
+ pg_list[i].second.decode_classic(p);
+ }
}
}
- }
- // v3 needs epoch_sent, query_epoch
- for (vector<pair<pg_notify_t,PastIntervals> >::iterator i = pg_list.begin();
- i != pg_list.end();
+ // v3 needs epoch_sent, query_epoch
+ for (auto i = pg_list.begin();
+ i != pg_list.end();
i++) {
- if (header.version >= 3) {
- pair<epoch_t, epoch_t> dec;
- ::decode(dec, p);
- i->first.epoch_sent = dec.first;
- i->first.query_epoch = dec.second;
- } else {
- i->first.epoch_sent = epoch;
- i->first.query_epoch = epoch;
+ if (header.version >= 3) {
+ pair<epoch_t, epoch_t> dec;
+ ::decode(dec, p);
+ i->first.epoch_sent = dec.first;
+ i->first.query_epoch = dec.second;
+ } else {
+ i->first.epoch_sent = epoch;
+ i->first.query_epoch = epoch;
+ }
}
- }
- // v4 needs from and to
- if (header.version >= 4) {
- for (vector<pair<pg_notify_t, PastIntervals> >::iterator i = pg_list.begin();
- i != pg_list.end();
- i++) {
- ::decode(i->first.from, p);
- ::decode(i->first.to, p);
+ // v4 needs from and to
+ if (header.version >= 4) {
+ for (auto i = pg_list.begin();
+ i != pg_list.end();
+ i++) {
+ ::decode(i->first.from, p);
+ ::decode(i->first.to, p);
+ }
}
+ return;
}
+ ::decode(epoch, p);
+ ::decode(pg_list, p);
}
};