summaryrefslogtreecommitdiff
path: root/src/mongo/db/service_context_d.cpp
diff options
context:
space:
mode:
authorMax Hirschhorn <max.hirschhorn@mongodb.com>2015-05-22 09:04:55 -0400
committerMax Hirschhorn <max.hirschhorn@mongodb.com>2015-05-22 09:04:55 -0400
commit841c50f3e7a8da9831a5e8c7c9ad9a22b12a17de (patch)
tree65e57c14746cf79d0421507a0c51d6af45e24e65 /src/mongo/db/service_context_d.cpp
parent38862aaa17e06e5e6733598bbb487774cb3616f7 (diff)
downloadmongo-841c50f3e7a8da9831a5e8c7c9ad9a22b12a17de.tar.gz
Revert "SERVER-17861 Change the default storage engine to wiredTiger."
This reverts commit 38862aaa17e06e5e6733598bbb487774cb3616f7.
Diffstat (limited to 'src/mongo/db/service_context_d.cpp')
-rw-r--r--src/mongo/db/service_context_d.cpp52
1 files changed, 9 insertions, 43 deletions
diff --git a/src/mongo/db/service_context_d.cpp b/src/mongo/db/service_context_d.cpp
index 704e17fb6bd..d78cf0be802 100644
--- a/src/mongo/db/service_context_d.cpp
+++ b/src/mongo/db/service_context_d.cpp
@@ -32,8 +32,6 @@
#include "mongo/db/service_context_d.h"
-#include <boost/optional.hpp>
-
#include "mongo/base/init.h"
#include "mongo/base/initializer.h"
#include "mongo/db/client.h"
@@ -47,7 +45,6 @@
#include "mongo/scripting/engine.h"
#include "mongo/stdx/memory.h"
#include "mongo/util/log.h"
-#include "mongo/util/map_util.h"
#include "mongo/util/mongoutils/str.h"
#include "mongo/util/scopeguard.h"
@@ -75,52 +72,21 @@ namespace mongo {
extern bool _supportsDocLocking;
- void ServiceContextMongoD::initializeGlobalStorageEngine() {
+ void ServiceContextMongoD::setGlobalStorageEngine(const std::string& name) {
// This should be set once.
invariant(!_storageEngine);
- const std::string dbpath = storageGlobalParams.dbpath;
- if (auto existingStorageEngine = StorageEngineMetadata::getStorageEngineForPath(dbpath)) {
- if (storageGlobalParams.engineSetByUser) {
- // Verify that the name of the user-supplied storage engine matches the contents of
- // the metadata file.
- const StorageEngine::Factory* factory = mapFindWithDefault(
- _storageFactories,
- storageGlobalParams.engine,
- static_cast<const StorageEngine::Factory*>(nullptr));
-
- if (factory) {
- uassert(28661, str::stream()
- << "Cannot start server. Detected data files in " << dbpath << " created by"
- << " the '" << *existingStorageEngine << "' storage engine, but the"
- << " specified storage engine was '" << factory->getCanonicalName() << "'.",
- factory->getCanonicalName() == *existingStorageEngine);
- }
- }
- else {
- // Otherwise set the active storage engine as the contents of the metadata file.
- log() << "Detected data files in " << dbpath << " created by the '"
- << *existingStorageEngine << "' storage engine, so setting the active"
- << " storage engine to '" << *existingStorageEngine << "'.";
- storageGlobalParams.engine = *existingStorageEngine;
- }
- }
- else if (!storageGlobalParams.engineSetByUser) {
- // Ensure the default storage engine is available with this build of mongod.
- uassert(28662, str::stream()
- << "Cannot start server. The default storage engine '" << storageGlobalParams.engine
- << "' is not available with this build of mongod. Please specify a different"
- << " storage engine explicitly, e.g. --storageEngine=mmapv1.",
- isRegisteredStorageEngine(storageGlobalParams.engine));
- }
-
- const StorageEngine::Factory* factory = _storageFactories[storageGlobalParams.engine];
+ const StorageEngine::Factory* factory = _storageFactories[name];
uassert(18656, str::stream()
- << "Cannot start server with an unknown storage engine: " << storageGlobalParams.engine,
+ << "Cannot start server with an unknown storage engine: " << name,
factory);
- std::unique_ptr<StorageEngineMetadata> metadata = StorageEngineMetadata::forPath(dbpath);
+ std::string canonicalName = factory->getCanonicalName().toString();
+
+ // Do not proceed if data directory has been used by a different storage engine previously.
+ std::auto_ptr<StorageEngineMetadata> metadata =
+ StorageEngineMetadata::validate(storageGlobalParams.dbpath, canonicalName);
// Validate options in metadata against current startup options.
if (metadata.get()) {
@@ -150,7 +116,7 @@ namespace mongo {
// Write a new metadata file if it is not present.
if (!metadata.get()) {
metadata.reset(new StorageEngineMetadata(storageGlobalParams.dbpath));
- metadata->setStorageEngine(factory->getCanonicalName().toString());
+ metadata->setStorageEngine(canonicalName);
metadata->setStorageEngineOptions(factory->createMetadataOptions(storageGlobalParams));
uassertStatusOK(metadata->write());
}