gossiper: Keep immutable options on gossip_config
Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
This commit is contained in:
@@ -60,16 +60,12 @@ const sstring& gossiper::get_cluster_name() const noexcept {
|
||||
return _gcfg.cluster_name;
|
||||
}
|
||||
|
||||
const sstring& gossiper::get_partitioner_name() const noexcept {
|
||||
return _cfg.partitioner();
|
||||
}
|
||||
|
||||
const std::set<inet_address>& gossiper::get_seeds() const noexcept {
|
||||
return _gcfg.seeds;
|
||||
}
|
||||
|
||||
std::chrono::milliseconds gossiper::quarantine_delay() const noexcept {
|
||||
auto delay = std::max(unsigned(30000), _cfg.ring_delay_ms());
|
||||
auto delay = std::max(unsigned(30000), _gcfg.ring_delay_ms);
|
||||
auto ring_delay = std::chrono::milliseconds(delay);
|
||||
return ring_delay * 2;
|
||||
}
|
||||
@@ -1160,7 +1156,7 @@ future<> gossiper::advertise_removing(inet_address endpoint, utils::UUID host_id
|
||||
// remember this node's generation
|
||||
int generation = state.get_heart_beat_state().get_generation();
|
||||
logger.info("Removing host: {}", host_id);
|
||||
auto ring_delay = std::chrono::milliseconds(_cfg.ring_delay_ms());
|
||||
auto ring_delay = std::chrono::milliseconds(_gcfg.ring_delay_ms);
|
||||
logger.info("Sleeping for {}ms to ensure {} does not change", ring_delay.count(), endpoint);
|
||||
co_await sleep_abortable(ring_delay, _abort_source);
|
||||
// make sure it did not change
|
||||
@@ -1219,7 +1215,7 @@ future<> gossiper::assassinate_endpoint(sstring address) {
|
||||
|
||||
int generation = ep_state.get_heart_beat_state().get_generation();
|
||||
int heartbeat = ep_state.get_heart_beat_state().get_heart_beat_version();
|
||||
auto ring_delay = std::chrono::milliseconds(gossiper._cfg.ring_delay_ms());
|
||||
auto ring_delay = std::chrono::milliseconds(gossiper._gcfg.ring_delay_ms);
|
||||
logger.info("Sleeping for {} ms to ensure {} does not change", ring_delay.count(), endpoint);
|
||||
// make sure it did not change
|
||||
sleep_abortable(ring_delay, gossiper._abort_source).get();
|
||||
@@ -1908,7 +1904,7 @@ future<> gossiper::do_shadow_round(std::unordered_set<gms::inet_address> nodes)
|
||||
if (fall_back_to_syn_msg) {
|
||||
break;
|
||||
}
|
||||
if (clk::now() > start_time + std::chrono::milliseconds(_cfg.shadow_round_ms())) {
|
||||
if (clk::now() > start_time + std::chrono::milliseconds(_gcfg.shadow_round_ms)) {
|
||||
throw std::runtime_error(format("Unable to gossip with any nodes={} (ShadowRound).", nodes));
|
||||
}
|
||||
sleep_abortable(std::chrono::seconds(1), _abort_source).get();
|
||||
@@ -1933,7 +1929,7 @@ future<> gossiper::do_shadow_round(std::unordered_set<gms::inet_address> nodes)
|
||||
}
|
||||
sleep_abortable(std::chrono::seconds(1), _abort_source).get();
|
||||
if (is_in_shadow_round()) {
|
||||
if (clk::now() > t + std::chrono::milliseconds(_cfg.shadow_round_ms())) {
|
||||
if (clk::now() > t + std::chrono::milliseconds(_gcfg.shadow_round_ms)) {
|
||||
throw std::runtime_error(format("Unable to gossip with any nodes={} (ShadowRound),", nodes));
|
||||
}
|
||||
logger.info("Connect nodes={} again ... ({} seconds passed)",
|
||||
@@ -2108,7 +2104,7 @@ future<> gossiper::do_stop_gossiping() {
|
||||
return make_ready_future<>();
|
||||
}).get();
|
||||
}
|
||||
sleep(std::chrono::milliseconds(_cfg.shutdown_announce_in_ms())).get();
|
||||
sleep(std::chrono::milliseconds(_gcfg.shutdown_announce_ms)).get();
|
||||
} else {
|
||||
logger.warn("No local state or state is in silent shutdown, not announcing shutdown");
|
||||
}
|
||||
@@ -2334,7 +2330,7 @@ future<> gossiper::wait_for_gossip(std::chrono::milliseconds initial_delay, std:
|
||||
|
||||
future<> gossiper::wait_for_gossip_to_settle() {
|
||||
static constexpr std::chrono::milliseconds GOSSIP_SETTLE_MIN_WAIT_MS{5000};
|
||||
auto force_after = _cfg.skip_wait_for_gossip_to_settle();
|
||||
auto force_after = _gcfg.skip_wait_for_gossip_to_settle;
|
||||
auto do_enable_features = [this] {
|
||||
return async([this] {
|
||||
if (!std::exchange(_gossip_settled, true)) {
|
||||
@@ -2352,8 +2348,8 @@ future<> gossiper::wait_for_gossip_to_settle() {
|
||||
|
||||
future<> gossiper::wait_for_range_setup() {
|
||||
logger.info("Waiting for pending range setup...");
|
||||
auto ring_delay = std::chrono::milliseconds(_cfg.ring_delay_ms());
|
||||
auto force_after = _cfg.skip_wait_for_gossip_to_settle();
|
||||
auto ring_delay = std::chrono::milliseconds(_gcfg.ring_delay_ms);
|
||||
auto force_after = _gcfg.skip_wait_for_gossip_to_settle;
|
||||
return wait_for_gossip(ring_delay, force_after);
|
||||
}
|
||||
|
||||
|
||||
@@ -72,6 +72,11 @@ struct gossip_config {
|
||||
seastar::scheduling_group gossip_scheduling_group = seastar::scheduling_group();
|
||||
sstring cluster_name;
|
||||
std::set<inet_address> seeds;
|
||||
sstring partitioner;
|
||||
uint32_t ring_delay_ms = 30 * 1000;
|
||||
uint32_t shadow_round_ms = 300 * 1000;
|
||||
uint32_t shutdown_announce_ms = 2 * 1000;
|
||||
uint32_t skip_wait_for_gossip_to_settle = -1;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -129,7 +134,11 @@ public:
|
||||
// Only respond echo message listed in nodes with the generation number
|
||||
future<> advertise_to_nodes(std::unordered_map<gms::inet_address, int32_t> advertise_to_nodes = {});
|
||||
const sstring& get_cluster_name() const noexcept;
|
||||
const sstring& get_partitioner_name() const noexcept;
|
||||
|
||||
const sstring& get_partitioner_name() const noexcept {
|
||||
return _gcfg.partitioner;
|
||||
}
|
||||
|
||||
inet_address get_broadcast_address() const noexcept {
|
||||
return utils::fb_utilities::get_broadcast_address();
|
||||
}
|
||||
|
||||
5
main.cc
5
main.cc
@@ -840,6 +840,11 @@ To start the scylla server proper, simply invoke as: scylla server (or just scyl
|
||||
gcfg.gossip_scheduling_group = dbcfg.gossip_scheduling_group;
|
||||
gcfg.seeds = get_seeds_from_db_config(*cfg);
|
||||
gcfg.cluster_name = cfg->cluster_name();
|
||||
gcfg.partitioner = cfg->partitioner();
|
||||
gcfg.ring_delay_ms = cfg->ring_delay_ms();
|
||||
gcfg.shadow_round_ms = cfg->shadow_round_ms();
|
||||
gcfg.shutdown_announce_ms = cfg->shutdown_announce_in_ms();
|
||||
gcfg.skip_wait_for_gossip_to_settle = cfg->skip_wait_for_gossip_to_settle();
|
||||
if (gcfg.cluster_name.empty()) {
|
||||
gcfg.cluster_name = "Test Cluster";
|
||||
startlog.warn("Using default cluster name is not recommended. Using a unique cluster name will reduce the chance of adding nodes to the wrong cluster by mistake");
|
||||
|
||||
Reference in New Issue
Block a user