summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2017-09-20 19:11:59 -0400
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2017-09-22 19:30:55 -0400
commit5749a726b242af9f54834765fbf1c66eeed6dc3a (patch)
tree3b9fc15987b35447f7346f94a0a5b166ed3bf04a /src/mongo/db
parent4fa949bc7c9b50a8043b76b342ab5e6b172c8af9 (diff)
downloadmongo-5749a726b242af9f54834765fbf1c66eeed6dc3a.tar.gz
SERVER-31170 Cleanup bench_run.cpp
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/db.cpp134
-rw-r--r--src/mongo/db/service_context.cpp14
-rw-r--r--src/mongo/db/service_context.h45
-rw-r--r--src/mongo/db/service_context_d.cpp23
-rw-r--r--src/mongo/db/service_context_d.h20
-rw-r--r--src/mongo/db/service_context_d_test_fixture.cpp6
-rw-r--r--src/mongo/db/service_context_noop.cpp7
-rw-r--r--src/mongo/db/service_context_noop.h4
8 files changed, 105 insertions, 148 deletions
diff --git a/src/mongo/db/db.cpp b/src/mongo/db/db.cpp
index 3013b1dc333..b71537cb235 100644
--- a/src/mongo/db/db.cpp
+++ b/src/mongo/db/db.cpp
@@ -168,16 +168,8 @@
namespace mongo {
-using std::unique_ptr;
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::list;
-using std::string;
-using std::stringstream;
-using std::vector;
-
using logger::LogComponent;
+using std::endl;
namespace {
@@ -185,13 +177,13 @@ const NamespaceString startupLogCollectionName("local.startup_log");
const NamespaceString kSystemReplSetCollection("local.system.replset");
#ifdef _WIN32
-ntservice::NtServiceDefaultStrings defaultServiceStrings = {
+const ntservice::NtServiceDefaultStrings defaultServiceStrings = {
L"MongoDB", L"MongoDB", L"MongoDB Server"};
#endif
void logStartup(OperationContext* opCtx) {
BSONObjBuilder toLog;
- stringstream id;
+ std::stringstream id;
id << getHostNameCached() << "-" << jsTime().asInt64();
toLog.append("_id", id.str());
toLog.append("hostname", getHostNameCached());
@@ -241,12 +233,11 @@ void checkForIdIndexesAndDropPendingCollections(OperationContext* opCtx, Databas
return;
}
- list<string> collections;
- db->getDatabaseCatalogEntry()->getCollectionNamespaces(&collections);
+ std::list<std::string> collectionNames;
+ db->getDatabaseCatalogEntry()->getCollectionNamespaces(&collectionNames);
- for (list<string>::iterator i = collections.begin(); i != collections.end(); ++i) {
- const string& collectionName = *i;
- NamespaceString ns(collectionName);
+ for (const auto& collectionName : collectionNames) {
+ const NamespaceString ns(collectionName);
if (ns.isDropPendingNamespace()) {
auto dropOpTime = fassertStatusOK(40459, ns.getDropPendingNamespaceOpTime());
@@ -264,7 +255,7 @@ void checkForIdIndexesAndDropPendingCollections(OperationContext* opCtx, Databas
if (coll->getIndexCatalog()->findIdIndex(opCtx))
continue;
- log() << "WARNING: the collection '" << *i << "' lacks a unique index on _id."
+ log() << "WARNING: the collection '" << collectionName << "' lacks a unique index on _id."
<< " This index is needed for replication to function properly" << startupWarningsLog;
log() << "\t To fix this, you need to create a unique index on _id."
<< " See http://dochub.mongodb.org/core/build-replica-set-indexes"
@@ -307,20 +298,18 @@ void checkForCappedOplog(OperationContext* opCtx, Database* db) {
void repairDatabasesAndCheckVersion(OperationContext* opCtx) {
LOG(1) << "enter repairDatabases (to check pdfile version #)";
- Lock::GlobalWrite lk(opCtx);
+ auto const storageEngine = opCtx->getServiceContext()->getGlobalStorageEngine();
- vector<string> dbNames;
+ Lock::GlobalWrite lk(opCtx);
- StorageEngine* storageEngine = opCtx->getServiceContext()->getGlobalStorageEngine();
+ std::vector<std::string> dbNames;
storageEngine->listDatabases(&dbNames);
// Repair all databases first, so that we do not try to open them if they are in bad shape
if (storageGlobalParams.repair) {
invariant(!storageGlobalParams.readOnly);
- for (vector<string>::const_iterator i = dbNames.begin(); i != dbNames.end(); ++i) {
- const string dbName = *i;
+ for (const auto& dbName : dbNames) {
LOG(1) << " Repairing database: " << dbName;
-
fassert(18506, repairDatabase(opCtx, storageEngine, dbName));
}
}
@@ -376,8 +365,7 @@ void repairDatabasesAndCheckVersion(OperationContext* opCtx) {
// To print warning later if any database collections have UUIDs in FCV 3.4.
bool collsHaveUuids = false;
- for (vector<string>::const_iterator i = dbNames.begin(); i != dbNames.end(); ++i) {
- const string dbName = *i;
+ for (const auto& dbName : dbNames) {
LOG(1) << " Recovering database: " << dbName;
Database* db = dbHolder().openDb(opCtx, dbName);
@@ -463,7 +451,7 @@ void repairDatabasesAndCheckVersion(OperationContext* opCtx) {
PlanExecutor::ExecState state;
while (PlanExecutor::ADVANCED == (state = exec->getNext(&index, NULL))) {
const BSONObj key = index.getObjectField("key");
- const string plugin = IndexNames::findPluginName(key);
+ const auto plugin = IndexNames::findPluginName(key);
if (db->getDatabaseCatalogEntry()->isOlderThan24(opCtx)) {
if (IndexNames::existedBefore24(plugin)) {
@@ -520,18 +508,17 @@ ExitCode _initAndListen(int listenPort) {
Client::initThread("initandlisten");
initWireSpec();
- auto globalServiceContext = checked_cast<ServiceContextMongoD*>(getGlobalServiceContext());
+ auto serviceContext = checked_cast<ServiceContextMongoD*>(getGlobalServiceContext());
- globalServiceContext->setFastClockSource(FastClockSourceFactory::create(Milliseconds(10)));
- globalServiceContext->setOpObserver(stdx::make_unique<OpObserverImpl>());
+ serviceContext->setFastClockSource(FastClockSourceFactory::create(Milliseconds(10)));
+ serviceContext->setOpObserver(stdx::make_unique<OpObserverImpl>());
- DBDirectClientFactory::get(globalServiceContext)
- .registerImplementation([](OperationContext* opCtx) {
- return std::unique_ptr<DBClientBase>(new DBDirectClient(opCtx));
- });
+ DBDirectClientFactory::get(serviceContext).registerImplementation([](OperationContext* opCtx) {
+ return std::unique_ptr<DBClientBase>(new DBDirectClient(opCtx));
+ });
const repl::ReplSettings& replSettings =
- repl::ReplicationCoordinator::get(globalServiceContext)->getSettings();
+ repl::ReplicationCoordinator::get(serviceContext)->getSettings();
{
ProcessId pid = ProcessId::getCurrent();
@@ -555,24 +542,26 @@ ExitCode _initAndListen(int listenPort) {
logProcessDetails();
- globalServiceContext->createLockFile();
+ serviceContext->createLockFile();
- globalServiceContext->setServiceEntryPoint(
- stdx::make_unique<ServiceEntryPointMongod>(globalServiceContext));
+ serviceContext->setServiceEntryPoint(
+ stdx::make_unique<ServiceEntryPointMongod>(serviceContext));
- auto tl = transport::TransportLayerManager::createWithConfig(&serverGlobalParams,
- globalServiceContext);
- auto res = tl->setup();
- if (!res.isOK()) {
- error() << "Failed to set up listener: " << res;
- return EXIT_NET_ERROR;
+ {
+ auto tl =
+ transport::TransportLayerManager::createWithConfig(&serverGlobalParams, serviceContext);
+ auto res = tl->setup();
+ if (!res.isOK()) {
+ error() << "Failed to set up listener: " << res;
+ return EXIT_NET_ERROR;
+ }
+ serviceContext->setTransportLayer(std::move(tl));
}
- globalServiceContext->setTransportLayer(std::move(tl));
- globalServiceContext->initializeGlobalStorageEngine();
+ serviceContext->initializeGlobalStorageEngine();
#ifdef MONGO_CONFIG_WIREDTIGER_ENABLED
- if (EncryptionHooks::get(getGlobalServiceContext())->restartRequired()) {
+ if (EncryptionHooks::get(serviceContext)->restartRequired()) {
exitCleanly(EXIT_CLEAN);
}
#endif
@@ -592,7 +581,7 @@ ExitCode _initAndListen(int listenPort) {
}
// Warn if field name matches non-active registered storage engine.
- if (globalServiceContext->isRegisteredStorageEngine(e.fieldName())) {
+ if (serviceContext->isRegisteredStorageEngine(e.fieldName())) {
warning() << "Detected configuration for non-active storage engine "
<< e.fieldName() << " when current storage engine is "
<< storageGlobalParams.engine;
@@ -600,7 +589,7 @@ ExitCode _initAndListen(int listenPort) {
}
}
- if (!globalServiceContext->getGlobalStorageEngine()->getSnapshotManager()) {
+ if (!serviceContext->getGlobalStorageEngine()->getSnapshotManager()) {
if (moe::startupOptionsParsed.count("replication.enableMajorityReadConcern") &&
moe::startupOptionsParsed["replication.enableMajorityReadConcern"].as<bool>()) {
// Note: we are intentionally only erroring if the user explicitly requested that we
@@ -615,10 +604,10 @@ ExitCode _initAndListen(int listenPort) {
}
}
- logMongodStartupWarnings(storageGlobalParams, serverGlobalParams, globalServiceContext);
+ logMongodStartupWarnings(storageGlobalParams, serverGlobalParams, serviceContext);
{
- stringstream ss;
+ std::stringstream ss;
ss << endl;
ss << "*********************************************************************" << endl;
ss << " ERROR: dbpath (" << storageGlobalParams.dbpath << ") does not exist." << endl;
@@ -629,7 +618,7 @@ ExitCode _initAndListen(int listenPort) {
}
{
- stringstream ss;
+ std::stringstream ss;
ss << "repairpath (" << storageGlobalParams.repairpath << ") does not exist";
uassert(12590, ss.str().c_str(), boost::filesystem::exists(storageGlobalParams.repairpath));
}
@@ -647,7 +636,7 @@ ExitCode _initAndListen(int listenPort) {
ScriptEngine::setup();
}
- auto startupOpCtx = globalServiceContext->makeOperationContext(&cc());
+ auto startupOpCtx = serviceContext->makeOperationContext(&cc());
repairDatabasesAndCheckVersion(startupOpCtx.get());
@@ -659,7 +648,7 @@ ExitCode _initAndListen(int listenPort) {
// Start up health log writer thread.
HealthLog::get(startupOpCtx.get()).startup();
- auto const globalAuthzManager = AuthorizationManager::get(globalServiceContext);
+ auto const globalAuthzManager = AuthorizationManager::get(serviceContext);
uassertStatusOK(globalAuthzManager->initialize(startupOpCtx.get()));
// This is for security on certain platforms (nonce generation)
@@ -712,7 +701,7 @@ ExitCode _initAndListen(int listenPort) {
<< startupWarningsLog;
}
- SessionCatalog::create(globalServiceContext);
+ SessionCatalog::create(serviceContext);
// This function may take the global lock.
auto shardingInitialized =
@@ -772,7 +761,7 @@ ExitCode _initAndListen(int listenPort) {
storageGlobalParams.engine != "devnull") {
Lock::GlobalWrite lk(startupOpCtx.get());
FeatureCompatibilityVersion::setIfCleanStartup(
- startupOpCtx.get(), repl::StorageInterface::get(globalServiceContext));
+ startupOpCtx.get(), repl::StorageInterface::get(serviceContext));
}
if (replSettings.usingReplSets() || (!replSettings.isMaster() && replSettings.isSlave()) ||
@@ -788,10 +777,10 @@ ExitCode _initAndListen(int listenPort) {
// Set up the periodic runner for background job execution
auto runner = makePeriodicRunner();
runner->startup().transitional_ignore();
- globalServiceContext->setPeriodicRunner(std::move(runner));
+ serviceContext->setPeriodicRunner(std::move(runner));
- SessionKiller::set(globalServiceContext,
- std::make_shared<SessionKiller>(globalServiceContext, killSessionsLocal));
+ SessionKiller::set(serviceContext,
+ std::make_shared<SessionKiller>(serviceContext, killSessionsLocal));
// Set up the logical session cache
LogicalSessionCacheServer kind = LogicalSessionCacheServer::kStandalone;
@@ -801,26 +790,26 @@ ExitCode _initAndListen(int listenPort) {
kind = LogicalSessionCacheServer::kReplicaSet;
}
- auto sessionCache = makeLogicalSessionCacheD(globalServiceContext, kind);
- LogicalSessionCache::set(globalServiceContext, std::move(sessionCache));
+ auto sessionCache = makeLogicalSessionCacheD(serviceContext, kind);
+ LogicalSessionCache::set(serviceContext, std::move(sessionCache));
// MessageServer::run will return when exit code closes its socket and we don't need the
// operation context anymore
startupOpCtx.reset();
- auto start = globalServiceContext->getTransportLayer()->start();
+ auto start = serviceContext->getTransportLayer()->start();
if (!start.isOK()) {
error() << "Failed to start the listener: " << start.toString();
return EXIT_NET_ERROR;
}
- start = globalServiceContext->getServiceExecutor()->start();
+ start = serviceContext->getServiceExecutor()->start();
if (!start.isOK()) {
error() << "Failed to start the service executor: " << start;
return EXIT_NET_ERROR;
}
- globalServiceContext->notifyStartupComplete();
+ serviceContext->notifyStartupComplete();
#ifndef _WIN32
mongo::signalForkSuccess();
@@ -879,21 +868,21 @@ void startupConfigActions(const std::vector<std::string>& args) {
// and "dbppath" command. The "run" command is the same as just running mongod, so just
// falls through.
if (moe::startupOptionsParsed.count("command")) {
- vector<string> command = moe::startupOptionsParsed["command"].as<vector<string>>();
+ const auto command = moe::startupOptionsParsed["command"].as<std::vector<std::string>>();
if (command[0].compare("dbpath") == 0) {
- cout << storageGlobalParams.dbpath << endl;
+ std::cout << storageGlobalParams.dbpath << endl;
quickExit(EXIT_SUCCESS);
}
if (command[0].compare("run") != 0) {
- cout << "Invalid command: " << command[0] << endl;
+ std::cout << "Invalid command: " << command[0] << endl;
printMongodHelp(moe::startupOptions);
quickExit(EXIT_FAILURE);
}
if (command.size() > 1) {
- cout << "Too many parameters to 'run' command" << endl;
+ std::cout << "Too many parameters to 'run' command" << endl;
printMongodHelp(moe::startupOptions);
quickExit(EXIT_FAILURE);
}
@@ -912,13 +901,13 @@ void startupConfigActions(const std::vector<std::string>& args) {
moe::startupOptionsParsed["shutdown"].as<bool>() == true) {
bool failed = false;
- string name =
+ std::string name =
(boost::filesystem::path(storageGlobalParams.dbpath) / "mongod.lock").string();
if (!boost::filesystem::exists(name) || boost::filesystem::file_size(name) == 0)
failed = true;
pid_t pid;
- string procPath;
+ std::string procPath;
if (!failed) {
try {
std::ifstream f(name.c_str());
@@ -927,7 +916,8 @@ void startupConfigActions(const std::vector<std::string>& args) {
if (!boost::filesystem::exists(procPath))
failed = true;
} catch (const std::exception& e) {
- cerr << "Error reading pid from lock file [" << name << "]: " << e.what() << endl;
+ std::cerr << "Error reading pid from lock file [" << name << "]: " << e.what()
+ << endl;
failed = true;
}
}
@@ -938,11 +928,11 @@ void startupConfigActions(const std::vector<std::string>& args) {
quickExit(EXIT_FAILURE);
}
- cout << "killing process with pid: " << pid << endl;
+ std::cout << "killing process with pid: " << pid << endl;
int ret = kill(pid, SIGTERM);
if (ret) {
int e = errno;
- cerr << "failed to kill process: " << errnoWithDescription(e) << endl;
+ std::cerr << "failed to kill process: " << errnoWithDescription(e) << endl;
quickExit(EXIT_FAILURE);
}
diff --git a/src/mongo/db/service_context.cpp b/src/mongo/db/service_context.cpp
index 2b4eb81c354..48004bf0174 100644
--- a/src/mongo/db/service_context.cpp
+++ b/src/mongo/db/service_context.cpp
@@ -32,6 +32,7 @@
#include "mongo/bson/bsonobj.h"
#include "mongo/db/client.h"
+#include "mongo/db/op_observer.h"
#include "mongo/db/operation_context.h"
#include "mongo/stdx/memory.h"
#include "mongo/transport/service_entry_point.h"
@@ -188,17 +189,8 @@ transport::ServiceExecutor* ServiceContext::getServiceExecutor() const {
return _serviceExecutor.get();
}
-
-TickSource* ServiceContext::getTickSource() const {
- return _tickSource.get();
-}
-
-ClockSource* ServiceContext::getFastClockSource() const {
- return _fastClockSource.get();
-}
-
-ClockSource* ServiceContext::getPreciseClockSource() const {
- return _preciseClockSource.get();
+void ServiceContext::setOpObserver(std::unique_ptr<OpObserver> opObserver) {
+ _opObserver = std::move(opObserver);
}
void ServiceContext::setTickSource(std::unique_ptr<TickSource> newSource) {
diff --git a/src/mongo/db/service_context.h b/src/mongo/db/service_context.h
index 06c7892c504..b33b3aeeb4b 100644
--- a/src/mongo/db/service_context.h
+++ b/src/mongo/db/service_context.h
@@ -66,6 +66,8 @@ class TransportLayer;
* including limitations on the lifetime of registered listeners.
*/
class KillOpListenerInterface {
+ MONGO_DISALLOW_COPYING(KillOpListenerInterface);
+
public:
/**
* Will be called *after* ops have been told they should die.
@@ -75,20 +77,23 @@ public:
virtual void interruptAll() = 0;
protected:
+ KillOpListenerInterface() = default;
+
// Should not delete through a pointer of this type
- virtual ~KillOpListenerInterface() {}
+ virtual ~KillOpListenerInterface() = default;
};
class StorageFactoriesIterator {
MONGO_DISALLOW_COPYING(StorageFactoriesIterator);
public:
- virtual ~StorageFactoriesIterator() {}
+ virtual ~StorageFactoriesIterator() = default;
+
virtual bool more() const = 0;
virtual const StorageEngine::Factory* next() = 0;
protected:
- StorageFactoriesIterator() {}
+ StorageFactoriesIterator() = default;
};
/**
@@ -392,35 +397,39 @@ public:
*/
void notifyStartupComplete();
- //
- // Global OpObserver.
- //
-
/**
* Set the OpObserver.
*/
- virtual void setOpObserver(std::unique_ptr<OpObserver> opObserver) = 0;
+ void setOpObserver(std::unique_ptr<OpObserver> opObserver);
/**
* Return the OpObserver instance we're using.
*/
- virtual OpObserver* getOpObserver() = 0;
+ OpObserver* getOpObserver() const {
+ return _opObserver.get();
+ }
/**
* Returns the tick/clock source set in this context.
*/
- TickSource* getTickSource() const;
+ TickSource* getTickSource() const {
+ return _tickSource.get();
+ }
/**
* Get a ClockSource implementation that may be less precise than the _preciseClockSource but
* may be cheaper to call.
*/
- ClockSource* getFastClockSource() const;
+ ClockSource* getFastClockSource() const {
+ return _fastClockSource.get();
+ }
/**
* Get a ClockSource implementation that is very precise but may be expensive to call.
*/
- ClockSource* getPreciseClockSource() const;
+ ClockSource* getPreciseClockSource() const {
+ return _preciseClockSource.get();
+ }
/**
* Replaces the current tick/clock source with a new one. In other words, the old source will be
@@ -474,13 +483,6 @@ private:
virtual std::unique_ptr<OperationContext> _newOpCtx(Client* client, unsigned opId) = 0;
/**
- * Kills the given operation.
- *
- * Caller must own the service context's _mutex.
- */
- void _killOperation_inlock(OperationContext* opCtx, ErrorCodes::Error killCode);
-
- /**
* The key manager.
*/
std::shared_ptr<KeysCollectionManager> _keyManager;
@@ -511,6 +513,11 @@ private:
std::vector<std::unique_ptr<ClientObserver>> _clientObservers;
ClientSet _clients;
+ /**
+ * The registered OpObserver.
+ */
+ std::unique_ptr<OpObserver> _opObserver;
+
std::unique_ptr<TickSource> _tickSource;
/**
diff --git a/src/mongo/db/service_context_d.cpp b/src/mongo/db/service_context_d.cpp
index c84f60aad55..56f073630de 100644
--- a/src/mongo/db/service_context_d.cpp
+++ b/src/mongo/db/service_context_d.cpp
@@ -32,22 +32,16 @@
#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"
#include "mongo/db/concurrency/lock_state.h"
-#include "mongo/db/op_observer.h"
-#include "mongo/db/service_context.h"
#include "mongo/db/service_entry_point_mongod.h"
#include "mongo/db/storage/storage_engine.h"
#include "mongo/db/storage/storage_engine_lock_file.h"
#include "mongo/db/storage/storage_engine_metadata.h"
#include "mongo/db/storage/storage_options.h"
-#include "mongo/scripting/engine.h"
#include "mongo/stdx/memory.h"
-#include "mongo/stdx/mutex.h"
#include "mongo/util/log.h"
#include "mongo/util/map_util.h"
#include "mongo/util/mongoutils/str.h"
@@ -72,6 +66,8 @@ MONGO_INITIALIZER(SetGlobalEnvironment)(InitializerContext* context) {
}
} // namespace
+extern bool _supportsDocLocking;
+
ServiceContextMongoD::ServiceContextMongoD() = default;
ServiceContextMongoD::~ServiceContextMongoD() = default;
@@ -83,8 +79,6 @@ StorageEngine* ServiceContextMongoD::getGlobalStorageEngine() {
return _storageEngine;
}
-extern bool _supportsDocLocking;
-
void ServiceContextMongoD::createLockFile() {
try {
_lockFile.reset(new StorageEngineLockFile(storageGlobalParams.dbpath));
@@ -256,9 +250,8 @@ StorageFactoriesIterator* ServiceContextMongoD::makeStorageFactoriesIterator() {
return new StorageFactoriesIteratorMongoD(_storageFactories.begin(), _storageFactories.end());
}
-StorageFactoriesIteratorMongoD::StorageFactoriesIteratorMongoD(
- const ServiceContextMongoD::FactoryMap::const_iterator& begin,
- const ServiceContextMongoD::FactoryMap::const_iterator& end)
+StorageFactoriesIteratorMongoD::StorageFactoriesIteratorMongoD(const FactoryMapIterator& begin,
+ const FactoryMapIterator& end)
: _curr(begin), _end(end) {}
bool StorageFactoriesIteratorMongoD::more() const {
@@ -284,12 +277,4 @@ std::unique_ptr<OperationContext> ServiceContextMongoD::_newOpCtx(Client* client
return opCtx;
}
-void ServiceContextMongoD::setOpObserver(std::unique_ptr<OpObserver> opObserver) {
- _opObserver = std::move(opObserver);
-}
-
-OpObserver* ServiceContextMongoD::getOpObserver() {
- return _opObserver.get();
-}
-
} // namespace mongo
diff --git a/src/mongo/db/service_context_d.h b/src/mongo/db/service_context_d.h
index 0e96996206a..79b2126831a 100644
--- a/src/mongo/db/service_context_d.h
+++ b/src/mongo/db/service_context_d.h
@@ -28,11 +28,9 @@
#pragma once
-#include <boost/optional.hpp>
-#include <vector>
+#include <map>
#include "mongo/db/service_context.h"
-#include "mongo/platform/unordered_set.h"
namespace mongo {
@@ -41,7 +39,7 @@ class StorageEngineLockFile;
class ServiceContextMongoD final : public ServiceContext {
public:
- typedef std::map<std::string, const StorageEngine::Factory*> FactoryMap;
+ using FactoryMap = std::map<std::string, const StorageEngine::Factory*>;
ServiceContextMongoD();
@@ -62,10 +60,6 @@ public:
StorageFactoriesIterator* makeStorageFactoriesIterator() override;
- void setOpObserver(std::unique_ptr<OpObserver> opObserver) override;
-
- OpObserver* getOpObserver() override;
-
private:
std::unique_ptr<OperationContext> _newOpCtx(Client* client, unsigned opId) override;
@@ -74,20 +68,18 @@ private:
// logically owned here, but never deleted by anyone.
StorageEngine* _storageEngine = nullptr;
- // logically owned here.
- std::unique_ptr<OpObserver> _opObserver;
-
// All possible storage engines are registered here through MONGO_INIT.
FactoryMap _storageFactories;
};
-class StorageFactoriesIteratorMongoD : public StorageFactoriesIterator {
+class StorageFactoriesIteratorMongoD final : public StorageFactoriesIterator {
public:
typedef ServiceContextMongoD::FactoryMap::const_iterator FactoryMapIterator;
+
StorageFactoriesIteratorMongoD(const FactoryMapIterator& begin, const FactoryMapIterator& end);
- virtual bool more() const;
- virtual const StorageEngine::Factory* next();
+ bool more() const override;
+ const StorageEngine::Factory* next() override;
private:
FactoryMapIterator _curr;
diff --git a/src/mongo/db/service_context_d_test_fixture.cpp b/src/mongo/db/service_context_d_test_fixture.cpp
index eb35a212569..c47e554b633 100644
--- a/src/mongo/db/service_context_d_test_fixture.cpp
+++ b/src/mongo/db/service_context_d_test_fixture.cpp
@@ -52,7 +52,8 @@ namespace mongo {
void ServiceContextMongoDTest::setUp() {
Client::initThread(getThreadName());
- ServiceContext* serviceContext = getServiceContext();
+
+ auto const serviceContext = getServiceContext();
auto logicalClock = stdx::make_unique<LogicalClock>(serviceContext);
LogicalClock::set(serviceContext, std::move(logicalClock));
@@ -64,7 +65,8 @@ void ServiceContextMongoDTest::setUp() {
storageGlobalParams.dbpath = tempDir.path();
storageGlobalParams.engine = "ephemeralForTest";
storageGlobalParams.engineSetByUser = true;
- checked_cast<ServiceContextMongoD*>(getGlobalServiceContext())->createLockFile();
+
+ checked_cast<ServiceContextMongoD*>(serviceContext)->createLockFile();
serviceContext->initializeGlobalStorageEngine();
serviceContext->setOpObserver(stdx::make_unique<OpObserverNoop>());
}
diff --git a/src/mongo/db/service_context_noop.cpp b/src/mongo/db/service_context_noop.cpp
index 64e1388b80e..2ad4d1f2c3c 100644
--- a/src/mongo/db/service_context_noop.cpp
+++ b/src/mongo/db/service_context_noop.cpp
@@ -30,7 +30,6 @@
#include "mongo/db/service_context_noop.h"
-#include "mongo/db/op_observer.h"
#include "mongo/db/operation_context_noop.h"
#include "mongo/stdx/memory.h"
@@ -71,10 +70,4 @@ std::unique_ptr<OperationContext> ServiceContextNoop::_newOpCtx(Client* client,
return stdx::make_unique<OperationContextNoop>(client, opId);
}
-void ServiceContextNoop::setOpObserver(std::unique_ptr<OpObserver> opObserver) {}
-
-OpObserver* ServiceContextNoop::getOpObserver() {
- return nullptr;
-}
-
} // namespace mongo
diff --git a/src/mongo/db/service_context_noop.h b/src/mongo/db/service_context_noop.h
index d6e2d12e525..251cd43310a 100644
--- a/src/mongo/db/service_context_noop.h
+++ b/src/mongo/db/service_context_noop.h
@@ -47,10 +47,6 @@ public:
StorageFactoriesIterator* makeStorageFactoriesIterator() override;
- void setOpObserver(std::unique_ptr<OpObserver> opObserver) override;
-
- OpObserver* getOpObserver() override;
-
private:
std::unique_ptr<OperationContext> _newOpCtx(Client* client, unsigned opId) override;
};