locator: topology: Add printer

This commit is contained in:
Tomasz Grabiec
2023-04-13 11:17:32 +02:00
parent 3dfd49fe62
commit 6ed841b8d7
2 changed files with 21 additions and 1 deletions

View File

@@ -509,6 +509,18 @@ void topology::for_each_node(std::function<void(const node*)> func) const {
namespace std {
std::ostream& operator<<(std::ostream& out, const locator::topology& t) {
out << "{this_host_id: " << t._cfg.this_host_id
<< ", this_endpoint: " << t._cfg.this_endpoint
<< ", dc: " << t._cfg.local_dc_rack.dc
<< ", rack: " << t._cfg.local_dc_rack.rack
<< ", nodes:\n";
for (auto&& node : t._nodes) {
out << " " << locator::topology::debug_format(&*node) << "\n";
}
return out << "}";
}
std::ostream& operator<<(std::ostream& out, const locator::node& node) {
fmt::print(out, "{}", node);
return out;

View File

@@ -25,8 +25,14 @@
using namespace seastar;
namespace locator {
class topology;
}
namespace std {
std::ostream& operator<<(std::ostream& out, const locator::topology&);
}
namespace locator {
class node;
using node_holder = std::unique_ptr<node>;
@@ -315,6 +321,8 @@ private:
friend class token_metadata_impl;
public:
void test_compare_endpoints(const inet_address& address, const inet_address& a1, const inet_address& a2) const;
friend std::ostream& std::operator<<(std::ostream& out, const topology&);
};
} // namespace locator