tablets: Extract get_new_replicas() which works on migraiton request
Now we have a single place which translates tablet migration request to new replicas. Will be reused in other places.
This commit is contained in:
@@ -107,6 +107,10 @@ tablet_replica get_leaving_replica(const tablet_info& tinfo, const tablet_transi
|
||||
return *leaving.begin();
|
||||
}
|
||||
|
||||
tablet_replica_set get_new_replicas(const tablet_info& tinfo, const tablet_migration_info& mig) {
|
||||
return replace_replica(tinfo.replicas, mig.src, mig.dst);
|
||||
}
|
||||
|
||||
const tablet_map& tablet_metadata::get_tablet_map(table_id id) const {
|
||||
try {
|
||||
return _tablets.at(id);
|
||||
|
||||
@@ -209,6 +209,9 @@ struct tablet_migration_info {
|
||||
locator::tablet_replica dst;
|
||||
};
|
||||
|
||||
/// 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&);
|
||||
|
||||
/// Describes streaming required for a given tablet transition.
|
||||
struct tablet_migration_streaming_info {
|
||||
std::unordered_set<tablet_replica> read_from;
|
||||
|
||||
@@ -2044,7 +2044,7 @@ class topology_coordinator : public endpoint_lifecycle_subscriber {
|
||||
}
|
||||
out.emplace_back(
|
||||
replica::tablet_mutation_builder(guard.write_timestamp(), mig.tablet.table)
|
||||
.set_new_replicas(last_token, replace_replica(tmap.get_tablet_info(mig.tablet.tablet).replicas, mig.src, mig.dst))
|
||||
.set_new_replicas(last_token, locator::get_new_replicas(tmap.get_tablet_info(mig.tablet.tablet), mig))
|
||||
.set_stage(last_token, locator::tablet_transition_stage::allow_write_both_read_old)
|
||||
.set_transition(last_token, mig.kind)
|
||||
.build());
|
||||
|
||||
@@ -617,7 +617,7 @@ tablet_transition_info migration_to_transition_info(const tablet_migration_info&
|
||||
return tablet_transition_info {
|
||||
tablet_transition_stage::allow_write_both_read_old,
|
||||
mig.kind,
|
||||
replace_replica(ti.replicas, mig.src, mig.dst),
|
||||
get_new_replicas(ti, mig),
|
||||
mig.dst
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user