diff --git a/db/system_keyspace.cc b/db/system_keyspace.cc index af2c1aba85..e4082909bd 100644 --- a/db/system_keyspace.cc +++ b/db/system_keyspace.cc @@ -1035,6 +1035,24 @@ utils::UUID set_local_host_id(const utils::UUID& host_id) { // executeInternal(String.format(req, LOCAL, LOCAL), hostId); return host_id; } - +std::unordered_map +load_dc_rack_info() +{ + std::unordered_map result; +#if 0 //TODO + for (UntypedResultSet.Row row : executeInternal("SELECT peer, data_center, rack from system." + PEERS)) + { + InetAddress peer = row.getInetAddress("peer"); + if (row.has("data_center") && row.has("rack")) + { + Map dcRack = new HashMap<>(); + dcRack.put("data_center", row.getString("data_center")); + dcRack.put("rack", row.getString("rack")); + result.put(peer, dcRack); + } + } +#endif + return result; +} } // namespace system_keyspace } // namespace db diff --git a/db/system_keyspace.hh b/db/system_keyspace.hh index 753742a144..ee768d1c24 100644 --- a/db/system_keyspace.hh +++ b/db/system_keyspace.hh @@ -23,9 +23,12 @@ #pragma once +#include +#include #include "schema.hh" #include "legacy_schema_tables.hh" #include "utils/UUID.hh" +#include "gms/inet_address.hh" namespace db { namespace system_keyspace { @@ -51,6 +54,16 @@ extern schema_ptr built_indexes(); // TODO (from Cassandra): make private std::vector all_tables(); void make(database& db); +// Endpoint Data Center and Rack names +struct endpoint_dc_rack { + sstring dc; + sstring rack; +}; +/** + * Return a map of IP addresses containing a map of dc and rack info + */ +std::unordered_map load_dc_rack_info(); + #if 0 private static volatile Map> truncationRecords; diff --git a/locator/token_metadata.hh b/locator/token_metadata.hh index 96e36b747c..92c6522bd0 100644 --- a/locator/token_metadata.hh +++ b/locator/token_metadata.hh @@ -1072,6 +1072,11 @@ public: } } #endif + void invalidate_cached_rings() { + // TODO: + //ringVersion++; + //cachedTokenMap.set(null); + } }; } diff --git a/service/storage_service.hh b/service/storage_service.hh index cda7118212..8f4219c004 100644 --- a/service/storage_service.hh +++ b/service/storage_service.hh @@ -68,6 +68,15 @@ public: const locator::token_metadata& get_token_metadata() const { return _token_metadata; } + + locator::token_metadata& get_token_metadata() { + return _token_metadata; + } + + void gossip_snitch_info() { + // TODO + } + private: inet_address get_broadcast_address() { auto& gossiper = gms::get_local_gossiper(); diff --git a/utils/fb_utilities.hh b/utils/fb_utilities.hh index 6432dfd6d0..f4ed6c300c 100644 --- a/utils/fb_utilities.hh +++ b/utils/fb_utilities.hh @@ -24,12 +24,39 @@ #pragma once #include +#include +#include "gms/inet_address.hh" +#include "message/messaging_service.hh" namespace utils { + +using inet_address = gms::inet_address; + // FIXME: stub class fb_utilities { public: static const int32_t MAX_UNSIGNED_SHORT = 0xFFFF; + + static const inet_address get_broadcast_address() { + static std::experimental::optional broadcast_inet_address; +#if 0 + if (_broadcast_inet_address == nullptr) + _broadcast_inet_address = DatabaseDescriptor.getBroadcastAddress() == nullptr + ? getLocalAddress() + : DatabaseDescriptor.getBroadcastAddress(); +#else + // TODO: Remove this when database_descriptor is implemented + if (!broadcast_inet_address) { + if (net::get_messaging_service().local_is_initialized()) { + broadcast_inet_address = + net::get_local_messaging_service().listen_address(); + } else { + return inet_address("127.0.0.1"); + } + } +#endif + return broadcast_inet_address.value(); + } }; }