diff --git a/api/storage_service.cc b/api/storage_service.cc index 90542fa088..740380e2a6 100644 --- a/api/storage_service.cc +++ b/api/storage_service.cc @@ -56,6 +56,7 @@ #include "service/storage_proxy.hh" #include "locator/abstract_replication_strategy.hh" #include "sstables_loader.hh" +#include "db/view/view_builder.hh" extern logging::logger apilog; @@ -329,10 +330,10 @@ void unset_sstables_loader(http_context& ctx, routes& r) { } void set_view_builder(http_context& ctx, routes& r, sharded& vb, sharded& ss) { - ss::view_build_statuses.set(r, [&ctx, &ss] (std::unique_ptr req) { + ss::view_build_statuses.set(r, [&ctx, &vb] (std::unique_ptr req) { auto keyspace = validate_keyspace(ctx, req->param); auto view = req->param["view"]; - return ss.local().view_build_statuses(std::move(keyspace), std::move(view)).then([] (std::unordered_map status) { + return vb.local().view_build_statuses(std::move(keyspace), std::move(view)).then([] (std::unordered_map status) { std::vector res; return make_ready_future(map_to_key_value(std::move(status), res)); }); diff --git a/db/view/view.cc b/db/view/view.cc index 85354f84b5..88a7407e5b 100644 --- a/db/view/view.cc +++ b/db/view/view.cc @@ -85,8 +85,6 @@ #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"); @@ -1727,15 +1725,12 @@ 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(); +view_builder::view_build_statuses(sstring keyspace, sstring view_name) const { + return _sys_dist_ks.view_status(std::move(keyspace), std::move(view_name)).then([this] (std::unordered_map status) { + auto& endpoint_to_host_id = service::get_local_storage_proxy().get_token_metadata_ptr()->get_endpoint_to_host_id_map_for_reading(); return boost::copy_range>(endpoint_to_host_id - | boost::adaptors::transformed([&status] (const std::pair& p) { + | 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)); @@ -1743,10 +1738,6 @@ storage_service::view_build_statuses(sstring keyspace, sstring view_name) const }); } -} -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/db/view/view_builder.hh b/db/view/view_builder.hh index 082e9c8a18..b942ba2c9c 100644 --- a/db/view/view_builder.hh +++ b/db/view/view_builder.hh @@ -222,6 +222,8 @@ public: // For tests future<> wait_until_built(const sstring& ks_name, const sstring& view_name); + future> view_build_statuses(sstring keyspace, sstring view_name) const; + private: build_step& get_or_create_build_step(utils::UUID); future<> initialize_reader_at_current_token(build_step&); diff --git a/service/storage_service.hh b/service/storage_service.hh index 59c3dc6ea7..145ab5ef3e 100644 --- a/service/storage_service.hh +++ b/service/storage_service.hh @@ -790,8 +790,6 @@ public: future> effective_ownership(sstring keyspace_name); - future> view_build_statuses(sstring keyspace, sstring view_name) const; - private: promise<> _drain_finished; std::optional> _transport_stopped;