From 250d9332dc11400c831e8b7ea1acfe0f062fc67e Mon Sep 17 00:00:00 2001 From: Glauber Costa Date: Mon, 4 Jun 2018 11:19:57 -0400 Subject: [PATCH 1/2] partitioner: export the name of the algorithm used to do intra-node sharding We will export this on system tables. To avoid hard-coding it in the system table level, keep it at least in the dht layer where it belongs. Signed-off-by: Glauber Costa --- dht/i_partitioner.hh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dht/i_partitioner.hh b/dht/i_partitioner.hh index ded4d08041..0c6efe8bf5 100644 --- a/dht/i_partitioner.hh +++ b/dht/i_partitioner.hh @@ -380,6 +380,10 @@ public: return _shard_count; } + sstring cpu_sharding_algorithm_name() const { + return "biased-token-round-robin"; + } + friend bool operator==(token_view t1, token_view t2); friend bool operator<(token_view t1, token_view t2); friend int tri_compare(token_view t1, token_view t2); From bdce561ada2bc1deb11604152e1222dcebd47008 Mon Sep 17 00:00:00 2001 From: Glauber Costa Date: Sun, 3 Jun 2018 11:53:32 -0400 Subject: [PATCH 2/2] system_keyspace: add sharding information to local table We would like the clients to be able to route work directly to the right shards. To do that, they need to know the sharding algorithm and its parameters. The algorithm can be copied into the client, but the parameters need to be exported somewhere. Let's use the local table for that. Signed-off-by: Glauber Costa --- v2: force msb to zero on non-murmur --- db/system_keyspace.cc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/db/system_keyspace.cc b/db/system_keyspace.cc index 7009a95b8f..bd3ab92b4b 100644 --- a/db/system_keyspace.cc +++ b/db/system_keyspace.cc @@ -240,7 +240,9 @@ schema_ptr built_indexes() { {"broadcast_address", inet_addr_type}, {"listen_address", inet_addr_type}, {"supported_features", utf8_type}, - + {"scylla_cpu_sharding_algorithm", utf8_type }, + {"scylla_nr_shards", int32_type }, + {"scylla_msb_ignore", int32_type }, }, // static columns {}, @@ -986,10 +988,15 @@ schema_ptr aggregates() { static future<> setup_version() { return gms::inet_address::lookup(qctx->db().get_config().rpc_address()).then([](gms::inet_address a) { - sstring req = sprint("INSERT INTO system.%s (key, release_version, cql_version, thrift_version, native_protocol_version, data_center, rack, partitioner, rpc_address, broadcast_address, listen_address, supported_features) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" + sstring req = sprint("INSERT INTO system.%s (key, release_version, cql_version, thrift_version, native_protocol_version, data_center, rack, partitioner, rpc_address, broadcast_address, listen_address, supported_features, scylla_cpu_sharding_algorithm, scylla_nr_shards, scylla_msb_ignore) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" , db::system_keyspace::LOCAL); auto& snitch = locator::i_endpoint_snitch::get_local_snitch_ptr(); + int32_t scylla_msb_ignore = + dht::global_partitioner().name() == "org.apache.cassandra.dht.Murmur3Partitioner" + ? (qctx->db().get_config().murmur3_partitioner_ignore_msb_bits()) + : 0; + return execute_cql(req, sstring(db::system_keyspace::LOCAL), version::release(), cql3::query_processor::CQL_VERSION, @@ -1001,7 +1008,10 @@ static future<> setup_version() { a.addr(), utils::fb_utilities::get_broadcast_address().addr(), netw::get_local_messaging_service().listen_address().addr(), - service::storage_service::get_config_supported_features() + service::storage_service::get_config_supported_features(), + dht::global_partitioner().cpu_sharding_algorithm_name(), + int32_t(smp::count), + int32_t(scylla_msb_ignore) ).discard_result(); }); }