view_builder: Accept view_build_statuses

The code itself is already in relevant .cc file, not move it to the
relevant class.

The only significant change is where to get token metadata from.
In its old location tokens were provided by the storage service
itself, now when it's in the view builder there's no "native" place
to get them from, however the rest of the view building code gets
tokens from global storage proxy, so do the same here.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
This commit is contained in:
Pavel Emelyanov
2021-09-23 12:21:46 +03:00
parent 3b6e8c7d93
commit c504361c15
4 changed files with 9 additions and 17 deletions

View File

@@ -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<std::unordered_map<sstring, sstring>>
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<utils::UUID, sstring> 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<utils::UUID, sstring> 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<std::unordered_map<sstring, sstring>>(endpoint_to_host_id
| boost::adaptors::transformed([&status] (const std::pair<inet_address, utils::UUID>& p) {
| boost::adaptors::transformed([&status] (const std::pair<gms::inet_address, utils::UUID>& 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});

View File

@@ -222,6 +222,8 @@ public:
// For tests
future<> wait_until_built(const sstring& ks_name, const sstring& view_name);
future<std::unordered_map<sstring, sstring>> 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&);