They are in fact such, but wasn't marked as const before because they wanted to talk to non-const gossiper and system_keyspaces methods and updated snitch internal caches Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
51 lines
1.3 KiB
C++
51 lines
1.3 KiB
C++
/*
|
|
*
|
|
* Modified by ScyllaDB
|
|
* Copyright (C) 2015-present ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: (AGPL-3.0-or-later and Apache-2.0)
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <seastar/core/sstring.hh>
|
|
#include "gms/inet_address.hh"
|
|
#include "snitch_base.hh"
|
|
#include "utils/fb_utilities.hh"
|
|
|
|
namespace locator {
|
|
|
|
using inet_address = gms::inet_address;
|
|
|
|
/**
|
|
* A simple endpoint snitch implementation that assumes datacenter and rack information is encoded
|
|
* in the 2nd and 3rd octets of the ip address, respectively.
|
|
*/
|
|
struct rack_inferring_snitch : public snitch_base {
|
|
rack_inferring_snitch(const snitch_config& cfg) {
|
|
_my_dc = get_datacenter();
|
|
_my_rack = get_rack();
|
|
|
|
// This snitch is ready on creation
|
|
set_snitch_ready();
|
|
}
|
|
|
|
virtual sstring get_rack() const override {
|
|
auto endpoint = utils::fb_utilities::get_broadcast_address();
|
|
return std::to_string(uint8_t(endpoint.bytes()[2]));
|
|
}
|
|
|
|
virtual sstring get_datacenter() const override {
|
|
auto endpoint = utils::fb_utilities::get_broadcast_address();
|
|
return std::to_string(uint8_t(endpoint.bytes()[1]));
|
|
}
|
|
|
|
virtual sstring get_name() const override {
|
|
return "org.apache.cassandra.locator.RackInferringSnitch";
|
|
}
|
|
};
|
|
|
|
} // namespace locator
|