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:
@@ -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<db::view::view_builder>& vb, sharded<service::storage_service>& ss) {
|
||||
ss::view_build_statuses.set(r, [&ctx, &ss] (std::unique_ptr<request> req) {
|
||||
ss::view_build_statuses.set(r, [&ctx, &vb] (std::unique_ptr<request> 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<sstring, sstring> status) {
|
||||
return vb.local().view_build_statuses(std::move(keyspace), std::move(view)).then([] (std::unordered_map<sstring, sstring> status) {
|
||||
std::vector<storage_service_json::mapper> res;
|
||||
return make_ready_future<json::json_return_type>(map_to_key_value(std::move(status), res));
|
||||
});
|
||||
|
||||
@@ -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});
|
||||
|
||||
@@ -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&);
|
||||
|
||||
@@ -790,8 +790,6 @@ public:
|
||||
|
||||
future<std::map<gms::inet_address, float>> effective_ownership(sstring keyspace_name);
|
||||
|
||||
future<std::unordered_map<sstring, sstring>> view_build_statuses(sstring keyspace, sstring view_name) const;
|
||||
|
||||
private:
|
||||
promise<> _drain_finished;
|
||||
std::optional<shared_promise<>> _transport_stopped;
|
||||
|
||||
Reference in New Issue
Block a user