From 2ca8a580d994f1f5fdee9fcb75a323907fda84a8 Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Wed, 22 Dec 2021 18:35:55 +0300 Subject: [PATCH] create_|alter_keyspace_statement: Make check_restricted_replication_strategy() accept query_processor Patch the check_restricted_replication_strategy() and its callers. Signed-off-by: Pavel Emelyanov --- cql3/statements/alter_keyspace_statement.cc | 2 +- cql3/statements/create_keyspace_statement.cc | 8 ++++---- cql3/statements/create_keyspace_statement.hh | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cql3/statements/alter_keyspace_statement.cc b/cql3/statements/alter_keyspace_statement.cc index 0db68d01d3..89b071a5ff 100644 --- a/cql3/statements/alter_keyspace_statement.cc +++ b/cql3/statements/alter_keyspace_statement.cc @@ -120,7 +120,7 @@ static logging::logger mylogger("alter_keyspace"); future<::shared_ptr> cql3::statements::alter_keyspace_statement::execute(query_processor& qp, service::query_state& state, const query_options& options) const { - std::optional warning = check_restricted_replication_strategy(qp.proxy(), keyspace(), *_attrs); + std::optional warning = check_restricted_replication_strategy(qp, keyspace(), *_attrs); return schema_altering_statement::execute(qp, state, options).then([this, warning = std::move(warning)] (::shared_ptr msg) { if (warning) { msg->add_warning(*warning); diff --git a/cql3/statements/create_keyspace_statement.cc b/cql3/statements/create_keyspace_statement.cc index 8d1f28d1df..7153c9b316 100644 --- a/cql3/statements/create_keyspace_statement.cc +++ b/cql3/statements/create_keyspace_statement.cc @@ -161,7 +161,7 @@ future<> cql3::statements::create_keyspace_statement::grant_permissions_to_creat // errors (such as unknown replication strategy name or unknown options // to a known replication strategy) are done elsewhere. std::optional check_restricted_replication_strategy( - service::storage_proxy& proxy, + query_processor& qp, const sstring& keyspace, const ks_prop_defs& attrs) { @@ -174,7 +174,7 @@ std::optional check_restricted_replication_strategy( // may have in the future - multiple racks or DCs. So depending on how // protective we are configured, let's prevent it or allow with a warning: if (replication_strategy == "org.apache.cassandra.locator.SimpleStrategy") { - switch(proxy.data_dictionary().get_config().restrict_replication_simplestrategy()) { + switch(qp.proxy().data_dictionary().get_config().restrict_replication_simplestrategy()) { case db::tri_mode_restriction_t::mode::TRUE: throw exceptions::configuration_exception( "SimpleStrategy replication class is not recommended, and " @@ -191,7 +191,7 @@ std::optional check_restricted_replication_strategy( case db::tri_mode_restriction_t::mode::FALSE: // Scylla was configured to allow SimpleStrategy, but let's warn // if it's used on a cluster which *already* has multiple DCs: - if (proxy.get_token_metadata_ptr()->get_topology().get_datacenter_endpoints().size() > 1) { + if (qp.proxy().get_token_metadata_ptr()->get_topology().get_datacenter_endpoints().size() > 1) { return "Using SimpleStrategy in a multi-datacenter environment is not recommended."; } break; @@ -202,7 +202,7 @@ std::optional check_restricted_replication_strategy( future<::shared_ptr> create_keyspace_statement::execute(query_processor& qp, service::query_state& state, const query_options& options) const { - std::optional warning = check_restricted_replication_strategy(qp.proxy(), keyspace(), *_attrs); + std::optional warning = check_restricted_replication_strategy(qp, keyspace(), *_attrs); return schema_altering_statement::execute(qp, state, options).then([this, warning = std::move(warning)] (::shared_ptr msg) { if (warning) { msg->add_warning(*warning); diff --git a/cql3/statements/create_keyspace_statement.hh b/cql3/statements/create_keyspace_statement.hh index 00bdfc8b0d..6bbb3a6a1f 100644 --- a/cql3/statements/create_keyspace_statement.hh +++ b/cql3/statements/create_keyspace_statement.hh @@ -108,7 +108,7 @@ public: }; std::optional check_restricted_replication_strategy( - service::storage_proxy& proxy, + query_processor& qp, const sstring& keyspace, const ks_prop_defs& attrs);