Merge "Use num_tokens from config file" from Glauber

"Without this, we cannot use our sstables in Cassandra 2.1.8 without
edititing their conf file first, to expect 3 tokens - a number we hard code."
This commit is contained in:
Avi Kivity
2015-08-10 12:50:40 +03:00
3 changed files with 7 additions and 7 deletions

View File

@@ -23,6 +23,8 @@
#include "locator/token_metadata.hh"
#include "dht/i_partitioner.hh"
#include <unordered_set>
#include "database.hh"
#include "db/config.hh"
namespace dht {
@@ -77,7 +79,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<token> get_bootstrap_tokens(token_metadata metadata) {
static std::unordered_set<token> get_bootstrap_tokens(token_metadata metadata, database& db) {
#if 0
Collection<String> initialTokens = DatabaseDescriptor.getInitialTokens();
// if user specified tokens, use those
@@ -95,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");
}

View File

@@ -80,7 +80,7 @@ int main(int ac, char** av) {
("api-dir", bpo::value<sstring>()->default_value("swagger-ui/dist/"),
"The directory location of the API GUI")
// TODO : default, always read?
("options-file", bpo::value<sstring>(), "cassandra.yaml file to read options from")
("options-file", bpo::value<sstring>()->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")
;

View File

@@ -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()) {
@@ -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