NodeId is used in all internal token_metadata data structures, that previously used inet_address. We choose topology::key_kind based on the value of the template parameter. generic_token_metadata::update_topology overload with host_id parameter is added to make update_topology_change_info work, it now uses NodeId as a parameter type. topology::remove_endpoint(host_id) is added to make generic_token_metadata::remove_endpoint(NodeId) work. pending_endpoints_for and endpoints_for_reading are just removed - they are not used and not implemented. The declarations were left by mistake from a refactoring in which these methods were moved to erm. generic_token_metadata_base is extracted to contain declarations, common to both token_metadata versions. Templates are explicitly instantiated inside token_metadata.cc, since implementation part is also a template and it's not exposed to the header. There are no other behavioral changes in this commit, just syntax fixes to make token_metadata a template.
78 lines
2.2 KiB
C++
78 lines
2.2 KiB
C++
/*
|
|
* Copyright (C) 2015-present ScyllaDB
|
|
*
|
|
* Modified by ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: (AGPL-3.0-or-later and Apache-2.0)
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "cql3/statements/property_definitions.hh"
|
|
#include "data_dictionary/storage_options.hh"
|
|
#include "locator/host_id.hh"
|
|
|
|
#include <seastar/core/shared_ptr.hh>
|
|
#include <seastar/core/sstring.hh>
|
|
#include <optional>
|
|
|
|
namespace data_dictionary {
|
|
class keyspace_metadata;
|
|
}
|
|
namespace gms {
|
|
class inet_address;
|
|
}
|
|
|
|
namespace locator {
|
|
template <typename NodeId>
|
|
class generic_token_metadata;
|
|
using token_metadata = generic_token_metadata<gms::inet_address>;
|
|
using token_metadata2 = generic_token_metadata<host_id>;
|
|
class shared_token_metadata;
|
|
struct snitch_ptr;
|
|
class abstract_replication_strategy;
|
|
} // namespace locator
|
|
|
|
namespace cql3 {
|
|
|
|
namespace statements {
|
|
|
|
class ks_prop_defs : public property_definitions {
|
|
public:
|
|
static constexpr auto KW_DURABLE_WRITES = "durable_writes";
|
|
static constexpr auto KW_REPLICATION = "replication";
|
|
static constexpr auto KW_STORAGE = "storage";
|
|
|
|
static constexpr auto REPLICATION_STRATEGY_CLASS_KEY = "class";
|
|
static constexpr auto REPLICATION_FACTOR_KEY = "replication_factor";
|
|
private:
|
|
std::optional<sstring> _strategy_class;
|
|
public:
|
|
void validate();
|
|
std::map<sstring, sstring> get_replication_options() const;
|
|
std::optional<sstring> get_replication_strategy_class() const;
|
|
data_dictionary::storage_options get_storage_options() const;
|
|
lw_shared_ptr<data_dictionary::keyspace_metadata> as_ks_metadata(sstring ks_name, const locator::token_metadata&);
|
|
lw_shared_ptr<data_dictionary::keyspace_metadata> as_ks_metadata_update(lw_shared_ptr<data_dictionary::keyspace_metadata> old, const locator::token_metadata&);
|
|
|
|
#if 0
|
|
public KSMetaData asKSMetadataUpdate(KSMetaData old) throws RequestValidationException
|
|
{
|
|
String sClass = strategyClass;
|
|
Map<String, String> sOptions = getReplicationOptions();
|
|
if (sClass == null)
|
|
{
|
|
sClass = old.strategyClass.getName();
|
|
sOptions = old.strategyOptions;
|
|
}
|
|
return KSMetaData.newKeyspace(old.name, sClass, sOptions, getBoolean(KW_DURABLE_WRITES, old.durableWrites));
|
|
}
|
|
#endif
|
|
};
|
|
|
|
}
|
|
|
|
}
|