snitch: add optional get_broadcast_address method
and set broadcast_address / broadcast_rpc_address in main to remove this dependency of snitch on fb_utilities. Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
This commit is contained in:
@@ -20,7 +20,7 @@ static constexpr const char* PRIVATE_MAC_QUERY = "/latest/meta-data/network/inte
|
||||
namespace locator {
|
||||
ec2_multi_region_snitch::ec2_multi_region_snitch(const snitch_config& cfg)
|
||||
: ec2_snitch(cfg)
|
||||
, _broadcast_rpc_address_specified_by_user(cfg.broadcast_rpc_address_specified_by_user) {}
|
||||
{}
|
||||
|
||||
future<> ec2_multi_region_snitch::start() {
|
||||
_state = snitch_state::initializing;
|
||||
@@ -53,17 +53,6 @@ future<> ec2_multi_region_snitch::start() {
|
||||
}
|
||||
logger().info("Ec2MultiRegionSnitch using publicIP as identifier: {}", _local_public_address);
|
||||
|
||||
//
|
||||
// Use the Public IP to broadcast Address to other nodes.
|
||||
//
|
||||
// Cassandra 2.1 manual explicitly instructs to set broadcast_address
|
||||
// value to a public address in cassandra.yaml.
|
||||
//
|
||||
utils::fb_utilities::set_broadcast_address(_local_public_address);
|
||||
if (!_broadcast_rpc_address_specified_by_user) {
|
||||
utils::fb_utilities::set_broadcast_rpc_address(_local_public_address);
|
||||
}
|
||||
|
||||
if (!_local_public_address.addr().is_ipv6()) {
|
||||
sstring priv_addr = co_await aws_api_call(AWS_QUERY_SERVER_ADDR, AWS_QUERY_SERVER_PORT, PRIVATE_IP_QUERY_REQ, token);
|
||||
_local_private_address = priv_addr;
|
||||
|
||||
@@ -22,6 +22,9 @@ public:
|
||||
virtual sstring get_name() const override {
|
||||
return "org.apache.cassandra.locator.Ec2MultiRegionSnitch";
|
||||
}
|
||||
virtual std::optional<inet_address> get_public_address() const noexcept override {
|
||||
return _local_public_address;
|
||||
}
|
||||
private:
|
||||
inet_address _local_public_address;
|
||||
sstring _local_private_address;
|
||||
|
||||
@@ -46,7 +46,6 @@ struct snitch_config {
|
||||
sstring name = "SimpleSnitch";
|
||||
sstring properties_file_name = "";
|
||||
unsigned io_cpu_id = 0;
|
||||
bool broadcast_rpc_address_specified_by_user = false;
|
||||
|
||||
// Gossiping-property-file specific
|
||||
gms::inet_address listen_address;
|
||||
@@ -78,6 +77,8 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
virtual std::optional<inet_address> get_public_address() const noexcept { return std::nullopt; }
|
||||
|
||||
/**
|
||||
* returns whatever info snitch wants to gossip
|
||||
*/
|
||||
|
||||
16
main.cc
16
main.cc
@@ -873,7 +873,6 @@ To start the scylla server proper, simply invoke as: scylla server (or just scyl
|
||||
debug::the_snitch = &snitch;
|
||||
snitch_config snitch_cfg;
|
||||
snitch_cfg.name = cfg->endpoint_snitch();
|
||||
snitch_cfg.broadcast_rpc_address_specified_by_user = !cfg->broadcast_rpc_address().empty();
|
||||
snitch_cfg.listen_address = utils::resolve(cfg->listen_address, family).get0();
|
||||
snitch.start(snitch_cfg).get();
|
||||
auto stop_snitch = defer_verbose_shutdown("snitch", [&snitch] {
|
||||
@@ -883,6 +882,21 @@ To start the scylla server proper, simply invoke as: scylla server (or just scyl
|
||||
// #293 - do not stop anything (unless snitch.on_all(start) fails)
|
||||
stop_snitch->cancel();
|
||||
|
||||
if (auto opt_public_address = snitch.local()->get_public_address()) {
|
||||
// Use the Public IP as broadcast_address to other nodes
|
||||
// and the broadcast_rpc_address (for client CQL connections).
|
||||
//
|
||||
// Cassandra 2.1 manual explicitly instructs to set broadcast_address
|
||||
// value to a public address in cassandra.yaml.
|
||||
//
|
||||
broadcast_addr = *opt_public_address;
|
||||
utils::fb_utilities::set_broadcast_address(*opt_public_address);
|
||||
if (cfg->broadcast_rpc_address().empty()) {
|
||||
broadcast_rpc_addr = *opt_public_address;
|
||||
utils::fb_utilities::set_broadcast_rpc_address(*opt_public_address);
|
||||
}
|
||||
}
|
||||
|
||||
supervisor::notify("starting tokens manager");
|
||||
locator::token_metadata::config tm_cfg;
|
||||
tm_cfg.topo_cfg.this_endpoint = utils::fb_utilities::get_broadcast_address();
|
||||
|
||||
Reference in New Issue
Block a user