diff --git a/api/api.cc b/api/api.cc index 5f5c677d36d2..7618937fb752 100644 --- a/api/api.cc +++ b/api/api.cc @@ -135,6 +135,14 @@ future<> unset_load_meter(http_context& ctx) { return ctx.http_server.set_routes([&ctx] (routes& r) { unset_load_meter(ctx, r); }); } +future<> set_format_selector(http_context& ctx, db::sstables_format_selector& sel) { + return ctx.http_server.set_routes([&ctx, &sel] (routes& r) { set_format_selector(ctx, r, sel); }); +} + +future<> unset_format_selector(http_context& ctx) { + return ctx.http_server.set_routes([&ctx] (routes& r) { unset_format_selector(ctx, r); }); +} + future<> set_server_sstables_loader(http_context& ctx, sharded& sst_loader) { return ctx.http_server.set_routes([&ctx, &sst_loader] (routes& r) { set_sstables_loader(ctx, r, sst_loader); }); } diff --git a/api/api_init.hh b/api/api_init.hh index e2a09f40c2b5..836fdb7e16ef 100644 --- a/api/api_init.hh +++ b/api/api_init.hh @@ -51,6 +51,7 @@ namespace cql_transport { class controller; } namespace db { class snapshot_ctl; class config; +class sstables_format_selector; namespace view { class view_builder; } @@ -135,6 +136,8 @@ future<> set_server_raft(http_context&, sharded&); future<> unset_server_raft(http_context&); future<> set_load_meter(http_context& ctx, service::load_meter& lm); future<> unset_load_meter(http_context& ctx); +future<> set_format_selector(http_context& ctx, db::sstables_format_selector& sel); +future<> unset_format_selector(http_context& ctx); future<> set_server_cql_server_test(http_context& ctx, cql_transport::controller& ctl); future<> unset_server_cql_server_test(http_context& ctx); future<> set_server_commitlog(http_context& ctx, sharded&); diff --git a/api/system.cc b/api/system.cc index 1eda3c2a20d3..66d004f3aad3 100644 --- a/api/system.cc +++ b/api/system.cc @@ -10,7 +10,7 @@ #include "api/api-doc/system.json.hh" #include "api/api-doc/metrics.json.hh" #include "replica/database.hh" -#include "sstables/sstables_manager.hh" +#include "db/sstables-format-selector.hh" #include #include @@ -183,11 +183,18 @@ void set_system(http_context& ctx, routes& r) { apilog.info("Profile dumped to {}", profile_dest); return make_ready_future(json::json_return_type(json::json_void())); }) ; +} - hs::get_highest_supported_sstable_version.set(r, [&ctx] (const_req req) { - auto& table = ctx.db.local().find_column_family("system", "local"); - return seastar::to_sstring(table.get_sstables_manager().get_highest_supported_format()); +void set_format_selector(http_context& ctx, routes& r, db::sstables_format_selector& sel) { + hs::get_highest_supported_sstable_version.set(r, [&sel] (std::unique_ptr req) { + return smp::submit_to(0, [&sel] { + return make_ready_future(seastar::to_sstring(sel.selected_format())); + }); }); } +void unset_format_selector(http_context& ctx, routes& r) { + hs::get_highest_supported_sstable_version.unset(r); +} + } diff --git a/api/system.hh b/api/system.hh index 9ecff3681c47..d7dd8ea0e4e8 100644 --- a/api/system.hh +++ b/api/system.hh @@ -12,9 +12,14 @@ namespace seastar::httpd { class routes; } +namespace db { class sstables_format_selector; } + namespace api { struct http_context; void set_system(http_context& ctx, seastar::httpd::routes& r); +void set_format_selector(http_context& ctx, seastar::httpd::routes& r, db::sstables_format_selector& sel); +void unset_format_selector(http_context& ctx, seastar::httpd::routes& r); + } diff --git a/main.cc b/main.cc index 3667c0189ad2..b6f4fdf35119 100644 --- a/main.cc +++ b/main.cc @@ -1268,6 +1268,11 @@ To start the scylla server proper, simply invoke as: scylla server (or just scyl db::sstables_format_selector sst_format_selector(db); + api::set_format_selector(ctx, sst_format_selector).get(); + auto stop_format_seletor_api = defer_verbose_shutdown("sstables format selector API", [&ctx] { + api::unset_format_selector(ctx).get(); + }); + supervisor::notify("starting system keyspace"); sys_ks.start(std::ref(qp), std::ref(db)).get(); // TODO: stop()?