Merge "Update system keyspace rs to local_strategy" from Shlomi
"local_strategy is used for system keyspaces to allow query / update of tables without the need to have snitch or token metadata avilable without this patch updating of system tables (e.g. insert system.local ...) fails."
This commit is contained in:
29
locator/local_strategy.cc
Normal file
29
locator/local_strategy.cc
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Cloudius Systems, Ltd.
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include "local_strategy.hh"
|
||||
#include "utils/class_registrator.hh"
|
||||
#include "utils/fb_utilities.hh"
|
||||
|
||||
|
||||
namespace locator {
|
||||
|
||||
local_strategy::local_strategy(const sstring& keyspace_name, token_metadata& token_metadata, snitch_ptr&& snitch, const std::map<sstring, sstring>& config_options) :
|
||||
abstract_replication_strategy(keyspace_name, token_metadata, std::move(snitch), config_options) {}
|
||||
|
||||
std::vector<inet_address> local_strategy::calculate_natural_endpoints(const token& t) {
|
||||
std::vector<inet_address> endpoints;
|
||||
endpoints.push_back(utils::fb_utilities::get_broadcast_address());
|
||||
return endpoints;
|
||||
}
|
||||
|
||||
size_t local_strategy::get_replication_factor() const {
|
||||
return 1;
|
||||
}
|
||||
|
||||
using registry = class_registrator<abstract_replication_strategy, local_strategy, const sstring&, token_metadata&, snitch_ptr&&, const std::map<sstring, sstring>&>;
|
||||
static registry registrator("org.apache.cassandra.locator.LocalStrategy");
|
||||
|
||||
}
|
||||
26
locator/local_strategy.hh
Normal file
26
locator/local_strategy.hh
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Cloudius Systems, Ltd.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "abstract_replication_strategy.hh"
|
||||
|
||||
// forward declaration since 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 {
|
||||
protected:
|
||||
virtual std::vector<inet_address> calculate_natural_endpoints(const token& search_token);
|
||||
public:
|
||||
local_strategy(const sstring& keyspace_name, token_metadata& token_metadata, snitch_ptr&& snitch, const std::map<sstring, sstring>& config_options);
|
||||
virtual ~local_strategy() {};
|
||||
virtual size_t get_replication_factor() const;
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user