So that using calaculate_natural_endpoints can be optimized for strategies that return the same endpoints for all tokens, namely everywhere_replication_strategy and local_strategy. Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
50 lines
1.4 KiB
C++
50 lines
1.4 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 bool natural_endpoints_depend_on_token() const noexcept override { return false; }
|
|
|
|
virtual future<endpoint_set> calculate_natural_endpoints(const token& search_token, const token_metadata& tm) const override;
|
|
|
|
virtual void validate_options() const override;
|
|
|
|
virtual std::optional<std::set<sstring>> recognized_options(const topology&) const override;
|
|
|
|
virtual bool allow_remove_node_being_replaced_from_natural_endpoints() const override {
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* We need to override this because the default implementation depends
|
|
* on token calculations but LocalStrategy may be used before tokens are set up.
|
|
*/
|
|
inet_address_vector_replica_set get_natural_endpoints(const token&, const effective_replication_map&) const override;
|
|
};
|
|
|
|
}
|