From 6dc56fd80b2d01452da76b3a63c696ae874a2b2a Mon Sep 17 00:00:00 2001 From: Tomasz Grabiec Date: Fri, 19 Jan 2024 12:12:03 +0100 Subject: [PATCH] tablets: Move migration_to_transition_info() to tablets.hh --- locator/tablets.cc | 9 +++++++++ locator/tablets.hh | 1 + test/boost/tablets_test.cc | 12 +----------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/locator/tablets.cc b/locator/tablets.cc index b684a5d3b2..41f9da2dfe 100644 --- a/locator/tablets.cc +++ b/locator/tablets.cc @@ -111,6 +111,15 @@ tablet_replica_set get_new_replicas(const tablet_info& tinfo, const tablet_migra return replace_replica(tinfo.replicas, mig.src, mig.dst); } +tablet_transition_info migration_to_transition_info(const tablet_info& ti, const tablet_migration_info& mig) { + return tablet_transition_info { + tablet_transition_stage::allow_write_both_read_old, + mig.kind, + get_new_replicas(ti, mig), + mig.dst + }; +} + const tablet_map& tablet_metadata::get_tablet_map(table_id id) const { try { return _tablets.at(id); diff --git a/locator/tablets.hh b/locator/tablets.hh index 6421e3dd54..171477380c 100644 --- a/locator/tablets.hh +++ b/locator/tablets.hh @@ -211,6 +211,7 @@ struct tablet_migration_info { /// Returns the replica set which will become the replica set of the tablet after executing a given tablet transition. tablet_replica_set get_new_replicas(const tablet_info&, const tablet_migration_info&); +tablet_transition_info migration_to_transition_info(const tablet_info&, const tablet_migration_info&); /// Describes streaming required for a given tablet transition. struct tablet_migration_streaming_info { diff --git a/test/boost/tablets_test.cc b/test/boost/tablets_test.cc index c321320cf4..a99087ee7f 100644 --- a/test/boost/tablets_test.cc +++ b/test/boost/tablets_test.cc @@ -612,23 +612,13 @@ void apply_plan(token_metadata& tm, const migration_plan& plan) { } } -static -tablet_transition_info migration_to_transition_info(const tablet_migration_info& mig, const tablet_info& ti) { - return tablet_transition_info { - tablet_transition_stage::allow_write_both_read_old, - mig.kind, - get_new_replicas(ti, mig), - mig.dst - }; -} - // Reflects the plan in a given token metadata as if the migrations were started but not yet executed. static void apply_plan_as_in_progress(token_metadata& tm, const migration_plan& plan) { for (auto&& mig : plan.migrations()) { tablet_map& tmap = tm.tablets().get_tablet_map(mig.tablet.table); auto tinfo = tmap.get_tablet_info(mig.tablet.tablet); - tmap.set_tablet_transition_info(mig.tablet.tablet, migration_to_transition_info(mig, tinfo)); + tmap.set_tablet_transition_info(mig.tablet.tablet, migration_to_transition_info(tinfo, mig)); } }