diff --git a/alternator/executor.cc b/alternator/executor.cc index 1b83595a24..7645b6a017 100644 --- a/alternator/executor.cc +++ b/alternator/executor.cc @@ -4469,7 +4469,7 @@ future executor::describe_continuous_backups(clie // manually create the keyspace to override this predefined behavior. static future> create_keyspace(std::string_view keyspace_name, service::storage_proxy& sp, gms::gossiper& gossiper, api::timestamp_type ts) { sstring keyspace_name_str(keyspace_name); - int endpoint_count = gossiper.get_endpoint_states().size(); + int endpoint_count = gossiper.num_endpoints(); int rf = 3; if (endpoint_count < rf) { rf = 1; diff --git a/gms/gossiper.hh b/gms/gossiper.hh index de2e0e21e3..319be5422a 100644 --- a/gms/gossiper.hh +++ b/gms/gossiper.hh @@ -428,6 +428,10 @@ public: std::vector get_endpoints() const; + size_t num_endpoints() const noexcept { + return _endpoint_state_map.size(); + } + bool uses_host_id(inet_address endpoint) const; locator::host_id get_host_id(inet_address endpoint) const; diff --git a/service/migration_manager.cc b/service/migration_manager.cc index 0e43e74b65..2c270a3cd4 100644 --- a/service/migration_manager.cc +++ b/service/migration_manager.cc @@ -222,11 +222,11 @@ void migration_manager::schedule_schema_pull(const gms::inet_address& endpoint, } bool migration_manager::have_schema_agreement() { - const auto known_endpoints = _gossiper.get_endpoint_states(); - if (known_endpoints.size() == 1) { + if (_gossiper.num_endpoints() == 1) { // Us. return true; } + const auto known_endpoints = _gossiper.get_endpoint_states(); auto our_version = _storage_proxy.get_db().local().get_version(); bool match = false; for (auto& x : known_endpoints) {