mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-25 19:10:42 +00:00
In column_family.cc and storage_service.cc there exist a bunch of helpers that parse and/or validate ks/cf names, and different endpoints use different combinations of those, duplicating the functionality of each other and generating some mess. This PR cleans the endpoints from column_family.cc that parse and validate fully qualified table name (the '$ks:$cf' string).
A visible "improvement" is that `validate_table()` helper usage in the api/ directory is narrowed down to storage_service.cc file only (with the intent to remove that helper completely), and the aforementioned `for_tables_on_all_shards()` helper becomes shorter and tiny bit faster, because it doesn't perform some re-lookups of tables, that had been performed by validation sanity checks before it.
There's more to be done in those helpers, this PR wraps only one part of this mess.
Below is the list of endpoints this PR affects and the tests that validate the changes:
|endpoint|test|
|-|-|
|column_family/autocompaction|rest_api/test_column_family::test_column_family_auto_compaction_table|
|column_family/tombstone_gc|rest_api/test_column_family::test_column_family_tombstone_gc_api|
|column_family/compaction_strategy|rest_api/test_column_family/test_column_family_compaction_strategy|
|compaction_manager/stop_keyspace_compaction/|rest_api/test_compaction_manager::{test_compaction_manager_stop_keyspace_compaction,test_compaction_manager_stop_keyspace_compaction_tables}|
Closes scylladb/scylladb#21533
* github.com:scylladb/scylladb:
api: Hide parse_tables() helper
api: Use parse_table_infos() in stop_keyspace_compaction handler
api: Re-use parse_table_info() in column_family API
api: Make get_uuid() return table_info (and rename)
api: Remove keyspace argument from for_table_on_all_shards()
api: Switch for_table_on_all_shards() to use table_info-s
api: Hide validate_table() helper
api: Tables vector is never empty now in for_table_on_all_shards()
api: Move vectors of tables, not copy
api: Add table validation to set_compaction_strategy_class endpoint
api: Use get_uuid() to validate_table() in column family API
api: Use parse_table_infos() in column family API
82 lines
3.5 KiB
C++
82 lines
3.5 KiB
C++
/*
|
|
* Copyright (C) 2015-present ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <seastar/core/sharded.hh>
|
|
#include <seastar/json/json_elements.hh>
|
|
#include "api/api_init.hh"
|
|
#include "db/data_listeners.hh"
|
|
#include "compaction/compaction_descriptor.hh"
|
|
#include "gms/gossip_address_map.hh"
|
|
|
|
namespace cql_transport { class controller; }
|
|
namespace db {
|
|
class snapshot_ctl;
|
|
namespace view {
|
|
class view_builder;
|
|
}
|
|
class system_keyspace;
|
|
}
|
|
namespace netw { class messaging_service; }
|
|
class repair_service;
|
|
class sstables_loader;
|
|
|
|
namespace gms {
|
|
|
|
class gossiper;
|
|
|
|
}
|
|
|
|
namespace api {
|
|
|
|
// verify that the keyspace is found, otherwise a bad_param_exception exception is thrown
|
|
// containing the description of the respective keyspace error.
|
|
sstring validate_keyspace(const http_context& ctx, sstring ks_name);
|
|
|
|
// verify that the keyspace parameter is found, otherwise a bad_param_exception exception is thrown
|
|
// containing the description of the respective keyspace error.
|
|
sstring validate_keyspace(const http_context& ctx, const std::unique_ptr<http::request>& req);
|
|
|
|
// splits a request parameter assumed to hold a comma-separated list of table names
|
|
// verify that the tables are found, otherwise a bad_param_exception exception is thrown
|
|
// containing the description of the respective no_such_column_family error.
|
|
// Returns a vector of all table infos given by the parameter, or
|
|
// if the parameter is not found or is empty, returns a list of all table infos in the keyspace.
|
|
std::vector<table_info> parse_table_infos(const sstring& ks_name, const http_context& ctx, const std::unordered_map<sstring, sstring>& query_params, sstring param_name);
|
|
|
|
std::vector<table_info> parse_table_infos(const sstring& ks_name, const http_context& ctx, sstring value);
|
|
|
|
struct scrub_info {
|
|
sstables::compaction_type_options::scrub opts;
|
|
sstring keyspace;
|
|
std::vector<sstring> column_families;
|
|
};
|
|
|
|
future<scrub_info> parse_scrub_options(const 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 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);
|
|
void set_view_builder(http_context& ctx, httpd::routes& r, sharded<db::view::view_builder>& vb, sharded<gms::gossiper>& g);
|
|
void unset_view_builder(http_context& ctx, httpd::routes& r);
|
|
void set_repair(http_context& ctx, httpd::routes& r, sharded<repair_service>& repair, sharded<gms::gossip_address_map>& am);
|
|
void unset_repair(http_context& ctx, httpd::routes& r);
|
|
void set_transport_controller(http_context& ctx, httpd::routes& r, cql_transport::controller& ctl);
|
|
void unset_transport_controller(http_context& ctx, httpd::routes& r);
|
|
void set_thrift_controller(http_context& ctx, httpd::routes& r);
|
|
void unset_thrift_controller(http_context& ctx, httpd::routes& r);
|
|
void set_snapshot(http_context& ctx, httpd::routes& r, sharded<db::snapshot_ctl>& snap_ctl);
|
|
void unset_snapshot(http_context& ctx, httpd::routes& r);
|
|
void set_load_meter(http_context& ctx, httpd::routes& r, service::load_meter& lm);
|
|
void unset_load_meter(http_context& ctx, httpd::routes& r);
|
|
seastar::future<json::json_return_type> run_toppartitions_query(db::toppartitions_query& q, http_context &ctx, bool legacy_request = false);
|
|
|
|
} // namespace api
|