From c52f70f92c22eacb7b3d113800a379e00a9824f2 Mon Sep 17 00:00:00 2001 From: Benny Halevy Date: Sun, 2 Jun 2024 20:15:12 +0300 Subject: [PATCH] locator: tablet_map: get_primary_replica: return tablet_replica This is required by repair when it will start using get_primary_replica in a following patch. Signed-off-by: Benny Halevy --- locator/tablets.cc | 4 ++-- locator/tablets.hh | 2 +- service/storage_service.cc | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/locator/tablets.cc b/locator/tablets.cc index 28ec2ef44f..fce280ffe9 100644 --- a/locator/tablets.cc +++ b/locator/tablets.cc @@ -245,9 +245,9 @@ dht::token_range tablet_map::get_token_range(tablet_id id) const { } } -host_id tablet_map::get_primary_replica(tablet_id id) const { +tablet_replica tablet_map::get_primary_replica(tablet_id id) const { const auto info = get_tablet_info(id); - return info.replicas.at(size_t(id) % info.replicas.size()).host; + return info.replicas.at(size_t(id) % info.replicas.size()); } future> tablet_map::get_sorted_tokens() const { diff --git a/locator/tablets.hh b/locator/tablets.hh index a0200030e3..faed694e56 100644 --- a/locator/tablets.hh +++ b/locator/tablets.hh @@ -360,7 +360,7 @@ public: dht::token_range get_token_range(tablet_id id) const; /// Returns the primary replica for the tablet - host_id get_primary_replica(tablet_id id) const; + tablet_replica get_primary_replica(tablet_id id) const; /// Returns a vector of sorted last tokens for tablets. future> get_sorted_tokens() const; diff --git a/service/storage_service.cc b/service/storage_service.cc index a451187fe5..b415551ea6 100644 --- a/service/storage_service.cc +++ b/service/storage_service.cc @@ -5055,7 +5055,7 @@ future> storage_service::get_tablet_to_endpoint_ma const auto& tmap = tm.tablets().get_tablet_map(table); std::map result; for (std::optional tid = tmap.first_tablet(); tid; tid = tmap.next_tablet(*tid)) { - result.emplace(tmap.get_last_token(*tid), tm.get_endpoint_for_host_id(tmap.get_primary_replica(*tid))); + result.emplace(tmap.get_last_token(*tid), tm.get_endpoint_for_host_id(tmap.get_primary_replica(*tid).host)); co_await coroutine::maybe_yield(); } co_return result;