From 4d461fc78878991cd9a37cf148563ab28ec90330 Mon Sep 17 00:00:00 2001 From: Benny Halevy Date: Thu, 30 Nov 2023 09:47:13 +0200 Subject: [PATCH] locator: replication strategies: use locator::topology rather than fb_utilities Signed-off-by: Benny Halevy --- locator/everywhere_replication_strategy.cc | 3 +-- locator/local_strategy.cc | 3 +-- locator/network_topology_strategy.cc | 1 - test/boost/network_topology_strategy_test.cc | 17 ++++++++++------- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/locator/everywhere_replication_strategy.cc b/locator/everywhere_replication_strategy.cc index f7940243db..3bf75f2021 100644 --- a/locator/everywhere_replication_strategy.cc +++ b/locator/everywhere_replication_strategy.cc @@ -11,7 +11,6 @@ #include "locator/everywhere_replication_strategy.hh" #include "utils/class_registrator.hh" -#include "utils/fb_utilities.hh" #include "locator/token_metadata.hh" namespace locator { @@ -23,7 +22,7 @@ everywhere_replication_strategy::everywhere_replication_strategy(const replicati future everywhere_replication_strategy::calculate_natural_endpoints(const token& search_token, const token_metadata& tm) const { if (tm.sorted_tokens().empty()) { - endpoint_set result{inet_address_vector_replica_set({utils::fb_utilities::get_broadcast_address()})}; + endpoint_set result{inet_address_vector_replica_set({tm.get_topology().my_address()})}; return make_ready_future(std::move(result)); } const auto& all_endpoints = tm.get_all_endpoints(); diff --git a/locator/local_strategy.cc b/locator/local_strategy.cc index b3e479f2c1..8f213489c4 100644 --- a/locator/local_strategy.cc +++ b/locator/local_strategy.cc @@ -9,7 +9,6 @@ #include #include "local_strategy.hh" #include "utils/class_registrator.hh" -#include "utils/fb_utilities.hh" namespace locator { @@ -20,7 +19,7 @@ local_strategy::local_strategy(const replication_strategy_config_options& config } future local_strategy::calculate_natural_endpoints(const token& t, const token_metadata& tm) const { - return make_ready_future(endpoint_set({utils::fb_utilities::get_broadcast_address()})); + return make_ready_future(endpoint_set({tm.get_topology().my_address()})); } void local_strategy::validate_options(const gms::feature_service&) const { diff --git a/locator/network_topology_strategy.cc b/locator/network_topology_strategy.cc index 0434081eae..9f09674588 100644 --- a/locator/network_topology_strategy.cc +++ b/locator/network_topology_strategy.cc @@ -15,7 +15,6 @@ #include "locator/network_topology_strategy.hh" #include "locator/load_sketch.hh" -#include "utils/fb_utilities.hh" #include #include "utils/hash.hh" diff --git a/test/boost/network_topology_strategy_test.cc b/test/boost/network_topology_strategy_test.cc index 240ea70272..80fd48443e 100644 --- a/test/boost/network_topology_strategy_test.cc +++ b/test/boost/network_topology_strategy_test.cc @@ -11,7 +11,6 @@ #include "gms/inet_address.hh" #include "locator/types.hh" #include "utils/UUID_gen.hh" -#include "utils/fb_utilities.hh" #include "utils/sequenced_set.hh" #include "locator/network_topology_strategy.hh" #include "test/lib/scylla_test_case.hh" @@ -704,8 +703,10 @@ void generate_topology(topology& topo, const std::unordered_map } SEASTAR_THREAD_TEST_CASE(testCalculateEndpoints) { - utils::fb_utilities::set_broadcast_address(gms::inet_address("localhost")); - utils::fb_utilities::set_broadcast_rpc_address(gms::inet_address("localhost")); + locator::token_metadata::config tm_cfg; + auto my_address = gms::inet_address("localhost"); + tm_cfg.topo_cfg.this_endpoint = my_address; + tm_cfg.topo_cfg.this_cql_address = my_address; constexpr size_t NODES = 100; constexpr size_t VNODES = 64; @@ -726,7 +727,7 @@ SEASTAR_THREAD_TEST_CASE(testCalculateEndpoints) { for (size_t run = 0; run < RUNS; ++run) { semaphore sem(1); - shared_token_metadata stm([&sem] () noexcept { return get_units(sem, 1); }, locator::token_metadata::config{}); + shared_token_metadata stm([&sem] () noexcept { return get_units(sem, 1); }, tm_cfg); std::unordered_set random_tokens; while (random_tokens.size() < nodes.size() * VNODES) { @@ -813,8 +814,10 @@ void topology::test_compare_endpoints(const inet_address& address, const inet_ad } // namespace locator SEASTAR_THREAD_TEST_CASE(test_topology_compare_endpoints) { - utils::fb_utilities::set_broadcast_address(gms::inet_address("localhost")); - utils::fb_utilities::set_broadcast_rpc_address(gms::inet_address("localhost")); + locator::token_metadata::config tm_cfg; + auto my_address = gms::inet_address("localhost"); + tm_cfg.topo_cfg.this_endpoint = my_address; + tm_cfg.topo_cfg.this_cql_address = my_address; constexpr size_t NODES = 10; @@ -836,7 +839,7 @@ SEASTAR_THREAD_TEST_CASE(test_topology_compare_endpoints) { auto bogus_address = make_address(NODES + 1); semaphore sem(1); - shared_token_metadata stm([&sem] () noexcept { return get_units(sem, 1); }, locator::token_metadata::config{}); + shared_token_metadata stm([&sem] () noexcept { return get_units(sem, 1); }, tm_cfg); stm.mutate_token_metadata([&] (token_metadata& tm) { auto& topo = tm.get_topology(); generate_topology(topo, datacenters, nodes);