diff options
9 files changed, 13 insertions, 162 deletions
diff --git a/src/mongo/db/storage/wiredtiger/SConscript b/src/mongo/db/storage/wiredtiger/SConscript index 9d2a8fc8035..032257889f0 100644 --- a/src/mongo/db/storage/wiredtiger/SConscript +++ b/src/mongo/db/storage/wiredtiger/SConscript @@ -10,17 +10,14 @@ if sanitizer_list: env.Library( target='storage_wiredtiger_customization_hooks', - source= [ - 'wiredtiger_customization_hooks.cpp', - 'wiredtiger_extensions.cpp', - ], + source= ['wiredtiger_customization_hooks.cpp'], LIBDEPS= ['$BUILD_DIR/mongo/base', '$BUILD_DIR/mongo/db/service_context'], PROGDEPS_DEPENDENTS=[ '$BUILD_DIR/mongo/mongod', '$BUILD_DIR/mongo/mongos', ], -) + ) if wiredtiger: wtEnv = env.Clone() diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_customization_hooks.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_customization_hooks.cpp index d14b33de5f7..fb4c85109cb 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_customization_hooks.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_customization_hooks.cpp @@ -76,10 +76,11 @@ bool EmptyWiredTigerCustomizationHooks::restartRequired() { return false; } -std::string EmptyWiredTigerCustomizationHooks::getTableCreateConfig(StringData tableName) { +std::string EmptyWiredTigerCustomizationHooks::getOpenConfig(StringData tableName) { return ""; } + std::unique_ptr<DataProtector> EmptyWiredTigerCustomizationHooks::getDataProtector() { return std::unique_ptr<DataProtector>(); } diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_customization_hooks.h b/src/mongo/db/storage/wiredtiger/wiredtiger_customization_hooks.h index e78995481bd..b604fb70c9c 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_customization_hooks.h +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_customization_hooks.h @@ -69,10 +69,10 @@ public: virtual bool restartRequired() = 0; /** - * Gets an additional configuration string for the provided table name on a - * `WT_SESSION::create` call. + * Gets the WiredTiger encryption configuration string for the + * provided table name */ - virtual std::string getTableCreateConfig(StringData tableName) = 0; + virtual std::string getOpenConfig(StringData tableName) = 0; /** * Returns the maximum size addition when doing transforming temp data. @@ -113,7 +113,7 @@ public: bool restartRequired() override; - std::string getTableCreateConfig(StringData tableName) override; + std::string getOpenConfig(StringData tableName) override; std::unique_ptr<DataProtector> getDataProtector() override; diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_extensions.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_extensions.cpp deleted file mode 100644 index f9bd90126e2..00000000000 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_extensions.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Copyright (C) 2016 MongoDB Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * As a special exception, the copyright holders give permission to link the - * code of portions of this program with the OpenSSL library under certain - * conditions as described in each individual source file and distribute - * linked combinations including the program with the OpenSSL library. You - * must comply with the GNU Affero General Public License in all respects for - * all of the code used other than as permitted herein. If you modify file(s) - * with this exception, you may extend this exception to your version of the - * file(s), but you are not obligated to do so. If you do not wish to do so, - * delete this exception statement from your version. If you delete this - * exception statement from all source files in the program, then also delete - * it in the license file. - */ - -#include "mongo/platform/basic.h" - -#include "mongo/db/storage/wiredtiger/wiredtiger_extensions.h" - -#include "mongo/base/init.h" -#include "mongo/base/string_data.h" -#include "mongo/db/service_context.h" -#include "mongo/stdx/memory.h" - -namespace mongo { - -MONGO_INITIALIZER_WITH_PREREQUISITES(SetWiredTigerExtensions, ("SetGlobalEnvironment")) -(InitializerContext* context) { - auto configHooks = stdx::make_unique<WiredTigerExtensions>(); - WiredTigerExtensions::set(getGlobalServiceContext(), std::move(configHooks)); - - return Status::OK(); -} - -namespace { -const auto getConfigHooks = - ServiceContext::declareDecoration<std::unique_ptr<WiredTigerExtensions>>(); -} // namespace - -void WiredTigerExtensions::set(ServiceContext* service, - std::unique_ptr<WiredTigerExtensions> configHooks) { - auto& hooks = getConfigHooks(service); - invariant(configHooks); - hooks = std::move(configHooks); -} - -WiredTigerExtensions* WiredTigerExtensions::get(ServiceContext* service) { - return getConfigHooks(service).get(); -} - -std::string WiredTigerExtensions::getOpenExtensionsConfig() const { - if (_wtExtensions.size() == 0) { - return ""; - } - - StringBuilder extensions; - extensions << "extensions=["; - for (const auto& ext : _wtExtensions) { - extensions << ext << ","; - } - extensions << "],"; - - return extensions.str(); -} - -void WiredTigerExtensions::addExtension(StringData extensionConfigStr) { - _wtExtensions.emplace_back(extensionConfigStr.toString()); -} - -} // namespace mongo diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_extensions.h b/src/mongo/db/storage/wiredtiger/wiredtiger_extensions.h deleted file mode 100644 index ba73a7ff060..00000000000 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_extensions.h +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Copyright (C) 2016 MongoDB Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * As a special exception, the copyright holders give permission to link the - * code of portions of this program with the OpenSSL library under certain - * conditions as described in each individual source file and distribute - * linked combinations including the program with the OpenSSL library. You - * must comply with the GNU Affero General Public License in all respects for - * all of the code used other than as permitted herein. If you modify file(s) - * with this exception, you may extend this exception to your version of the - * file(s), but you are not obligated to do so. If you do not wish to do so, - * delete this exception statement from your version. If you delete this - * exception statement from all source files in the program, then also delete - * it in the license file. - */ - -#pragma once - -#include <memory> -#include <vector> - -namespace mongo { - -class StringData; -class ServiceContext; - -class WiredTigerExtensions { -public: - static void set(ServiceContext* service, std::unique_ptr<WiredTigerExtensions> custHooks); - - static WiredTigerExtensions* get(ServiceContext* service); - - /** - * Return the `extensions=[...]` piece for a `wiredtiger_open` call. - */ - std::string getOpenExtensionsConfig() const; - - /** - * Add an item to the `wiredtiger_open` extensions list. - */ - void addExtension(StringData extensionConfigStr); - -private: - std::vector<std::string> _wtExtensions; -}; - -} // namespace mongo diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp index de3de61bf6d..5396ae918f7 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp @@ -167,7 +167,7 @@ StatusWith<std::string> WiredTigerIndex::generateCreateString(const std::string& ss << "block_compressor=" << wiredTigerGlobalOptions.indexBlockCompressor << ","; ss << WiredTigerCustomizationHooks::get(getGlobalServiceContext()) - ->getTableCreateConfig(desc.parentNS()); + ->getOpenConfig(desc.parentNS()); ss << sysIndexConfig << ","; ss << collIndexConfig << ","; diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp index 463c4effcb9..2d5bff3f4d5 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp @@ -59,7 +59,6 @@ #include "mongo/db/storage/journal_listener.h" #include "mongo/db/storage/storage_options.h" #include "mongo/db/storage/wiredtiger/wiredtiger_customization_hooks.h" -#include "mongo/db/storage/wiredtiger/wiredtiger_extensions.h" #include "mongo/db/storage/wiredtiger/wiredtiger_global_options.h" #include "mongo/db/storage/wiredtiger/wiredtiger_index.h" #include "mongo/db/storage/wiredtiger/wiredtiger_record_store.h" @@ -227,9 +226,7 @@ WiredTigerKVEngine::WiredTigerKVEngine(const std::string& canonicalName, ss << ",log_size=2GB),"; ss << "statistics_log=(wait=" << wiredTigerGlobalOptions.statisticsLogDelaySecs << "),"; } - ss << WiredTigerCustomizationHooks::get(getGlobalServiceContext()) - ->getTableCreateConfig("system"); - ss << WiredTigerExtensions::get(getGlobalServiceContext())->getOpenExtensionsConfig(); + ss << WiredTigerCustomizationHooks::get(getGlobalServiceContext())->getOpenConfig("system"); ss << extraOpenOptions; if (_readOnly) { invariant(!_durable); diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp index fb254424b5a..d8be71400fc 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp @@ -722,7 +722,7 @@ StatusWith<std::string> WiredTigerRecordStore::generateCreateString( ss << "block_compressor=" << wiredTigerGlobalOptions.collectionBlockCompressor << ","; - ss << WiredTigerCustomizationHooks::get(getGlobalServiceContext())->getTableCreateConfig(ns); + ss << WiredTigerCustomizationHooks::get(getGlobalServiceContext())->getOpenConfig(ns); ss << extraStrings << ","; diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_size_storer.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_size_storer.cpp index 7783cea4cbf..e2a30e54365 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_size_storer.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_size_storer.cpp @@ -61,8 +61,8 @@ WiredTigerSizeStorer::WiredTigerSizeStorer(WT_CONNECTION* conn, const std::strin int ret = session->open_cursor(session, storageUri.c_str(), NULL, "overwrite=true", &_cursor); if (ret == ENOENT) { // Need to create table. - std::string config = WiredTigerCustomizationHooks::get(getGlobalServiceContext()) - ->getTableCreateConfig(storageUri); + std::string config = + WiredTigerCustomizationHooks::get(getGlobalServiceContext())->getOpenConfig(storageUri); invariantWTOK(session->create(session, storageUri.c_str(), config.c_str())); ret = session->open_cursor(session, storageUri.c_str(), NULL, "overwrite=true", &_cursor); } |