mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-23 08:12:08 +00:00
storage_service: simplify storage_service::bootstrap method
The storage_service::bootstrap method took a parameter: tokens to bootstrap with. However, this method is only called in one place (join_token_ring) with only one parameter: _bootstrap_tokens. It doesn't make sense to call this method anywhere else with any other parameter. This commit also adds a comment explaining what the method does and moves it into the private section of storage_service.
This commit is contained in:
@@ -713,7 +713,7 @@ void storage_service::join_token_ring(int delay) {
|
||||
maybe_start_sys_dist_ks();
|
||||
mark_existing_views_as_built();
|
||||
db::system_keyspace::update_tokens(_bootstrap_tokens).get();
|
||||
bootstrap(_bootstrap_tokens);
|
||||
bootstrap();
|
||||
// bootstrap will block until finished
|
||||
if (_is_bootstrap_mode) {
|
||||
auto err = format("We are not supposed in bootstrap mode any more");
|
||||
@@ -817,21 +817,21 @@ void storage_service::mark_existing_views_as_built() {
|
||||
}
|
||||
|
||||
// Runs inside seastar::async context
|
||||
void storage_service::bootstrap(std::unordered_set<token> tokens) {
|
||||
void storage_service::bootstrap() {
|
||||
_is_bootstrap_mode = true;
|
||||
if (!db().local().is_replacing()) {
|
||||
// Wait until we know tokens of existing node before announcing join status.
|
||||
_gossiper.wait_for_range_setup().get();
|
||||
// if not an existing token then bootstrap
|
||||
_gossiper.add_local_application_state({
|
||||
{ gms::application_state::TOKENS, value_factory.tokens(tokens) },
|
||||
{ gms::application_state::STATUS, value_factory.bootstrapping(tokens) },
|
||||
{ gms::application_state::TOKENS, value_factory.tokens(_bootstrap_tokens) },
|
||||
{ gms::application_state::STATUS, value_factory.bootstrapping(_bootstrap_tokens) },
|
||||
}).get();
|
||||
set_mode(mode::JOINING, format("sleeping {} ms for pending range setup", get_ring_delay().count()), true);
|
||||
_gossiper.wait_for_range_setup().get();
|
||||
} else {
|
||||
// Dont set any state for the node which is bootstrapping the existing token...
|
||||
_token_metadata.update_normal_tokens(tokens, get_broadcast_address());
|
||||
_token_metadata.update_normal_tokens(_bootstrap_tokens, get_broadcast_address());
|
||||
replicate_to_all_cores().get();
|
||||
auto replace_addr = db().local().get_replace_address();
|
||||
if (replace_addr) {
|
||||
@@ -843,9 +843,10 @@ void storage_service::bootstrap(std::unordered_set<token> tokens) {
|
||||
_gossiper.check_seen_seeds();
|
||||
|
||||
set_mode(mode::JOINING, "Starting to bootstrap...", true);
|
||||
dht::boot_strapper bs(_db, _abort_source, get_broadcast_address(), tokens, _token_metadata);
|
||||
bs.bootstrap().get(); // handles token update
|
||||
slogger.info("Bootstrap completed! for the tokens {}", tokens);
|
||||
dht::boot_strapper bs(_db, _abort_source, get_broadcast_address(), _bootstrap_tokens, _token_metadata);
|
||||
// Does the actual streaming of newly replicated token ranges.
|
||||
bs.bootstrap().get();
|
||||
slogger.info("Bootstrap completed! for the tokens {}", _bootstrap_tokens);
|
||||
}
|
||||
|
||||
sstring
|
||||
|
||||
@@ -547,9 +547,13 @@ private:
|
||||
void set_mode(mode m, bool log);
|
||||
void set_mode(mode m, sstring msg, bool log);
|
||||
void mark_existing_views_as_built();
|
||||
public:
|
||||
void bootstrap(std::unordered_set<token> tokens);
|
||||
|
||||
// Stream data for which we become a new replica.
|
||||
// Before that, if we're not replacing another node, inform other nodes about our chosen tokens (_bootstrap_tokens)
|
||||
// and wait for RING_DELAY ms so that we receive new writes from coordinators during streaming.
|
||||
void bootstrap();
|
||||
|
||||
public:
|
||||
bool is_bootstrap_mode() {
|
||||
return _is_bootstrap_mode;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user