treewide: use fmtlib to format gms::inet_address
the goal of this change is to reduce the dependency on `operator<<(ostream&, const gms::inet_address&)`. this is not an exhaustive search-and-replace change, as in some caller sites we have other dependencies to yet-converted ostream printer, we cannot fix them all, this change only updates some caller of `operator<<(ostream&, const gms::inet_address&)`. Refs #13245 Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
This commit is contained in:
@@ -27,7 +27,7 @@ template<class T>
|
||||
std::vector<sstring> container_to_vec(const T& container) {
|
||||
std::vector<sstring> res;
|
||||
for (auto i : container) {
|
||||
res.push_back(boost::lexical_cast<std::string>(i));
|
||||
res.push_back(fmt::to_string(i));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ void set_failure_detector(http_context& ctx, routes& r, gms::gossiper& g) {
|
||||
std::vector<fd::endpoint_state> res;
|
||||
for (auto i : g.get_endpoint_states()) {
|
||||
fd::endpoint_state val;
|
||||
val.addrs = boost::lexical_cast<std::string>(i.first);
|
||||
val.addrs = fmt::to_string(i.first);
|
||||
val.is_alive = i.second.is_alive();
|
||||
val.generation = i.second.get_heart_beat_state().get_generation();
|
||||
val.version = i.second.get_heart_beat_state().get_heart_beat_version();
|
||||
|
||||
@@ -29,7 +29,7 @@ std::vector<message_counter> map_to_message_counters(
|
||||
std::vector<message_counter> res;
|
||||
for (auto i : map) {
|
||||
res.push_back(message_counter());
|
||||
res.back().key = boost::lexical_cast<sstring>(i.first);
|
||||
res.back().key = fmt::to_string(i.first);
|
||||
res.back().value = i.second;
|
||||
}
|
||||
return res;
|
||||
|
||||
@@ -169,7 +169,7 @@ static ss::token_range token_range_endpoints_to_json(const dht::token_range_endp
|
||||
r.rpc_endpoints = d._rpc_endpoints;
|
||||
for (auto det : d._endpoint_details) {
|
||||
ss::endpoint_detail ed;
|
||||
ed.host = boost::lexical_cast<std::string>(det._host);
|
||||
ed.host = fmt::to_string(det._host);
|
||||
ed.datacenter = det._datacenter;
|
||||
if (det._rack != "") {
|
||||
ed.rack = det._rack;
|
||||
@@ -485,8 +485,8 @@ void set_storage_service(http_context& ctx, routes& r, sharded<service::storage_
|
||||
ss::get_token_endpoint.set(r, [&ss] (std::unique_ptr<http::request> req) {
|
||||
return make_ready_future<json::json_return_type>(stream_range_as_array(ss.local().get_token_to_endpoint_map(), [](const auto& i) {
|
||||
storage_service_json::mapper val;
|
||||
val.key = boost::lexical_cast<std::string>(i.first);
|
||||
val.value = boost::lexical_cast<std::string>(i.second);
|
||||
val.key = fmt::to_string(i.first);
|
||||
val.value = fmt::to_string(i.second);
|
||||
return val;
|
||||
}));
|
||||
});
|
||||
@@ -554,7 +554,7 @@ void set_storage_service(http_context& ctx, routes& r, sharded<service::storage_
|
||||
auto points = ctx.get_token_metadata().get_bootstrap_tokens();
|
||||
std::unordered_set<sstring> addr;
|
||||
for (auto i: points) {
|
||||
addr.insert(boost::lexical_cast<std::string>(i.second));
|
||||
addr.insert(fmt::to_string(i.second));
|
||||
}
|
||||
return container_to_vec(addr);
|
||||
});
|
||||
|
||||
@@ -39,7 +39,7 @@ static hs::progress_info get_progress_info(const streaming::progress_info& info)
|
||||
res.current_bytes = info.current_bytes;
|
||||
res.direction = info.dir;
|
||||
res.file_name = info.file_name;
|
||||
res.peer = boost::lexical_cast<std::string>(info.peer);
|
||||
res.peer = fmt::to_string(info.peer);
|
||||
res.session_index = 0;
|
||||
res.total_bytes = info.total_bytes;
|
||||
return res;
|
||||
@@ -62,7 +62,7 @@ static hs::stream_state get_state(
|
||||
state.plan_id = result_future.plan_id.to_sstring();
|
||||
for (auto info : result_future.get_coordinator().get()->get_all_session_info()) {
|
||||
hs::stream_info si;
|
||||
si.peer = boost::lexical_cast<std::string>(info.peer);
|
||||
si.peer = fmt::to_string(info.peer);
|
||||
si.session_index = 0;
|
||||
si.state = info.state;
|
||||
si.connecting = si.peer;
|
||||
|
||||
@@ -66,7 +66,8 @@ public:
|
||||
}
|
||||
|
||||
friend inline std::ostream& operator<<(std::ostream& os, const gossip_digest& d) {
|
||||
return os << d._endpoint << ":" << d._generation << ":" << d._max_version;
|
||||
fmt::print(os, "{}:{}:{}", d._endpoint, d._generation, d._max_version);
|
||||
return os;
|
||||
}
|
||||
}; // class gossip_digest
|
||||
|
||||
|
||||
4
init.cc
4
init.cc
@@ -45,8 +45,8 @@ std::set<gms::inet_address> get_seeds_from_db_config(const db::config& cfg) {
|
||||
seeds.emplace(gms::inet_address("127.0.0.1"));
|
||||
}
|
||||
auto broadcast_address = utils::fb_utilities::get_broadcast_address();
|
||||
startlog.info("seeds={}, listen_address={}, broadcast_address={}",
|
||||
to_string(seeds), listen, broadcast_address);
|
||||
startlog.info("seeds={{{}}}, listen_address={}, broadcast_address={}",
|
||||
fmt::join(seeds, ", "), listen, broadcast_address);
|
||||
if (broadcast_address != listen && seeds.contains(listen)) {
|
||||
startlog.error("Use broadcast_address instead of listen_address for seeds list");
|
||||
throw std::runtime_error("Use broadcast_address for seeds list");
|
||||
|
||||
@@ -163,7 +163,8 @@ bool operator<(const msg_addr& x, const msg_addr& y) noexcept {
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const msg_addr& x) {
|
||||
return os << x.addr << ":" << x.cpu_id;
|
||||
fmt::print(os, "{}:{}", x.addr, x.cpu_id);
|
||||
return os;
|
||||
}
|
||||
|
||||
size_t msg_addr::hash::operator()(const msg_addr& id) const noexcept {
|
||||
|
||||
Reference in New Issue
Block a user