diff --git a/config/ks_meta_data.cc b/config/ks_meta_data.cc index ee96b64d14..9f06dc4482 100644 --- a/config/ks_meta_data.cc +++ b/config/ks_meta_data.cc @@ -22,12 +22,8 @@ * Modified by Cloudius Systems */ -#include "config/ks_meta_data.hh" - #include "database.hh" -namespace config { - ks_meta_data::ks_meta_data(sstring name, sstring strategy_name, std::unordered_map strategy_options, @@ -54,5 +50,3 @@ ks_meta_data::new_keyspace(sstring name, { return ::make_lw_shared(name, strategy_name, options, durables_writes, cf_defs); } - -} diff --git a/config/ks_meta_data.hh b/config/ks_meta_data.hh deleted file mode 100644 index c186853ad5..0000000000 --- a/config/ks_meta_data.hh +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Copyright 2015 Cloudius Systems - * - * Modified by Cloudius Systems - */ - -#pragma once - -#include "schema.hh" - -#include "core/shared_ptr.hh" - -#include - -class user_types_metadata; - -namespace config { - -class ks_meta_data final { - sstring _name; - sstring _strategy_name; - std::unordered_map _strategy_options; - std::unordered_map _cf_meta_data; - bool _durable_writes; - ::shared_ptr _user_types; -public: - ks_meta_data(sstring name, - sstring strategy_name, - std::unordered_map strategy_options, - bool durable_writes, - std::vector cf_defs = std::vector{}, - shared_ptr user_types = ::make_shared()); - - static lw_shared_ptr - new_keyspace(sstring name, - sstring strategy_name, - std::unordered_map options, - bool durables_writes, - std::vector cf_defs = std::vector{}); - - const sstring& name() const { - return _name; - } - const sstring& strategy_name() const { - return _strategy_name; - } - const std::unordered_map& strategy_options() const { - return _strategy_options; - } - const std::unordered_map& cf_meta_data() const { - return _cf_meta_data; - } - bool durable_writes() const { - return _durable_writes; - } - const ::shared_ptr& user_types() const { - return _user_types; - } -}; - -} diff --git a/cql3/statements/create_keyspace_statement.hh b/cql3/statements/create_keyspace_statement.hh index 17dd06da8f..40fcc7bc59 100644 --- a/cql3/statements/create_keyspace_statement.hh +++ b/cql3/statements/create_keyspace_statement.hh @@ -27,7 +27,6 @@ #include "cql3/statements/schema_altering_statement.hh" #include "cql3/statements/ks_prop_defs.hh" #include "service/migration_manager.hh" -#include "config/ks_meta_data.hh" #include "transport/event.hh" #include "core/shared_ptr.hh" diff --git a/cql3/statements/ks_prop_defs.hh b/cql3/statements/ks_prop_defs.hh index 8adff982da..a90397deec 100644 --- a/cql3/statements/ks_prop_defs.hh +++ b/cql3/statements/ks_prop_defs.hh @@ -25,7 +25,6 @@ #pragma once #include "cql3/statements/property_definitions.hh" -#include "config/ks_meta_data.hh" #include "core/sstring.hh" #include @@ -83,8 +82,8 @@ public: return _strategy_class; } - lw_shared_ptr as_ks_metadata(sstring ks_name) { - return config::ks_meta_data::new_keyspace(ks_name, get_replication_strategy_class().value(), get_replication_options(), get_boolean(KW_DURABLE_WRITES, true)); + lw_shared_ptr as_ks_metadata(sstring ks_name) { + return ks_meta_data::new_keyspace(ks_name, get_replication_strategy_class().value(), get_replication_options(), get_boolean(KW_DURABLE_WRITES, true)); } #if 0 diff --git a/database.cc b/database.cc index 913908d02e..1e29b594ae 100644 --- a/database.cc +++ b/database.cc @@ -530,7 +530,7 @@ const column_family& database::find_column_family(const utils::UUID& uuid) const } void -keyspace::create_replication_strategy(::config::ks_meta_data& ksm) { +keyspace::create_replication_strategy(ks_meta_data& ksm) { static thread_local locator::token_metadata tm; static locator::simple_snitch snitch; static std::unordered_map options = {{"replication_factor", "3"}}; diff --git a/database.hh b/database.hh index fbba4fbaec..5f2822f46c 100644 --- a/database.hh +++ b/database.hh @@ -6,7 +6,6 @@ #define DATABASE_HH_ #include "dht/i_partitioner.hh" -#include "config/ks_meta_data.hh" #include "locator/abstract_replication_strategy.hh" #include "core/sstring.hh" #include "core/shared_ptr.hh" @@ -134,6 +133,48 @@ public: } }; +class ks_meta_data final { + sstring _name; + sstring _strategy_name; + std::unordered_map _strategy_options; + std::unordered_map _cf_meta_data; + bool _durable_writes; + ::shared_ptr _user_types; +public: + ks_meta_data(sstring name, + sstring strategy_name, + std::unordered_map strategy_options, + bool durable_writes, + std::vector cf_defs = std::vector{}, + shared_ptr user_types = ::make_shared()); + + static lw_shared_ptr + new_keyspace(sstring name, + sstring strategy_name, + std::unordered_map options, + bool durables_writes, + std::vector cf_defs = std::vector{}); + + const sstring& name() const { + return _name; + } + const sstring& strategy_name() const { + return _strategy_name; + } + const std::unordered_map& strategy_options() const { + return _strategy_options; + } + const std::unordered_map& cf_meta_data() const { + return _cf_meta_data; + } + bool durable_writes() const { + return _durable_writes; + } + const ::shared_ptr& user_types() const { + return _user_types; + } +}; + class keyspace { public: struct config { @@ -147,7 +188,7 @@ private: public: explicit keyspace(config cfg) : _config(std::move(cfg)) {} user_types_metadata _user_types; - void create_replication_strategy(::config::ks_meta_data& ksm); + void create_replication_strategy(ks_meta_data& ksm); locator::abstract_replication_strategy& get_replication_strategy(); column_family::config make_column_family_config(const schema& s) const; future<> make_directory_for_column_family(const sstring& name, utils::UUID uuid); diff --git a/db/legacy_schema_tables.cc b/db/legacy_schema_tables.cc index 3b9e39b78e..f673836d49 100644 --- a/db/legacy_schema_tables.cc +++ b/db/legacy_schema_tables.cc @@ -820,7 +820,7 @@ std::vector ALL { KEYSPACES, COLUMNFAMILIES, COLUMNS, TRIGGERS, USE * Keyspace metadata serialization/deserialization. */ - std::vector make_create_keyspace_mutations(lw_shared_ptr<::config::ks_meta_data> keyspace, api::timestamp_type timestamp, bool with_tables_and_types_and_functions) + std::vector make_create_keyspace_mutations(lw_shared_ptr keyspace, api::timestamp_type timestamp, bool with_tables_and_types_and_functions) { std::vector mutations; schema_ptr s = keyspaces(); @@ -879,7 +879,7 @@ std::vector ALL { KEYSPACES, COLUMNFAMILIES, COLUMNS, TRIGGERS, USE * * @param partition Keyspace attributes in serialized form */ - lw_shared_ptr<::config::ks_meta_data> create_keyspace_from_schema_partition(const std::pair>& result) + lw_shared_ptr create_keyspace_from_schema_partition(const std::pair>& result) { auto&& rs = result.second; if (rs->empty()) { @@ -890,7 +890,7 @@ std::vector ALL { KEYSPACES, COLUMNFAMILIES, COLUMNS, TRIGGERS, USE auto strategy_name = row.get_nonnull("strategy_class"); std::unordered_map strategy_options; bool durable_writes = row.get_nonnull("durable_writes"); - return make_lw_shared<::config::ks_meta_data>(keyspace_name, strategy_name, strategy_options, durable_writes); + return make_lw_shared(keyspace_name, strategy_name, strategy_options, durable_writes); } #if 0 diff --git a/db/legacy_schema_tables.hh b/db/legacy_schema_tables.hh index 96aaa3f8c9..cb506ece3f 100644 --- a/db/legacy_schema_tables.hh +++ b/db/legacy_schema_tables.hh @@ -24,7 +24,6 @@ #pragma once #include "service/storage_proxy.hh" -#include "config/ks_meta_data.hh" #include "mutation.hh" #include "schema.hh" @@ -66,11 +65,11 @@ future<> merge_schema(service::storage_proxy& proxy, std::vector mutat future> merge_keyspaces(service::storage_proxy& proxy, schema_result&& before, schema_result&& after); -std::vector make_create_keyspace_mutations(lw_shared_ptr<::config::ks_meta_data> keyspace, api::timestamp_type timestamp, bool with_tables_and_types_and_functions = true); +std::vector make_create_keyspace_mutations(lw_shared_ptr keyspace, api::timestamp_type timestamp, bool with_tables_and_types_and_functions = true); -lw_shared_ptr<::config::ks_meta_data> create_keyspace_from_schema_partition(const std::pair>& partition); +lw_shared_ptr create_keyspace_from_schema_partition(const std::pair>& partition); -mutation make_create_keyspace_mutation(lw_shared_ptr<::config::ks_meta_data> keyspace, api::timestamp_type timestamp, bool with_tables_and_types_and_functions = true); +mutation make_create_keyspace_mutation(lw_shared_ptr keyspace, api::timestamp_type timestamp, bool with_tables_and_types_and_functions = true); void add_table_to_schema_mutation(schema_ptr table, api::timestamp_type timestamp, bool with_columns_and_triggers, const partition_key& pkey, std::vector& mutations); diff --git a/service/migration_manager.hh b/service/migration_manager.hh index 324d1b1a3a..81e07255fc 100644 --- a/service/migration_manager.hh +++ b/service/migration_manager.hh @@ -25,7 +25,6 @@ #pragma once #include "db/legacy_schema_tables.hh" -#include "config/ks_meta_data.hh" #if 0 package org.apache.cassandra.service; @@ -267,17 +266,17 @@ public: } #endif - static future<> announce_new_keyspace(service::storage_proxy& proxy, lw_shared_ptr ksm) + static future<> announce_new_keyspace(service::storage_proxy& proxy, lw_shared_ptr ksm) { return announce_new_keyspace(proxy, ksm, false); } - static future<> announce_new_keyspace(service::storage_proxy& proxy, lw_shared_ptr ksm, bool announce_locally) + static future<> announce_new_keyspace(service::storage_proxy& proxy, lw_shared_ptr ksm, bool announce_locally) { return announce_new_keyspace(proxy, ksm, db_clock::now_in_usecs(), announce_locally); } - static future<> announce_new_keyspace(service::storage_proxy& proxy, lw_shared_ptr ksm, api::timestamp_type timestamp, bool announce_locally) + static future<> announce_new_keyspace(service::storage_proxy& proxy, lw_shared_ptr ksm, api::timestamp_type timestamp, bool announce_locally) { #if 0 ksm.validate(); diff --git a/tests/urchin/cql_test_env.cc b/tests/urchin/cql_test_env.cc index 42400a6a0a..8bf9d0799c 100644 --- a/tests/urchin/cql_test_env.cc +++ b/tests/urchin/cql_test_env.cc @@ -95,7 +95,7 @@ public: auto& ks = db.find_or_create_keyspace(ks_name); auto cfg = ks.make_column_family_config(*cf_schema); db.add_column_family(column_family(std::move(cf_schema), std::move(cfg))); - config::ks_meta_data ksm(ks_name, + ks_meta_data ksm(ks_name, "org.apache.cassandra.locator.SimpleStrategy", std::unordered_map(), false, diff --git a/thrift/handler.cc b/thrift/handler.cc index 2afb54e997..f20f581aab 100644 --- a/thrift/handler.cc +++ b/thrift/handler.cc @@ -463,7 +463,7 @@ public: db.add_column_family(std::move(cf)); cf_defs.push_back(s); } - config::ks_meta_data ksm(to_sstring(ks_def.name), + ks_meta_data ksm(to_sstring(ks_def.name), to_sstring(ks_def.strategy_class), std::unordered_map(),//ks_def.strategy_options, ks_def.durable_writes,