Merge "augment system.local with sharding information" from Glauber

"
This patch adds nr_shards, msb_ignore, and the actual sharding algorithm to the
system.local table. Drivers and other tools can then make use of this
information to talk to scylla in an optimal way
"

* 'system_tables-v3' of github.com:glommer/scylla:
  system_keyspace: add sharding information to local table
  partitioner: export the name of the algorithm used to do intra-node sharding
This commit is contained in:
Avi Kivity
2018-06-04 18:50:28 +03:00
2 changed files with 17 additions and 3 deletions

View File

@@ -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();
});
}

View File

@@ -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);