transport: advertise the shard serving a connection

It is useful for the client driver to know which shard is serving a
particular connection, so it can only send requests through that connection
which will be served by the same shard, eliminating a hop.

Support that by advertising a "SCYLLA_SHARD" option, with a value
corresponding to the shard number.

Acked-by: Glauber Costa <glauber@scylladb.com>
Message-Id: <20180606203437.1198-1-avi@scylladb.com>
This commit is contained in:
Avi Kivity
2018-06-06 23:34:37 +03:00
committed by Pekka Enberg
parent 4a90eeb326
commit f9d66f88bb

View File

@@ -1195,6 +1195,7 @@ shared_ptr<cql_server::response> cql_server::connection::make_supported(int16_t
opts.insert({"CQL_VERSION", cql3::query_processor::CQL_VERSION});
opts.insert({"COMPRESSION", "lz4"});
opts.insert({"COMPRESSION", "snappy"});
opts.insert({"SCYLLA_SHARD", sprint("%d", engine().cpu_id())});
auto response = make_shared<cql_server::response>(stream, cql_binary_opcode::SUPPORTED, tr_state);
response->write_string_multimap(opts);
return response;