config: Enable broadcast_rpc_address option

With this patch, start two nodes

node 1:
scylla --rpc-address 127.0.0.1 --broadcast-rpc-address 127.0.0.11

node 2:
scylla --rpc-address 127.0.0.2 --broadcast-rpc-address 127.0.0.12

On node 1:
cqlsh> SELECT rpc_address from system.peers;

 rpc_address
-------------
  127.0.0.12

which means client should use this address to connect node 2 for cql and
thrift protocol.
This commit is contained in:
Asias He
2015-11-19 16:25:29 +08:00
parent 33ef58c5c9
commit 7ddf8963f5
10 changed files with 21 additions and 5 deletions

View File

@@ -560,7 +560,7 @@ public:
) \
/* RPC (remote procedure call) settings */ \
/* Settings for configuring and tuning client connections. */ \
val(broadcast_rpc_address, sstring, /* unset */, Unused, \
val(broadcast_rpc_address, sstring, /* unset */, Used, \
"RPC address to broadcast to drivers and other Cassandra nodes. This cannot be set to 0.0.0.0. If blank, it is set to the value of the rpc_address or rpc_interface. If rpc_address or rpc_interfaceis set to 0.0.0.0, this property must be set.\n" \
) \
val(rpc_port, uint16_t, 9160, Used, \

View File

@@ -61,8 +61,7 @@ future<> ec2_multi_region_snitch::start() {
// value to a public address in cassandra.yaml.
//
utils::fb_utilities::set_broadcast_address(local_public_address);
//DatabaseDescriptor.setBroadcastRpcAddress(local_public_address);
//
utils::fb_utilities::set_broadcast_rpc_address(local_public_address);
return aws_api_call(AWS_QUERY_SERVER_ADDR, PRIVATE_IP_QUERY_REQ).then(
[this] (sstring priv_addr) {

11
main.cc
View File

@@ -206,6 +206,7 @@ int main(int ac, char** av) {
sstring api_address = cfg->api_address() != "" ? cfg->api_address() : rpc_address;
auto seed_provider= cfg->seed_provider();
sstring broadcast_address = cfg->broadcast_address();
sstring broadcast_rpc_address = cfg->broadcast_rpc_address();
if (!broadcast_address.empty()) {
utils::fb_utilities::set_broadcast_address(broadcast_address);
@@ -216,6 +217,16 @@ int main(int ac, char** av) {
throw bad_configuration_error();
}
if (!broadcast_rpc_address.empty()) {
utils::fb_utilities::set_broadcast_rpc_address(broadcast_rpc_address);
} else {
if (rpc_address == "0.0.0.0") {
startlog.error("If rpc_address is set to a wildcard address {}, then you must set broadcast_rpc_address to a value other than {}", rpc_address, rpc_address);
throw bad_configuration_error();
}
utils::fb_utilities::set_broadcast_rpc_address(rpc_address);
}
using namespace locator;
return i_endpoint_snitch::create_snitch(cfg->endpoint_snitch()).then([] {
// #293 - do not stop anything

View File

@@ -202,8 +202,7 @@ future<> storage_service::prepare_to_join() {
return db::system_keyspace::get_local_host_id();
}).then([this, app_states] (auto local_host_id) mutable {
_token_metadata.update_host_id(local_host_id, this->get_broadcast_address());
// FIXME: DatabaseDescriptor.getBroadcastRpcAddress()
auto broadcast_rpc_address = this->get_broadcast_address();
auto broadcast_rpc_address = utils::fb_utilities::get_broadcast_rpc_address();
app_states->emplace(gms::application_state::NET_VERSION, value_factory.network_version());
app_states->emplace(gms::application_state::HOST_ID, value_factory.host_id(local_host_id));
app_states->emplace(gms::application_state::RPC_ADDRESS, value_factory.rpcaddress(broadcast_rpc_address));

View File

@@ -283,6 +283,7 @@ public:
}
return seastar::async([this] {
utils::fb_utilities::set_broadcast_address(gms::inet_address("localhost"));
utils::fb_utilities::set_broadcast_rpc_address(gms::inet_address("localhost"));
locator::i_endpoint_snitch::create_snitch("SimpleSnitch").get();
auto db = ::make_shared<distributed<database>>();
init_once(db).get();

View File

@@ -43,6 +43,7 @@ future<> one_test(const std::string& property_fname, bool exp_result) {
fname /= path(property_fname);
utils::fb_utilities::set_broadcast_address(gms::inet_address("localhost"));
utils::fb_utilities::set_broadcast_rpc_address(gms::inet_address("localhost"));
return i_endpoint_snitch::create_snitch<const sstring&>(
"EC2Snitch",

View File

@@ -65,6 +65,7 @@ int main(int ac, char ** av) {
logging::logger_registry().set_logger_level("gossip", logging::log_level::trace);
const gms::inet_address listen = gms::inet_address(config["listen-address"].as<std::string>());
utils::fb_utilities::set_broadcast_address(listen);
utils::fb_utilities::set_broadcast_rpc_address(listen);
auto vv = std::make_shared<gms::versioned_value::factory>();
locator::i_endpoint_snitch::create_snitch("SimpleSnitch").then([&db] {
return service::init_storage_service(db);

View File

@@ -43,6 +43,7 @@ future<> one_test(const std::string& property_fname, bool exp_result) {
fname /= path(property_fname);
utils::fb_utilities::set_broadcast_address(gms::inet_address("localhost"));
utils::fb_utilities::set_broadcast_rpc_address(gms::inet_address("localhost"));
return i_endpoint_snitch::create_snitch<const sstring&>(
"org.apache.cassandra.locator.GossipingPropertyFileSnitch",

View File

@@ -157,6 +157,7 @@ void full_ring_check(const std::vector<ring_point>& ring_points,
future<> simple_test() {
utils::fb_utilities::set_broadcast_address(gms::inet_address("localhost"));
utils::fb_utilities::set_broadcast_rpc_address(gms::inet_address("localhost"));
// Create the RackInferringSnitch
return i_endpoint_snitch::create_snitch("RackInferringSnitch").then(
@@ -230,6 +231,7 @@ future<> simple_test() {
future<> heavy_origin_test() {
utils::fb_utilities::set_broadcast_address(gms::inet_address("localhost"));
utils::fb_utilities::set_broadcast_rpc_address(gms::inet_address("localhost"));
// Create the RackInferringSnitch
return i_endpoint_snitch::create_snitch("RackInferringSnitch").then(

View File

@@ -38,6 +38,7 @@ future<> one_test(const std::string& property_fname1,
using namespace boost::filesystem;
utils::fb_utilities::set_broadcast_address(gms::inet_address("localhost"));
utils::fb_utilities::set_broadcast_rpc_address(gms::inet_address("localhost"));
printf("Testing %s and %s property files. Expected result is %s\n",
property_fname1.c_str(), property_fname2.c_str(),