Files
scylla/locator/local_strategy.cc
Petr Gusev a8c36aad0b vnode_erm: optimize replication_map
We optimise memory usage of replication_map by
storing endpoints list only once in case of
natural_endpoints_depend_on_token() == false. For simplicity,
this list is stored in the same unordered_map with
special key default_replication_map_key.

We inline both get_natural_endpoints and
for_each_natural_endpoint_until from abstract_replication_strategy
into vnode_erm since now the overrides in local and everywhere
strategies are redundant. The default implementation works
for them as empty sorted_tokens() is not a problem, we
store endpoints with a special key.

Function do_get_natural_endpoints was extracted,
since get_natural_endpoints returns by val,
but for_each_natural_endpoint_until reference in sufficient.
2023-05-21 13:17:42 +04:00

43 lines
1.3 KiB
C++

/*
* Copyright (C) 2015-present ScyllaDB
*/
/*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
#include <algorithm>
#include "local_strategy.hh"
#include "utils/class_registrator.hh"
#include "utils/fb_utilities.hh"
namespace locator {
local_strategy::local_strategy(const replication_strategy_config_options& config_options) :
abstract_replication_strategy(config_options, replication_strategy_type::local) {
_natural_endpoints_depend_on_token = false;
}
future<endpoint_set> local_strategy::calculate_natural_endpoints(const token& t, const token_metadata& tm) const {
return make_ready_future<endpoint_set>(endpoint_set({utils::fb_utilities::get_broadcast_address()}));
}
void local_strategy::validate_options(const gms::feature_service&) const {
}
std::optional<std::unordered_set<sstring>> local_strategy::recognized_options(const topology&) const {
// LocalStrategy doesn't expect any options.
return {};
}
size_t local_strategy::get_replication_factor(const token_metadata&) const {
return 1;
}
using registry = class_registrator<abstract_replication_strategy, local_strategy, const replication_strategy_config_options&>;
static registry registrator("org.apache.cassandra.locator.LocalStrategy");
static registry registrator_short_name("LocalStrategy");
}