From 2678b0e60699cd61d9e0533c67cbcb07aa14469d Mon Sep 17 00:00:00 2001 From: Glauber Costa Date: Fri, 7 Aug 2015 10:35:28 -0500 Subject: [PATCH 1/3] dht: change get_bootstrap_tokens()'s signature It needs to access the non-existent "DatabaseDescriptor". Do as we have been doing, and just pass the database object instead. Signed-off-by: Glauber Costa --- dht/boot_strapper.hh | 3 ++- service/storage_service.cc | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dht/boot_strapper.hh b/dht/boot_strapper.hh index 55c29b5e08..20d1ab87e9 100644 --- a/dht/boot_strapper.hh +++ b/dht/boot_strapper.hh @@ -23,6 +23,7 @@ #include "locator/token_metadata.hh" #include "dht/i_partitioner.hh" #include +#include "database.hh" namespace dht { @@ -77,7 +78,7 @@ public: * otherwise, if num_tokens == 1, pick a token to assume half the load of the most-loaded node. * else choose num_tokens tokens at random */ - static std::unordered_set get_bootstrap_tokens(token_metadata metadata) { + static std::unordered_set get_bootstrap_tokens(token_metadata metadata, database& db) { #if 0 Collection initialTokens = DatabaseDescriptor.getInitialTokens(); // if user specified tokens, use those diff --git a/service/storage_service.cc b/service/storage_service.cc index 3969707fa6..58da77ff70 100644 --- a/service/storage_service.cc +++ b/service/storage_service.cc @@ -221,7 +221,7 @@ future<> storage_service::join_token_ring(int delay) { throw std::runtime_error("This node is already a member of the token ring; bootstrap aborted. (If replacing a dead node, remove the old one from the ring first.)"); } set_mode(mode::JOINING, "getting bootstrap token", true); - _bootstrap_tokens = boot_strapper::get_bootstrap_tokens(_token_metadata); + _bootstrap_tokens = boot_strapper::get_bootstrap_tokens(_token_metadata, _db.local()); } else { auto replace_addr = get_replace_address(); if (replace_addr && *replace_addr != get_broadcast_address()) { From 3426b3ecc19e4977d952ee2ae845c7de3e72074a Mon Sep 17 00:00:00 2001 From: Glauber Costa Date: Fri, 7 Aug 2015 10:42:11 -0500 Subject: [PATCH 2/3] bootstrap tokens: get tokens from config file Aside from being the obviously correct thing to do, not having this will force us to manually adjust num_tokens when running our sstables into Cassandra. Signed-off-by: Glauber Costa --- dht/boot_strapper.hh | 4 ++-- service/storage_service.cc | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/dht/boot_strapper.hh b/dht/boot_strapper.hh index 20d1ab87e9..65a7b215ad 100644 --- a/dht/boot_strapper.hh +++ b/dht/boot_strapper.hh @@ -24,6 +24,7 @@ #include "dht/i_partitioner.hh" #include #include "database.hh" +#include "db/config.hh" namespace dht { @@ -96,8 +97,7 @@ public: return tokens; } #endif - // FIXME: DatabaseDescriptor.getNumTokens(); - size_t num_tokens = 3; + size_t num_tokens = db.get_config().num_tokens(); if (num_tokens < 1) { throw std::runtime_error("num_tokens must be >= 1"); } diff --git a/service/storage_service.cc b/service/storage_service.cc index 58da77ff70..0cd329d09c 100644 --- a/service/storage_service.cc +++ b/service/storage_service.cc @@ -256,8 +256,7 @@ future<> storage_service::join_token_ring(int delay) { // FIXME: _is_bootstrap_mode is set to fasle in BootStrapper::bootstrap // assert(!_is_bootstrap_mode); // bootstrap will block until finished } else { - // FIXME: DatabaseDescriptor.getNumTokens() - size_t num_tokens = 3; + size_t num_tokens = _db.local().get_config().num_tokens(); _bootstrap_tokens = boot_strapper::get_random_tokens(_token_metadata, num_tokens); logger.info("Generated random tokens. tokens are {}", _bootstrap_tokens); #if 0 From 28f3b4a084faac3afa307db2fb9b3b71810b5cd4 Mon Sep 17 00:00:00 2001 From: Glauber Costa Date: Fri, 7 Aug 2015 11:08:29 -0500 Subject: [PATCH 3/3] main: add default value for configuration file We should have a better default here, that is prefixed by some directory. But this will do for now, so we can start using the file without passing it as a parameter all the time. Also fix help string so it says scylla, and not cassandra. Signed-off-by: Glauber Costa --- main.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.cc b/main.cc index e2d0db8fb3..b9f71fac2e 100644 --- a/main.cc +++ b/main.cc @@ -80,7 +80,7 @@ int main(int ac, char** av) { ("api-dir", bpo::value()->default_value("swagger-ui/dist/"), "The directory location of the API GUI") // TODO : default, always read? - ("options-file", bpo::value(), "cassandra.yaml file to read options from") + ("options-file", bpo::value()->default_value("conf/scylla.yaml"), "scylla.yaml file to read options from") ("help-loggers", bpo::bool_switch(&help_loggers), "print a list of logger names and exit") ;