From 3b6e8c7d930a3389234a2c348df1ed0251e58faf Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Thu, 23 Sep 2021 12:15:33 +0300 Subject: [PATCH] storage_service: Move view_build_statuses code This code belongs to view builder, so put it into its .cc. No changes, just move. This needs some ugly namespace breakage, but they will be patched away with the next patch. Signed-off-by: Pavel Emelyanov --- db/view/view.cc | 22 ++++++++++++++++++++++ service/storage_service.cc | 13 ------------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/db/view/view.cc b/db/view/view.cc index 6426212ae2..85354f84b5 100644 --- a/db/view/view.cc +++ b/db/view/view.cc @@ -85,6 +85,8 @@ #include "utils/fb_utilities.hh" #include "query-result-writer.hh" +#include "service/storage_service.hh" // temporary + using namespace std::chrono_literals; static logging::logger vlogger("view"); @@ -1725,6 +1727,26 @@ future<> view_builder::calculate_shard_build_step(view_builder_init_state& vbi) }); } +}} // temporary break db::view +namespace service { + +future> +storage_service::view_build_statuses(sstring keyspace, sstring view_name) const { + return _sys_dist_ks.local().view_status(std::move(keyspace), std::move(view_name)).then([this] (std::unordered_map status) { + auto& endpoint_to_host_id = get_token_metadata().get_endpoint_to_host_id_map_for_reading(); + return boost::copy_range>(endpoint_to_host_id + | boost::adaptors::transformed([&status] (const std::pair& p) { + auto it = status.find(p.second); + auto s = it != status.end() ? std::move(it->second) : "UNKNOWN"; + return std::pair(p.first.to_sstring(), std::move(s)); + })); + }); +} + +} +namespace db { +namespace view { // temporary break + future<> view_builder::add_new_view(view_ptr view, build_step& step) { vlogger.info0("Building view {}.{}, starting at token {}", view->ks_name(), view->cf_name(), step.current_token()); step.build_status.emplace(step.build_status.begin(), view_build_status{view, step.current_token(), std::nullopt}); diff --git a/service/storage_service.cc b/service/storage_service.cc index 3c7ed067b3..3128d6a473 100644 --- a/service/storage_service.cc +++ b/service/storage_service.cc @@ -3452,19 +3452,6 @@ storage_service::get_natural_endpoints(const sstring& keyspace, const token& pos return _db.local().find_keyspace(keyspace).get_replication_strategy().get_natural_endpoints(pos); } -future> -storage_service::view_build_statuses(sstring keyspace, sstring view_name) const { - return _sys_dist_ks.local().view_status(std::move(keyspace), std::move(view_name)).then([this] (std::unordered_map status) { - auto& endpoint_to_host_id = get_token_metadata().get_endpoint_to_host_id_map_for_reading(); - return boost::copy_range>(endpoint_to_host_id - | boost::adaptors::transformed([&status] (const std::pair& p) { - auto it = status.find(p.second); - auto s = it != status.end() ? std::move(it->second) : "UNKNOWN"; - return std::pair(p.first.to_sstring(), std::move(s)); - })); - }); -} - future<> endpoint_lifecycle_notifier::notify_down(gms::inet_address endpoint) { return seastar::async([this, endpoint] { _subscribers.for_each([endpoint] (endpoint_lifecycle_subscriber* subscriber) {