diff --git a/config/ks_meta_data.cc b/config/ks_meta_data.cc new file mode 100644 index 0000000000..71c35cf8c1 --- /dev/null +++ b/config/ks_meta_data.cc @@ -0,0 +1,85 @@ +/* + * 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 + */ + +#include "config/ks_meta_data.hh" + +namespace config { + +ks_meta_data::ks_meta_data(sstring name_, + sstring strategy_name_, + std::unordered_map strategy_options_, + bool durable_writes_) + : ks_meta_data{std::move(name_), + std::move(strategy_name_), + std::move(strategy_options_), + durable_writes_, + {}, ::make_shared()} +{ } + +ks_meta_data::ks_meta_data(sstring name_, + sstring strategy_name_, + std::unordered_map strategy_options_, + bool durable_writes_, + std::vector cf_defs) + : ks_meta_data{std::move(name_), + std::move(strategy_name_), + std::move(strategy_options_), + durable_writes_, + std::move(cf_defs), + ::make_shared()} +{ } + +ks_meta_data::ks_meta_data(sstring name_, + sstring strategy_name_, + std::unordered_map strategy_options_, + bool durable_writes_, + std::vector cf_defs, + shared_ptr user_types_) + : name{std::move(name_)} + , strategy_name{strategy_name_.empty() ? "NetworkTopologyStrategy" : strategy_name_} + , strategy_options{std::move(strategy_options_)} + , durable_writes{durable_writes_} + , user_types{std::move(user_types_)} +{ + for (auto&& s : cf_defs) { + _cf_meta_data.emplace(s->cf_name(), s); + } +} + +// For new user created keyspaces (through CQL) +lw_shared_ptr ks_meta_data::new_keyspace(sstring name, sstring strategy_name, std::unordered_map options, bool durable_writes) { +#if 0 + Class cls = AbstractReplicationStrategy.getClass(strategyName); + if (cls.equals(LocalStrategy.class)) + throw new ConfigurationException("Unable to use given strategy class: LocalStrategy is reserved for internal use."); +#endif + return new_keyspace(name, strategy_name, options, durable_writes, std::vector{}); +} + +lw_shared_ptr ks_meta_data::new_keyspace(sstring name, sstring strategy_name, std::unordered_map options, bool durables_writes, std::vector cf_defs) +{ + return ::make_lw_shared(name, strategy_name, options, durables_writes, cf_defs, ::make_shared()); +} + +} diff --git a/config/ks_meta_data.hh b/config/ks_meta_data.hh index f1baf97825..b054c70ba5 100644 --- a/config/ks_meta_data.hh +++ b/config/ks_meta_data.hh @@ -48,58 +48,25 @@ public: ks_meta_data(sstring name_, sstring strategy_name_, std::unordered_map strategy_options_, - bool durable_writes_) - : ks_meta_data{std::move(name_), - std::move(strategy_name_), - std::move(strategy_options_), - durable_writes_, - {}, ::make_shared()} - { } + bool durable_writes_); ks_meta_data(sstring name_, sstring strategy_name_, std::unordered_map strategy_options_, bool durable_writes_, - std::vector cf_defs) - : ks_meta_data{std::move(name_), - std::move(strategy_name_), - std::move(strategy_options_), - durable_writes_, - std::move(cf_defs), - ::make_shared()} - { } + std::vector cf_defs); ks_meta_data(sstring name_, sstring strategy_name_, std::unordered_map strategy_options_, bool durable_writes_, std::vector cf_defs, - shared_ptr user_types_) - : name{std::move(name_)} - , strategy_name{strategy_name_.empty() ? "NetworkTopologyStrategy" : strategy_name_} - , strategy_options{std::move(strategy_options_)} - , durable_writes{durable_writes_} - , user_types{std::move(user_types_)} - { - for (auto&& s : cf_defs) { - _cf_meta_data.emplace(s->cf_name(), s); - } - } + shared_ptr user_types_); // For new user created keyspaces (through CQL) - static lw_shared_ptr new_keyspace(sstring name, sstring strategy_name, std::unordered_map options, bool durable_writes) { -#if 0 - Class cls = AbstractReplicationStrategy.getClass(strategyName); - if (cls.equals(LocalStrategy.class)) - throw new ConfigurationException("Unable to use given strategy class: LocalStrategy is reserved for internal use."); -#endif - return new_keyspace(name, strategy_name, options, durable_writes, std::vector{}); - } + static lw_shared_ptr new_keyspace(sstring name, sstring strategy_name, std::unordered_map options, bool durable_writes); - static lw_shared_ptr new_keyspace(sstring name, sstring strategy_name, std::unordered_map options, bool durables_writes, std::vector cf_defs) - { - return ::make_lw_shared(name, strategy_name, options, durables_writes, cf_defs, ::make_shared()); - } + static lw_shared_ptr new_keyspace(sstring name, sstring strategy_name, std::unordered_map options, bool durables_writes, std::vector cf_defs); #if 0 public KSMetaData cloneWithTableRemoved(CFMetaData table) diff --git a/configure.py b/configure.py index 2ead168953..f1e12f26e0 100755 --- a/configure.py +++ b/configure.py @@ -365,6 +365,7 @@ urchin_core = (['database.cc', 'sstables/partition.cc', 'log.cc', 'transport/server.cc', + 'config/ks_meta_data.cc', 'cql3/abstract_marker.cc', 'cql3/cql3.cc', 'cql3/cql3_type.cc',