mirror of
https://github.com/scylladb/scylladb.git
synced 2026-06-03 21:47:10 +00:00
db: tablets: Add printers
Example:
TRACE 2023-03-30 12:06:33,918 [shard 0] tablets - Read tablet metadata: {
8cd5b560-cee2-11ed-9cd5-7f37187f2167: {
[0]: last_token=-6917529027641081857, replicas={4fe5c4d5-7030-4ddd-8117-ba22c29f4f57:0},
[1]: last_token=-4611686018427387905, replicas={3160b965-1925-4677-884b-c761e2bf4272:0},
[2]: last_token=-2305843009213693953, replicas={3160b965-1925-4677-884b-c761e2bf4272:0},
[3]: last_token=-1, replicas={4fe5c4d5-7030-4ddd-8117-ba22c29f4f57:0},
[4]: last_token=2305843009213693951, replicas={3160b965-1925-4677-884b-c761e2bf4272:0},
[5]: last_token=4611686018427387903, replicas={4fe5c4d5-7030-4ddd-8117-ba22c29f4f57:0},
[6]: last_token=6917529027641081855, replicas={4fe5c4d5-7030-4ddd-8117-ba22c29f4f57:0},
[7]: last_token=9223372036854775807, replicas={3160b965-1925-4677-884b-c761e2bf4272:0}
}
}
This commit is contained in:
@@ -115,4 +115,46 @@ const tablet_transition_info* tablet_map::get_tablet_transition_info(tablet_id i
|
||||
return &i->second;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, tablet_id id) {
|
||||
return out << size_t(id);
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const tablet_replica& r) {
|
||||
return out << r.host << ":" << r.shard;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const tablet_map& r) {
|
||||
if (r.tablet_count() == 0) {
|
||||
return out << "{}";
|
||||
}
|
||||
out << "{";
|
||||
bool first = true;
|
||||
tablet_id tid = r.first_tablet();
|
||||
for (auto&& tablet : r._tablets) {
|
||||
if (!first) {
|
||||
out << ",";
|
||||
}
|
||||
out << format("\n [{}]: last_token={}, replicas={}", tid, r.get_last_token(tid), tablet.replicas);
|
||||
if (auto tr = r.get_tablet_transition_info(tid)) {
|
||||
out << format(", new_replicas={}, pending={}", tr->next, tr->pending_replica);
|
||||
}
|
||||
first = false;
|
||||
tid = *r.next_tablet(tid);
|
||||
}
|
||||
return out << "\n }";
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const tablet_metadata& tm) {
|
||||
out << "{";
|
||||
bool first = true;
|
||||
for (auto&& [id, map] : tm._tablets) {
|
||||
if (!first) {
|
||||
out << ",";
|
||||
}
|
||||
out << "\n " << id << ": " << map;
|
||||
first = false;
|
||||
}
|
||||
return out << "\n}";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ struct tablet_replica {
|
||||
bool operator==(const tablet_replica&) const = default;
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream&, tablet_id);
|
||||
std::ostream& operator<<(std::ostream&, const tablet_replica&);
|
||||
|
||||
using tablet_replica_set = utils::small_vector<tablet_replica, 3>;
|
||||
@@ -175,6 +176,7 @@ public:
|
||||
// Destroys gently.
|
||||
// The tablet map is not usable after this call and should be destroyed.
|
||||
future<> clear_gently();
|
||||
friend std::ostream& operator<<(std::ostream&, const tablet_map&);
|
||||
private:
|
||||
void check_tablet_id(tablet_id) const;
|
||||
};
|
||||
@@ -209,6 +211,7 @@ public:
|
||||
future<> clear_gently();
|
||||
public:
|
||||
bool operator==(const tablet_metadata&) const = default;
|
||||
friend std::ostream& operator<<(std::ostream&, const tablet_metadata&);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user