api/storage_service.cc: use utils::directories to get paths of dirs

This change replaces usage of db::config with usage
of utils::directories in api/storage_service.cc in
order to get the paths of directories.

Refs: scylladb#5626
Signed-off-by: Patryk Wrobel <patryk.wrobel@scylladb.com>
This commit is contained in:
Patryk Wrobel
2024-01-19 08:56:14 +01:00
parent 51fa108df7
commit 5ac3d0f135
5 changed files with 30 additions and 11 deletions

View File

@@ -104,9 +104,12 @@ future<> unset_rpc_controller(http_context& ctx) {
return ctx.http_server.set_routes([&ctx] (routes& r) { unset_rpc_controller(ctx, r); });
}
future<> set_server_storage_service(http_context& ctx, sharded<service::storage_service>& ss, service::raft_group0_client& group0_client) {
return register_api(ctx, "storage_service", "The storage service API", [&ss, &group0_client] (http_context& ctx, routes& r) {
set_storage_service(ctx, r, ss, group0_client);
future<> set_server_storage_service(http_context& ctx,
const utils::directories& dirs,
sharded<service::storage_service>& ss,
service::raft_group0_client& group0_client) {
return register_api(ctx, "storage_service", "The storage service API", [&dirs, &ss, &group0_client] (http_context& ctx, routes& r) {
set_storage_service(ctx, r, ss, group0_client, dirs);
});
}

View File

@@ -69,6 +69,8 @@ namespace tasks {
class task_manager;
}
namespace utils { class directories; }
namespace api {
struct http_context {
@@ -89,7 +91,10 @@ future<> set_server_init(http_context& ctx);
future<> set_server_config(http_context& ctx, const db::config& cfg);
future<> set_server_snitch(http_context& ctx, sharded<locator::snitch_ptr>& snitch);
future<> unset_server_snitch(http_context& ctx);
future<> set_server_storage_service(http_context& ctx, sharded<service::storage_service>& ss, service::raft_group0_client&);
future<> set_server_storage_service(http_context& ctx,
const utils::directories& dirs,
sharded<service::storage_service>& ss,
service::raft_group0_client&);
future<> unset_server_storage_service(http_context& ctx);
future<> set_server_sstables_loader(http_context& ctx, sharded<sstables_loader>& sst_loader);
future<> unset_server_sstables_loader(http_context& ctx);

View File

@@ -14,6 +14,7 @@
#include "api/scrub_status.hh"
#include "db/config.hh"
#include "db/schema_tables.hh"
#include "utils/directories.hh"
#include "utils/hash.hh"
#include <optional>
#include <sstream>
@@ -547,7 +548,11 @@ static future<json::json_return_type> describe_ring_as_json(sharded<service::sto
co_return json::json_return_type(stream_range_as_array(co_await ss.local().describe_ring(keyspace), token_range_endpoints_to_json));
}
void set_storage_service(http_context& ctx, routes& r, sharded<service::storage_service>& ss, service::raft_group0_client& group0_client) {
void set_storage_service(http_context& ctx,
routes& r,
sharded<service::storage_service>& ss,
service::raft_group0_client& group0_client,
const utils::directories& dirs) {
ss::get_commitlog.set(r, [&ctx](const_req req) {
return ctx.db.local().commitlog()->active_config().commit_log_location;
});
@@ -622,12 +627,12 @@ void set_storage_service(http_context& ctx, routes& r, sharded<service::storage_
return ss.local().get_schema_version();
});
ss::get_all_data_file_locations.set(r, [&ctx](const_req req) {
return container_to_vec(ctx.db.local().get_config().data_file_directories());
ss::get_all_data_file_locations.set(r, [data_file_dirs = dirs.get_data_file_dirs()](const_req req) {
return container_to_vec(data_file_dirs);
});
ss::get_saved_caches_location.set(r, [&ctx](const_req req) {
return ctx.db.local().get_config().saved_caches_directory();
ss::get_saved_caches_location.set(r, [saved_caches_dir = dirs.get_saved_caches_dir()](const_req req) {
return saved_caches_dir;
});
ss::get_range_to_endpoint_map.set(r, [&ctx, &ss](std::unique_ptr<http::request> req) -> future<json::json_return_type> {

View File

@@ -14,6 +14,8 @@
#include "db/data_listeners.hh"
namespace cql_transport { class controller; }
namespace utils { class directories; }
class thrift_controller;
namespace db {
class snapshot_ctl;
@@ -66,7 +68,11 @@ struct scrub_info {
future<scrub_info> parse_scrub_options(http_context& ctx, sharded<db::snapshot_ctl>& snap_ctl, std::unique_ptr<http::request> req);
void set_storage_service(http_context& ctx, httpd::routes& r, sharded<service::storage_service>& ss, service::raft_group0_client&);
void set_storage_service(http_context& ctx,
httpd::routes& r,
sharded<service::storage_service>& ss,
service::raft_group0_client&,
const utils::directories& dirs);
void unset_storage_service(http_context& ctx, httpd::routes& r);
void set_sstables_loader(http_context& ctx, httpd::routes& r, sharded<sstables_loader>& sst_loader);
void unset_sstables_loader(http_context& ctx, httpd::routes& r);

View File

@@ -1426,7 +1426,7 @@ To start the scylla server proper, simply invoke as: scylla server (or just scyl
ss.stop().get();
});
api::set_server_storage_service(ctx, ss, group0_client).get();
api::set_server_storage_service(ctx, *dirs, ss, group0_client).get();
auto stop_ss_api = defer_verbose_shutdown("storage service API", [&ctx] {
api::unset_server_storage_service(ctx).get();
});