snitch: Remove gossiper reference
It doesn't need gossiper any longer. This change will allow starting snitch early by the next patch, and eventually improving the token-metadata start-up sequence Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
This commit is contained in:
@@ -9,7 +9,6 @@
|
||||
*/
|
||||
|
||||
#include "locator/snitch_base.hh"
|
||||
#include "gms/gossiper.hh"
|
||||
#include "gms/application_state.hh"
|
||||
|
||||
namespace locator {
|
||||
@@ -21,8 +20,8 @@ std::list<std::pair<gms::application_state, gms::versioned_value>> snitch_base::
|
||||
};
|
||||
}
|
||||
|
||||
snitch_ptr::snitch_ptr(const snitch_config cfg, sharded<gms::gossiper>& g)
|
||||
: _gossiper(g) {
|
||||
snitch_ptr::snitch_ptr(const snitch_config cfg)
|
||||
{
|
||||
i_endpoint_snitch::ptr_type s;
|
||||
try {
|
||||
s = create_object<i_endpoint_snitch>(cfg.name, cfg);
|
||||
|
||||
@@ -206,17 +206,10 @@ struct snitch_ptr : public peering_sharded_service<snitch_ptr> {
|
||||
return _ptr ? true : false;
|
||||
}
|
||||
|
||||
snitch_ptr(const snitch_config cfg, sharded<gms::gossiper>&);
|
||||
|
||||
gms::gossiper& get_local_gossiper() noexcept { return _gossiper.local(); }
|
||||
const gms::gossiper& get_local_gossiper() const noexcept { return _gossiper.local(); }
|
||||
|
||||
sharded<gms::gossiper>& get_gossiper() noexcept { return _gossiper; }
|
||||
const sharded<gms::gossiper>& get_gossiper() const noexcept { return _gossiper; }
|
||||
snitch_ptr(const snitch_config cfg);
|
||||
|
||||
private:
|
||||
ptr_type _ptr;
|
||||
sharded<gms::gossiper>& _gossiper;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -246,7 +239,7 @@ inline future<> i_endpoint_snitch::reset_snitch(snitch_config cfg) {
|
||||
// (1) create a new snitch
|
||||
distributed<snitch_ptr> tmp_snitch;
|
||||
try {
|
||||
tmp_snitch.start(cfg, std::ref(get_local_snitch_ptr().get_gossiper())).get();
|
||||
tmp_snitch.start(cfg).get();
|
||||
|
||||
// (2) start the local instances of the new snitch
|
||||
tmp_snitch.invoke_on_all([] (snitch_ptr& local_inst) {
|
||||
|
||||
2
main.cc
2
main.cc
@@ -895,7 +895,7 @@ To start the scylla server proper, simply invoke as: scylla server (or just scyl
|
||||
snitch_cfg.broadcast_rpc_address_specified_by_user = !cfg->broadcast_rpc_address().empty();
|
||||
snitch_cfg.listen_address = utils::resolve(cfg->listen_address, family).get0();
|
||||
sharded<locator::snitch_ptr>& snitch = i_endpoint_snitch::snitch_instance();
|
||||
snitch.start(snitch_cfg, std::ref(gossiper)).get();
|
||||
snitch.start(snitch_cfg).get();
|
||||
auto stop_snitch = defer_verbose_shutdown("snitch", [&snitch] {
|
||||
snitch.stop().get();
|
||||
});
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include "locator/gossiping_property_file_snitch.hh"
|
||||
#include "utils/fb_utilities.hh"
|
||||
#include "gms/gossiper.hh"
|
||||
#include <seastar/testing/test_case.hh>
|
||||
#include <seastar/util/std-compat.hh>
|
||||
#include <seastar/core/reactor.hh>
|
||||
@@ -21,10 +20,9 @@
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
static fs::path test_files_subdir("test/resource/snitch_property_files");
|
||||
static sharded<gms::gossiper> gossiper;
|
||||
|
||||
static future<> create_snitch(locator::snitch_config cfg) {
|
||||
return locator::i_endpoint_snitch::snitch_instance().start(cfg, std::ref(gossiper)).then([] {
|
||||
return locator::i_endpoint_snitch::snitch_instance().start(cfg).then([] {
|
||||
return locator::i_endpoint_snitch::snitch_instance().invoke_on_all(&locator::snitch_ptr::start);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -193,9 +193,8 @@ void simple_test() {
|
||||
// Create the RackInferringSnitch
|
||||
snitch_config cfg;
|
||||
cfg.name = "RackInferringSnitch";
|
||||
sharded<gms::gossiper> g;
|
||||
sharded<snitch_ptr>& snitch = i_endpoint_snitch::snitch_instance();
|
||||
snitch.start(cfg, std::ref(g)).get();
|
||||
snitch.start(cfg).get();
|
||||
auto stop_snitch = defer([&snitch] { snitch.stop().get(); });
|
||||
snitch.invoke_on_all(&snitch_ptr::start).get();
|
||||
|
||||
@@ -278,9 +277,8 @@ void heavy_origin_test() {
|
||||
// Create the RackInferringSnitch
|
||||
snitch_config cfg;
|
||||
cfg.name = "RackInferringSnitch";
|
||||
sharded<gms::gossiper> g;
|
||||
sharded<snitch_ptr>& snitch = i_endpoint_snitch::snitch_instance();
|
||||
snitch.start(cfg, std::ref(g)).get();
|
||||
snitch.start(cfg).get();
|
||||
auto stop_snitch = defer([&snitch] { snitch.stop().get(); });
|
||||
snitch.invoke_on_all(&snitch_ptr::start).get();
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include "locator/gossiping_property_file_snitch.hh"
|
||||
#include "utils/fb_utilities.hh"
|
||||
#include "gms/gossiper.hh"
|
||||
#include <seastar/testing/test_case.hh>
|
||||
#include <seastar/util/std-compat.hh>
|
||||
#include <vector>
|
||||
@@ -40,7 +39,6 @@ future<> one_test(const std::string& property_fname1,
|
||||
auto cpu0_dc_new = make_lw_shared<sstring>();
|
||||
auto cpu0_rack_new = make_lw_shared<sstring>();
|
||||
auto my_address = utils::fb_utilities::get_broadcast_address();
|
||||
sharded<gms::gossiper> g;
|
||||
sharded<snitch_ptr>& snitch = i_endpoint_snitch::snitch_instance();
|
||||
|
||||
try {
|
||||
@@ -54,7 +52,7 @@ future<> one_test(const std::string& property_fname1,
|
||||
snitch_config cfg;
|
||||
cfg.name = "org.apache.cassandra.locator.GossipingPropertyFileSnitch";
|
||||
cfg.properties_file_name = fname1.string();
|
||||
snitch.start(cfg, std::ref(g)).get();
|
||||
snitch.start(cfg).get();
|
||||
snitch.invoke_on_all(&snitch_ptr::start).get();
|
||||
} catch (std::exception& e) {
|
||||
printf("%s\n", e.what());
|
||||
|
||||
@@ -605,7 +605,7 @@ public:
|
||||
gossiper.invoke_on_all(&gms::gossiper::start).get();
|
||||
|
||||
sharded<locator::snitch_ptr>& snitch = locator::i_endpoint_snitch::snitch_instance();
|
||||
snitch.start(locator::snitch_config{}, std::ref(gossiper)).get();
|
||||
snitch.start(locator::snitch_config{}).get();
|
||||
auto stop_snitch = defer([&snitch] { snitch.stop().get(); });
|
||||
snitch.invoke_on_all(&locator::snitch_ptr::start).get();
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include "locator/ec2_snitch.hh"
|
||||
#include "gms/gossiper.hh"
|
||||
#include "utils/fb_utilities.hh"
|
||||
#include <seastar/testing/test_case.hh>
|
||||
#include <seastar/util/std-compat.hh>
|
||||
@@ -38,9 +37,8 @@ future<> one_test(const std::string& property_fname, bool exp_result) {
|
||||
snitch_config cfg;
|
||||
cfg.name = "Ec2Snitch";
|
||||
cfg.properties_file_name = fname.string();
|
||||
sharded<gms::gossiper> g;
|
||||
auto start = [cfg, &g] {
|
||||
return i_endpoint_snitch::snitch_instance().start(cfg, std::ref(g)).then([] {
|
||||
auto start = [cfg] {
|
||||
return i_endpoint_snitch::snitch_instance().start(cfg).then([] {
|
||||
return i_endpoint_snitch::snitch_instance().invoke_on_all(&snitch_ptr::start);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include <seastar/http/httpd.hh>
|
||||
#include <seastar/net/inet_address.hh>
|
||||
#include <seastar/util/std-compat.hh>
|
||||
#include "gms/gossiper.hh"
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
@@ -85,9 +84,8 @@ future<> one_test(const std::string& property_fname, bool exp_result) {
|
||||
cfg.name = "GoogleCloudSnitch";
|
||||
cfg.properties_file_name = fname.string();
|
||||
cfg.gce_meta_server_url = meta_url;
|
||||
sharded<gms::gossiper> g;
|
||||
sharded<snitch_ptr>& snitch = i_endpoint_snitch::snitch_instance();
|
||||
snitch.start(cfg, std::ref(g)).get();
|
||||
snitch.start(cfg).get();
|
||||
snitch.invoke_on_all(&snitch_ptr::start).get();
|
||||
if (!exp_result) {
|
||||
BOOST_ERROR("Failed to catch an error in a malformed configuration file");
|
||||
|
||||
Reference in New Issue
Block a user