database: get_token_metadata -> new token_metadata
database::get_token_metadata() is switched to token_metadata2. get_all_ips method is added to the host_id-based token_metadata, since its convenient and will be used in several places. It returns all current nodes converted to inet_address by means of the topology contained within token_metadata. hint_sender::can_send: if the node has already left the cluster we may not find its host_id. This case is handled in the same way as if it's not a normal token owner - we simply send a hint to all replicas.
This commit is contained in:
@@ -101,7 +101,9 @@ bool hint_sender::can_send() noexcept {
|
||||
return true;
|
||||
} else {
|
||||
if (!_state.contains(state::ep_state_left_the_ring)) {
|
||||
_state.set_if<state::ep_state_left_the_ring>(!_shard_manager.local_db().get_token_metadata().is_normal_token_owner(end_point_key()));
|
||||
const auto& tm = _shard_manager.local_db().get_token_metadata();
|
||||
const auto host_id = tm.get_host_id_if_known(end_point_key());
|
||||
_state.set_if<state::ep_state_left_the_ring>(!host_id || !tm.is_normal_token_owner(*host_id));
|
||||
}
|
||||
// send the hints out if the destination Node is part of the ring - we will send to all new replicas in this case
|
||||
return _state.contains(state::ep_state_left_the_ring);
|
||||
|
||||
@@ -2573,7 +2573,7 @@ update_backlog node_update_backlog::add_fetch(unsigned shard, update_backlog bac
|
||||
return std::max(backlog, _max.load(std::memory_order_relaxed));
|
||||
}
|
||||
|
||||
future<bool> check_view_build_ongoing(db::system_distributed_keyspace& sys_dist_ks, const locator::token_metadata& tm, const sstring& ks_name,
|
||||
future<bool> check_view_build_ongoing(db::system_distributed_keyspace& sys_dist_ks, const locator::token_metadata2& tm, const sstring& ks_name,
|
||||
const sstring& cf_name) {
|
||||
using view_statuses_type = std::unordered_map<locator::host_id, sstring>;
|
||||
return sys_dist_ks.view_status(ks_name, cf_name).then([&tm] (view_statuses_type&& view_statuses) {
|
||||
@@ -2584,7 +2584,7 @@ future<bool> check_view_build_ongoing(db::system_distributed_keyspace& sys_dist_
|
||||
});
|
||||
}
|
||||
|
||||
future<bool> check_needs_view_update_path(db::system_distributed_keyspace& sys_dist_ks, const locator::token_metadata& tm, const replica::table& t,
|
||||
future<bool> check_needs_view_update_path(db::system_distributed_keyspace& sys_dist_ks, const locator::token_metadata2& tm, const replica::table& t,
|
||||
streaming::stream_reason reason) {
|
||||
if (is_internal_keyspace(t.schema()->ks_name())) {
|
||||
return make_ready_future<bool>(false);
|
||||
|
||||
@@ -32,7 +32,7 @@ using token_metadata2 = generic_token_metadata<host_id>;
|
||||
|
||||
namespace db::view {
|
||||
|
||||
future<bool> check_needs_view_update_path(db::system_distributed_keyspace& sys_dist_ks, const locator::token_metadata& tm, const replica::table& t,
|
||||
future<bool> check_needs_view_update_path(db::system_distributed_keyspace& sys_dist_ks, const locator::token_metadata2& tm, const replica::table& t,
|
||||
streaming::stream_reason reason);
|
||||
|
||||
}
|
||||
|
||||
@@ -1237,7 +1237,7 @@ future<> repair::user_requested_repair_task_impl::run() {
|
||||
participants = get_hosts_participating_in_repair(germs->get(), keyspace, ranges, data_centers, hosts, ignore_nodes).get();
|
||||
}
|
||||
if (needs_flush_before_repair) {
|
||||
auto waiting_nodes = db.get_token_metadata().get_all_endpoints();
|
||||
auto waiting_nodes = db.get_token_metadata().get_all_ips();
|
||||
std::erase_if(waiting_nodes, [&] (const auto& addr) {
|
||||
return ignore_nodes.contains(addr);
|
||||
});
|
||||
|
||||
@@ -1561,7 +1561,7 @@ public:
|
||||
}
|
||||
|
||||
const locator::shared_token_metadata& get_shared_token_metadata() const { return _shared_token_metadata; }
|
||||
const locator::token_metadata& get_token_metadata() const { return *_shared_token_metadata.get(); }
|
||||
const locator::token_metadata2& get_token_metadata() const { return *_shared_token_metadata.get()->get_new(); }
|
||||
|
||||
wasm::manager& wasm() noexcept { return _wasm; }
|
||||
const wasm::manager& wasm() const noexcept { return _wasm; }
|
||||
|
||||
@@ -181,7 +181,7 @@ static bool needs_repair_before_gc(const replica::database& db, sstring ks_name)
|
||||
auto& ks = db.find_keyspace(ks_name);
|
||||
auto& rs = ks.get_replication_strategy();
|
||||
bool needs_repair = rs.get_type() != locator::replication_strategy_type::local
|
||||
&& rs.get_replication_factor(*db.get_token_metadata().get_new()) != 1;
|
||||
&& rs.get_replication_factor(db.get_token_metadata()) != 1;
|
||||
return needs_repair;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user