locator: Make sharder accessible through effective_replication_map
For tablets, sharding depends on replication map, so the scope of the sharder should be effective_replicaion_map rather than the schema object. Existing users will be transitioned incrementally in later patches.
This commit is contained in:
@@ -134,6 +134,10 @@ std::unique_ptr<token_range_splitter> vnode_effective_replication_map::make_spli
|
||||
return locator::make_splitter(_tmptr);
|
||||
}
|
||||
|
||||
const dht::sharder& vnode_effective_replication_map::get_sharder(const schema& s) const {
|
||||
return s.get_sharder();
|
||||
}
|
||||
|
||||
const per_table_replication_strategy* abstract_replication_strategy::maybe_as_per_table() const {
|
||||
if (!_per_table) {
|
||||
return nullptr;
|
||||
|
||||
@@ -213,6 +213,14 @@ public:
|
||||
/// Returns a token_range_splitter which is line with the replica assignment of this replication map.
|
||||
/// The splitter can live longer than this instance.
|
||||
virtual std::unique_ptr<token_range_splitter> make_splitter() const = 0;
|
||||
|
||||
/// Returns a sharder which reflects shard replica assignment of this replication map.
|
||||
/// The sharder is valid as long as this instance is kept alive.
|
||||
virtual const dht::sharder& get_sharder(const schema& s) const = 0;
|
||||
|
||||
shard_id shard_of(const schema& s, dht::token t) const {
|
||||
return get_sharder(s).shard_of(t);
|
||||
}
|
||||
};
|
||||
|
||||
using effective_replication_map_ptr = seastar::shared_ptr<const effective_replication_map>;
|
||||
@@ -274,6 +282,7 @@ public: // effective_replication_map
|
||||
std::optional<inet_address_vector_replica_set> get_endpoints_for_reading(const token& search_token) const override;
|
||||
bool has_pending_ranges(inet_address endpoint) const override;
|
||||
std::unique_ptr<token_range_splitter> make_splitter() const override;
|
||||
const dht::sharder& get_sharder(const schema& s) const override;
|
||||
public:
|
||||
explicit vnode_effective_replication_map(replication_strategy_ptr rs, token_metadata_ptr tmptr, replication_map replication_map,
|
||||
ring_mapping pending_endpoints, ring_mapping read_endpoints, size_t replication_factor) noexcept
|
||||
|
||||
@@ -202,6 +202,7 @@ size_t tablet_metadata::external_memory_usage() const {
|
||||
|
||||
class tablet_effective_replication_map : public effective_replication_map {
|
||||
table_id _table;
|
||||
tablet_sharder _sharder;
|
||||
private:
|
||||
gms::inet_address get_endpoint_for_host_id(host_id host) const {
|
||||
auto endpoint_opt = _tmptr->get_endpoint_for_host_id(host);
|
||||
@@ -228,6 +229,7 @@ public:
|
||||
size_t replication_factor)
|
||||
: effective_replication_map(std::move(rs), std::move(tmptr), replication_factor)
|
||||
, _table(table)
|
||||
, _sharder(*_tmptr, table)
|
||||
{ }
|
||||
|
||||
virtual ~tablet_effective_replication_map() = default;
|
||||
@@ -301,6 +303,10 @@ public:
|
||||
};
|
||||
return std::make_unique<splitter>(_tmptr, get_tablet_map());
|
||||
}
|
||||
|
||||
const dht::sharder& get_sharder(const schema& s) const override {
|
||||
return _sharder;
|
||||
}
|
||||
};
|
||||
|
||||
size_t tablet_aware_replication_strategy::parse_initial_tablets(const sstring& val) const {
|
||||
|
||||
Reference in New Issue
Block a user