Files
scylla/locator/ec2_snitch.hh
Pavel Emelyanov 0abd2c1e52 snitch: Export prefer-local
The boolean bit says whether "the system" should prefer connecting to
the address gossiper around via INTERNAL_IP. Currently only gossiping
property file snitch allows to tune it and ec2-multiregion snitch
prefers internal IP unconditionally.

So exporting consists of 2 pieces:

- add prefer_local() snitch method that's false by default or returns
  the (existing) _prefer_local bit for production snitch base
- set the _prefer_local to true by ec2-multiregion snitch

While at it the _prefer_local is moved to production_snitch_base for
uniformity with the new prefer_local() call

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2022-07-26 13:48:04 +03:00

37 lines
1.1 KiB
C++

/*
* SPDX-License-Identifier: Apache-2.0
*
* Modified by ScyllaDB
* Copyright (C) 2015-present ScyllaDB
*/
#pragma once
#include "locator/production_snitch_base.hh"
#include <seastar/http/response_parser.hh>
#include <seastar/net/api.hh>
namespace locator {
class ec2_snitch : public production_snitch_base {
public:
static constexpr const char* ZONE_NAME_QUERY_REQ = "/latest/meta-data/placement/availability-zone";
static constexpr const char* AWS_QUERY_SERVER_ADDR = "169.254.169.254";
static constexpr uint16_t AWS_QUERY_SERVER_PORT = 80;
ec2_snitch(const snitch_config&);
virtual future<> start() override;
virtual sstring get_name() const override {
return "org.apache.cassandra.locator.Ec2Snitch";
}
protected:
future<> load_config(bool prefer_local);
future<sstring> aws_api_call(sstring addr, uint16_t port, const sstring cmd);
future<sstring> read_property_file();
private:
connected_socket _sd;
input_stream<char> _in;
output_stream<char> _out;
http_response_parser _parser;
sstring _zone_req;
};
} // namespace locator