summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHari Khalsa <hkhalsa@10gen.com>2014-08-22 14:31:33 -0400
committerHari Khalsa <hkhalsa@10gen.com>2014-08-26 12:03:27 -0400
commit2c403aab664bb25704d984c48583d80701a5267b (patch)
treecd0856464104034dc88d6e76c1f4548d640f2b78
parent7b1fb9c442e6c97df18d0ecba47a21adaaf1d65b (diff)
downloadmongo-2c403aab664bb25704d984c48583d80701a5267b.tar.gz
SERVER-14413 move globalStorageEngine inside of global env
-rw-r--r--src/mongo/SConscript2
-rw-r--r--src/mongo/db/db.cpp9
-rw-r--r--src/mongo/db/global_environment_d.cpp38
-rw-r--r--src/mongo/db/global_environment_d.h12
-rw-r--r--src/mongo/db/global_environment_experiment.h22
-rw-r--r--src/mongo/db/global_environment_noop.cpp6
-rw-r--r--src/mongo/db/global_environment_noop.h5
-rw-r--r--src/mongo/db/storage/heap1/heap1_init.cpp56
-rw-r--r--src/mongo/db/storage/mmap_v1/SConscript1
-rw-r--r--src/mongo/db/storage/mmap_v1/dur.cpp2
-rw-r--r--src/mongo/db/storage/mmap_v1/dur_recover.cpp2
-rw-r--r--src/mongo/db/storage/mmap_v1/mmap_v1_engine.cpp1
-rw-r--r--src/mongo/db/storage/mmap_v1/mmap_v1_init.cpp57
-rw-r--r--src/mongo/db/storage/mmap_v1/repair_database.cpp7
-rw-r--r--src/mongo/db/storage/storage_engine.h81
-rw-r--r--src/mongo/db/storage/storage_init.cpp (renamed from src/mongo/db/storage/storage_engine.cpp)38
-rw-r--r--src/mongo/dbtests/framework.cpp5
-rw-r--r--src/mongo/tools/tool.cpp4
18 files changed, 247 insertions, 101 deletions
diff --git a/src/mongo/SConscript b/src/mongo/SConscript
index 3f313d3b561..e19a521e9e7 100644
--- a/src/mongo/SConscript
+++ b/src/mongo/SConscript
@@ -566,7 +566,6 @@ serverOnlyFiles = [ "db/curop.cpp",
"util/logfile.cpp",
"util/alignedbuilder.cpp",
"util/elapsed_tracker.cpp",
- "db/storage/storage_engine.cpp",
"db/operation_context_impl.cpp",
"db/introspect.cpp",
"db/clientcursor.cpp",
@@ -645,6 +644,7 @@ serverOnlyFiles = [ "db/curop.cpp",
"db/write_concern.cpp",
"db/startup_warnings.cpp",
"db/storage_options.cpp",
+ "db/storage/storage_init.cpp",
"db/ops/update_lifecycle_impl.cpp",
"db/matcher/expression_where.cpp",
diff --git a/src/mongo/db/db.cpp b/src/mongo/db/db.cpp
index f2918bff1ef..8abf9aa1a0e 100644
--- a/src/mongo/db/db.cpp
+++ b/src/mongo/db/db.cpp
@@ -586,7 +586,7 @@ namespace mongo {
snmpInit();
}
- initGlobalStorageEngine();
+ getGlobalEnvironment()->setGlobalStorageEngine(storageGlobalParams.engine);
boost::filesystem::remove_all(storageGlobalParams.dbpath + "/_tmp/");
@@ -832,11 +832,6 @@ MONGO_INITIALIZER_GENERAL(CreateAuthorizationManager,
return Status::OK();
}
-MONGO_INITIALIZER(SetGlobalConfigExperiment)(InitializerContext* context) {
- setGlobalEnvironment(new GlobalEnvironmentMongoD());
- return Status::OK();
-}
-
namespace {
repl::ReplSettings replSettings;
} // namespace
@@ -847,7 +842,7 @@ namespace mongo {
}
} // namespace mongo
-MONGO_INITIALIZER_WITH_PREREQUISITES(CreateReplicationManager, ("SetGlobalConfigExperiment"))
+MONGO_INITIALIZER_WITH_PREREQUISITES(CreateReplicationManager, ("SetGlobalEnvironment"))
(InitializerContext* context) {
repl::setGlobalReplicationCoordinator(new repl::HybridReplicationCoordinator(replSettings));
return Status::OK();
diff --git a/src/mongo/db/global_environment_d.cpp b/src/mongo/db/global_environment_d.cpp
index 6b7ea87ebf0..b1324f0388d 100644
--- a/src/mongo/db/global_environment_d.cpp
+++ b/src/mongo/db/global_environment_d.cpp
@@ -30,6 +30,8 @@
#include <set>
+#include "mongo/base/init.h"
+#include "mongo/base/initializer.h"
#include "mongo/db/client.h"
#include "mongo/db/curop.h"
#include "mongo/db/operation_context_impl.h"
@@ -39,12 +41,17 @@
namespace mongo {
- GlobalEnvironmentMongoD::GlobalEnvironmentMongoD()
- : _globalKill(false),
- _registeredOpContextsMutex("RegisteredOpContextsMutex") {
+ StorageEngine* globalStorageEngine = 0;
+ MONGO_INITIALIZER(SetGlobalEnvironment)(InitializerContext* context) {
+ setGlobalEnvironment(new GlobalEnvironmentMongoD());
+ return Status::OK();
}
+ GlobalEnvironmentMongoD::GlobalEnvironmentMongoD()
+ : _globalKill(false),
+ _registeredOpContextsMutex("RegisteredOpContextsMutex") { }
+
GlobalEnvironmentMongoD::~GlobalEnvironmentMongoD() {
if (!_registeredOpContexts.empty()) {
warning() << "Terminating with outstanding operation contexts." << endl;
@@ -52,9 +59,34 @@ namespace mongo {
}
StorageEngine* GlobalEnvironmentMongoD::getGlobalStorageEngine() {
+ invariant(globalStorageEngine);
return globalStorageEngine;
}
+ void GlobalEnvironmentMongoD::setGlobalStorageEngine(const std::string& name) {
+ // This should be set once.
+ invariant(!globalStorageEngine);
+
+ const StorageEngine::Factory* factory = _storageFactories[name];
+
+ uassert(18530, "cannot start database with an unknown storage engine: " + name, factory);
+ globalStorageEngine = factory->create(storageGlobalParams);
+ }
+
+ void GlobalEnvironmentMongoD::registerStorageEngine(const std::string& name,
+ const StorageEngine::Factory* factory) {
+ // No double-registering.
+ invariant(0 == _storageFactories.count(name));
+
+ // Some sanity checks: the factory must exist,
+ invariant(factory);
+
+ // and all factories should be added before we pick a storage engine.
+ invariant(NULL == globalStorageEngine);
+
+ _storageFactories[name] = factory;
+ }
+
void GlobalEnvironmentMongoD::setKillAllOperations() {
scoped_lock clientLock(Client::clientsMutex);
_globalKill = true;
diff --git a/src/mongo/db/global_environment_d.h b/src/mongo/db/global_environment_d.h
index 4d44c2dd071..a953b423dcd 100644
--- a/src/mongo/db/global_environment_d.h
+++ b/src/mongo/db/global_environment_d.h
@@ -45,6 +45,11 @@ namespace mongo {
StorageEngine* getGlobalStorageEngine();
+ void setGlobalStorageEngine(const std::string& name);
+
+ void registerStorageEngine(const std::string& name,
+ const StorageEngine::Factory* factory);
+
void setKillAllOperations();
void unsetKillAllOperations();
@@ -73,6 +78,13 @@ namespace mongo {
// protected by Client::clientsMutex
std::vector<KillOpListenerInterface*> _killOpListeners;
+
+ // All possible storage engines are registered here through MONGO_INIT.
+ std::map<std::string, const StorageEngine::Factory*> _storageFactories;
};
+ // TODO: This shouldn't be public. Currently, the mmapv1 dur::startup() code relies on
+ // being able to access this as it (possibly) begins recovery immediately upon start-up.
+ extern StorageEngine* globalStorageEngine;
+
} // namespace mongo
diff --git a/src/mongo/db/global_environment_experiment.h b/src/mongo/db/global_environment_experiment.h
index b99ab8f4784..ed63113d08c 100644
--- a/src/mongo/db/global_environment_experiment.h
+++ b/src/mongo/db/global_environment_experiment.h
@@ -29,11 +29,11 @@
#pragma once
#include "mongo/base/disallow_copying.h"
+#include "mongo/db/storage/storage_engine.h"
namespace mongo {
class OperationContext;
- class StorageEngine;
/**
* Classes that implement this interface can receive notification on killOp.
@@ -60,6 +60,22 @@ namespace mongo {
public:
virtual ~GlobalEnvironmentExperiment() { }
+ //
+ // Storage
+ //
+
+ /**
+ * Register a storage engine. Called from a MONGO_INIT that depends on initializiation of
+ * the global environment.
+ */
+ virtual void registerStorageEngine(const std::string& name,
+ const StorageEngine::Factory* factory) = 0;
+
+ /**
+ * Set the storage engine. The engine must have been registered via registerStorageEngine.
+ */
+ virtual void setGlobalStorageEngine(const std::string& name) = 0;
+
/**
* Return the storage engine instance we're using.
*/
@@ -142,10 +158,6 @@ namespace mongo {
*/
virtual void forEachOperationContext(ProcessOperationContext* procOpCtx) = 0;
- //
- // Factories for storage interfaces
- //
-
/**
* Returns a new OperationContext. Caller owns pointer.
*/
diff --git a/src/mongo/db/global_environment_noop.cpp b/src/mongo/db/global_environment_noop.cpp
index a7102e7e87f..b99af713101 100644
--- a/src/mongo/db/global_environment_noop.cpp
+++ b/src/mongo/db/global_environment_noop.cpp
@@ -36,6 +36,12 @@ namespace mongo {
return NULL;
}
+ void GlobalEnvironmentNoop::setGlobalStorageEngine(const std::string& name) {
+ }
+
+ void GlobalEnvironmentNoop::registerStorageEngine(const std::string& name,
+ const StorageEngine::Factory* factory) { }
+
void GlobalEnvironmentNoop::setKillAllOperations() { }
void GlobalEnvironmentNoop::unsetKillAllOperations() { }
diff --git a/src/mongo/db/global_environment_noop.h b/src/mongo/db/global_environment_noop.h
index 0c17b4cc2ca..fa4459d49f0 100644
--- a/src/mongo/db/global_environment_noop.h
+++ b/src/mongo/db/global_environment_noop.h
@@ -34,6 +34,11 @@ namespace mongo {
public:
StorageEngine* getGlobalStorageEngine();
+ void setGlobalStorageEngine(const std::string& name);
+
+ void registerStorageEngine(const std::string& name,
+ const StorageEngine::Factory* factory);
+
bool killOperation(unsigned int opId);
void setKillAllOperations();
diff --git a/src/mongo/db/storage/heap1/heap1_init.cpp b/src/mongo/db/storage/heap1/heap1_init.cpp
new file mode 100644
index 00000000000..59401f71070
--- /dev/null
+++ b/src/mongo/db/storage/heap1/heap1_init.cpp
@@ -0,0 +1,56 @@
+/**
+ * Copyright (C) 2014 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/base/init.h"
+#include "mongo/db/storage/heap1/heap1_engine.h"
+#include "mongo/db/storage_options.h"
+
+namespace mongo {
+
+ namespace {
+
+ class HeapFactory : public StorageEngine::Factory {
+ public:
+ virtual ~HeapFactory() { }
+ virtual StorageEngine* create(const StorageGlobalParams& params) const {
+ return new HeapEngine();
+ }
+ };
+
+ } // namespace
+
+ MONGO_INITIALIZER_WITH_PREREQUISITES(HeapEngineInit,
+ ("SetGlobalEnvironment"))
+ (InitializerContext* context) {
+
+ getGlobalEnvironment()->registerStorageEngine("heap1", new HeapFactory());
+ return Status::OK();
+ }
+
+} // namespace mongo
diff --git a/src/mongo/db/storage/mmap_v1/SConscript b/src/mongo/db/storage/mmap_v1/SConscript
index 097de97c5fa..50dec12ab6f 100644
--- a/src/mongo/db/storage/mmap_v1/SConscript
+++ b/src/mongo/db/storage/mmap_v1/SConscript
@@ -22,6 +22,7 @@ env.Library(
"mmap_v1_database_catalog_entry.cpp",
"mmap_v1_engine.cpp",
"mmap_v1_extent_manager.cpp",
+ "mmap_v1_init.cpp",
"repair_database.cpp",
],
LIBDEPS = [
diff --git a/src/mongo/db/storage/mmap_v1/dur.cpp b/src/mongo/db/storage/mmap_v1/dur.cpp
index 438e1ca9a72..f3d31aa32ef 100644
--- a/src/mongo/db/storage/mmap_v1/dur.cpp
+++ b/src/mongo/db/storage/mmap_v1/dur.cpp
@@ -903,7 +903,7 @@ namespace mongo {
}
commitNow(txn);
- globalStorageEngine->flushAllFiles(true);
+ MongoFile::flushAll(true);
journalCleanup();
verify(!haveJournalFiles()); // Double check post-conditions
diff --git a/src/mongo/db/storage/mmap_v1/dur_recover.cpp b/src/mongo/db/storage/mmap_v1/dur_recover.cpp
index 96c07ec0f63..2418fca68e1 100644
--- a/src/mongo/db/storage/mmap_v1/dur_recover.cpp
+++ b/src/mongo/db/storage/mmap_v1/dur_recover.cpp
@@ -227,7 +227,7 @@ namespace mongo {
}
void RecoveryJob::_close() {
- globalStorageEngine->flushAllFiles(true);
+ MongoFile::flushAll(true);
_mmfs.clear();
}
diff --git a/src/mongo/db/storage/mmap_v1/mmap_v1_engine.cpp b/src/mongo/db/storage/mmap_v1/mmap_v1_engine.cpp
index 29d52b21802..46525799d74 100644
--- a/src/mongo/db/storage/mmap_v1/mmap_v1_engine.cpp
+++ b/src/mongo/db/storage/mmap_v1/mmap_v1_engine.cpp
@@ -42,6 +42,7 @@
#include <sys/file.h>
#endif
+#include "mongo/db/global_environment_d.h" // XXX: for globalStorageEngine
#include "mongo/db/mongod_options.h"
#include "mongo/db/storage/mmap_v1/dur.h"
#include "mongo/db/storage/mmap_v1/dur_commitjob.h"
diff --git a/src/mongo/db/storage/mmap_v1/mmap_v1_init.cpp b/src/mongo/db/storage/mmap_v1/mmap_v1_init.cpp
new file mode 100644
index 00000000000..7aba9da0f93
--- /dev/null
+++ b/src/mongo/db/storage/mmap_v1/mmap_v1_init.cpp
@@ -0,0 +1,57 @@
+/**
+ * Copyright (C) 2014 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/base/init.h"
+#include "mongo/db/global_environment_experiment.h"
+#include "mongo/db/storage/mmap_v1/mmap_v1_engine.h"
+#include "mongo/db/storage_options.h"
+
+namespace mongo {
+
+ namespace {
+
+ class MMAPV1Factory : public StorageEngine::Factory {
+ public:
+ virtual ~MMAPV1Factory() { }
+ virtual StorageEngine* create(const StorageGlobalParams& params) const {
+ return new MMAPV1Engine();
+ }
+ };
+
+ } // namespace
+
+ MONGO_INITIALIZER_WITH_PREREQUISITES(MMAPV1EngineInit,
+ ("SetGlobalEnvironment"))
+ (InitializerContext* context) {
+
+ getGlobalEnvironment()->registerStorageEngine("mmapv1", new MMAPV1Factory());
+ return Status::OK();
+ }
+
+} // namespace mongo
diff --git a/src/mongo/db/storage/mmap_v1/repair_database.cpp b/src/mongo/db/storage/mmap_v1/repair_database.cpp
index fc01db60723..07f5e1bc4c4 100644
--- a/src/mongo/db/storage/mmap_v1/repair_database.cpp
+++ b/src/mongo/db/storage/mmap_v1/repair_database.cpp
@@ -240,8 +240,8 @@ namespace mongo {
try {
_txn->recoveryUnit()->syncDataAndTruncateJournal();
-
- globalStorageEngine->flushAllFiles(true); // need both in case journaling is disabled
+ // need both in case journaling is disabled
+ MongoFile::flushAll(true);
MONGO_ASSERT_ON_EXCEPTION( boost::filesystem::remove_all( _path ) );
}
@@ -434,7 +434,8 @@ namespace mongo {
}
txn->recoveryUnit()->syncDataAndTruncateJournal();
- globalStorageEngine->flushAllFiles(true); // need both in case journaling is disabled
+ // need both in case journaling is disabled
+ MongoFile::flushAll(true);
txn->checkForInterrupt(false);
}
diff --git a/src/mongo/db/storage/storage_engine.h b/src/mongo/db/storage/storage_engine.h
index cc6fee59845..7e4e6ae694d 100644
--- a/src/mongo/db/storage/storage_engine.h
+++ b/src/mongo/db/storage/storage_engine.h
@@ -1,32 +1,32 @@
// storage_engine.h
/**
-* Copyright (C) 2014 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.
-*/
+ * Copyright (C) 2014 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
@@ -49,16 +49,23 @@ namespace mongo {
*/
class StorageEngine {
public:
- //
- // Static methods for registering StorageEngine implementations. XXX: global config
- //
+
+ /**
+ * The interface for creating new instances of storage engines.
+ *
+ * A storage engine provides an instance of this class (along with an associated
+ * name) to the global environment, which then sets the global storage engine
+ * according to the provided configuration parameter.
+ */
class Factory {
public:
virtual ~Factory() { }
- virtual StorageEngine* create( const StorageGlobalParams& params ) const = 0;
- };
- static void registerFactory( const std::string& name, const Factory* factory );
+ /**
+ * Return a new instance of the StorageEngine. Caller owns the returned pointer.
+ */
+ virtual StorageEngine* create(const StorageGlobalParams& params) const = 0;
+ };
/**
* Returns a new interface to the storage engine's recovery unit. The recovery
@@ -120,12 +127,4 @@ namespace mongo {
virtual ~StorageEngine() {}
};
- /**
- * Sets up the globalStorageEngine pointer and performs any startup work needed by the selected
- * storage engine. This must be called at a point where it is safe to spawn worker threads.
- */
- void initGlobalStorageEngine();
-
- // TODO: this is temporary
- extern StorageEngine* globalStorageEngine;
-}
+} // namespace mongo
diff --git a/src/mongo/db/storage/storage_engine.cpp b/src/mongo/db/storage/storage_init.cpp
index b344a68a878..08ed2d69716 100644
--- a/src/mongo/db/storage/storage_engine.cpp
+++ b/src/mongo/db/storage/storage_init.cpp
@@ -28,45 +28,14 @@
* it in the license file.
*/
-#include "mongo/db/storage/storage_engine.h"
-
#include "mongo/db/commands/server_status.h"
#include "mongo/db/storage_options.h"
-#include "mongo/db/storage/heap1/heap1_engine.h"
-#include "mongo/db/storage/mmap_v1/mmap_v1_engine.h"
-#include "mongo/util/log.h"
namespace mongo {
- StorageEngine* globalStorageEngine = 0;
-
+ // TODO: Does this belong here?
namespace {
- std::map<std::string,const StorageEngine::Factory*> factorys;
- } // namespace
-
- void StorageEngine::registerFactory( const std::string& name,
- const StorageEngine::Factory* factory ) {
- invariant( factorys.count(name) == 0 );
- factorys[name] = factory;
- }
- void initGlobalStorageEngine() {
- // TODO these should use the StorageEngine::Factory system
- if ( storageGlobalParams.engine == "mmapv1" ) {
- globalStorageEngine = new MMAPV1Engine();
- }
- else if ( storageGlobalParams.engine == "heap1" ) {
- globalStorageEngine = new Heap1Engine();
- }
- else {
- const StorageEngine::Factory* factory = factorys[storageGlobalParams.engine];
- uassert(18525, "unknown storage engine: " + storageGlobalParams.engine,
- factory);
- globalStorageEngine = factory->create( storageGlobalParams );
- }
- }
-
- namespace {
class StorageSSS : public ServerStatusSection {
public:
StorageSSS() : ServerStatusSection( "storageEngine" ) {
@@ -81,6 +50,7 @@ namespace mongo {
}
} storageSSS;
- }
-}
+ } // namespace
+
+} // namespace mongo
diff --git a/src/mongo/dbtests/framework.cpp b/src/mongo/dbtests/framework.cpp
index 2604571300c..8354c6fb0e3 100644
--- a/src/mongo/dbtests/framework.cpp
+++ b/src/mongo/dbtests/framework.cpp
@@ -41,8 +41,9 @@
#include "mongo/base/status.h"
#include "mongo/db/client.h"
#include "mongo/db/concurrency/lock_state.h"
+#include "mongo/db/global_environment_d.h"
+#include "mongo/db/global_environment_experiment.h"
#include "mongo/db/ops/update.h"
-#include "mongo/db/storage/storage_engine.h"
#include "mongo/dbtests/dbtests.h"
#include "mongo/dbtests/framework_options.h"
#include "mongo/util/background.h"
@@ -113,7 +114,7 @@ namespace mongo {
printOpenSSLVersion();
printSysInfo();
- initGlobalStorageEngine();
+ getGlobalEnvironment()->setGlobalStorageEngine(storageGlobalParams.engine);
TestWatchDog twd;
twd.go();
diff --git a/src/mongo/tools/tool.cpp b/src/mongo/tools/tool.cpp
index 0921b358338..045d830d77c 100644
--- a/src/mongo/tools/tool.cpp
+++ b/src/mongo/tools/tool.cpp
@@ -79,8 +79,6 @@ namespace mongo {
new AuthzManagerExternalStateMock()));
repl::ReplSettings replSettings;
repl::setGlobalReplicationCoordinator(new repl::ReplicationCoordinatorMock(replSettings));
- // We don't use the noop environment here since we actually need the storage engine...
- setGlobalEnvironment(new GlobalEnvironmentMongoD());
return Status::OK();
}
@@ -134,7 +132,7 @@ namespace mongo {
Client::initThread("tools");
storageGlobalParams.dbpath = toolGlobalParams.dbpath;
try {
- initGlobalStorageEngine();
+ getGlobalEnvironment()->setGlobalStorageEngine(storageGlobalParams.engine);
}
catch (const DBException& ex) {
if (ex.getCode() == ErrorCodes::DBPathInUse) {