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.
42 lines
1.1 KiB
C++
42 lines
1.1 KiB
C++
/*
|
|
* Copyright (C) 2015-present ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "abstract_replication_strategy.hh"
|
|
|
|
#include <optional>
|
|
#include <set>
|
|
|
|
// forward declaration since replica/database.hh includes this file
|
|
class keyspace;
|
|
|
|
namespace locator {
|
|
|
|
using inet_address = gms::inet_address;
|
|
using token = dht::token;
|
|
|
|
class local_strategy : public abstract_replication_strategy {
|
|
public:
|
|
local_strategy(const replication_strategy_config_options& config_options);
|
|
virtual ~local_strategy() {};
|
|
virtual size_t get_replication_factor(const token_metadata&) const override;
|
|
|
|
virtual future<endpoint_set> calculate_natural_endpoints(const token& search_token, const token_metadata& tm) const override;
|
|
|
|
virtual void validate_options(const gms::feature_service&) const override;
|
|
|
|
virtual std::optional<std::unordered_set<sstring>> recognized_options(const topology&) const override;
|
|
|
|
virtual bool allow_remove_node_being_replaced_from_natural_endpoints() const override {
|
|
return false;
|
|
}
|
|
};
|
|
|
|
}
|