summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands
diff options
context:
space:
mode:
authorADAM David Alan Martin <adam.martin@10gen.com>2018-04-27 16:09:09 -0400
committerADAM David Alan Martin <adam.martin@10gen.com>2018-04-27 17:23:21 -0400
commit2227f272a7a0a3e43625cb2d4a2704e1ccb6f893 (patch)
treeeeb3a3fe22df48b6819a5d7e719befd680b3dedc /src/mongo/db/commands
parent7c25d109bda4c56cc329ee4f1a1521a2f9bc690a (diff)
downloadmongo-2227f272a7a0a3e43625cb2d4a2704e1ccb6f893.tar.gz
SERVER-32645 Create a shim helper framework.
The `MONGO_DECLARE_SHIM`, `MONGO_DEFINE_SHIM`, and `MONGO_REGISTER_SHIM` macros can be used to create specialized types which are customization and auto-registration points for late-binding functions. In some sense they work like weak-symbols; however, they also are useful for tracking dependencies upon shimmed-out implementations.
Diffstat (limited to 'src/mongo/db/commands')
-rw-r--r--src/mongo/db/commands/create_indexes.cpp6
-rw-r--r--src/mongo/db/commands/dbcommands.cpp7
-rw-r--r--src/mongo/db/commands/dbcommands_d.cpp2
-rw-r--r--src/mongo/db/commands/find_and_modify.cpp4
-rw-r--r--src/mongo/db/commands/mr.cpp5
-rw-r--r--src/mongo/db/commands/resize_oplog.cpp2
-rw-r--r--src/mongo/db/commands/restart_catalog_command.cpp2
7 files changed, 15 insertions, 13 deletions
diff --git a/src/mongo/db/commands/create_indexes.cpp b/src/mongo/db/commands/create_indexes.cpp
index eb3b197278f..bf1edf90884 100644
--- a/src/mongo/db/commands/create_indexes.cpp
+++ b/src/mongo/db/commands/create_indexes.cpp
@@ -269,9 +269,9 @@ public:
str::stream() << "Not primary while creating indexes in " << ns.ns()));
}
- Database* db = dbHolder().get(opCtx, ns.db());
+ Database* db = DatabaseHolder::getDatabaseHolder().get(opCtx, ns.db());
if (!db) {
- db = dbHolder().openDb(opCtx, ns.db());
+ db = DatabaseHolder::getDatabaseHolder().openDb(opCtx, ns.db());
}
DatabaseShardingState::get(db).checkDbVersion(opCtx);
@@ -393,7 +393,7 @@ public:
str::stream() << "Not primary while completing index build in " << dbname,
repl::ReplicationCoordinator::get(opCtx)->canAcceptWritesFor(opCtx, ns));
- Database* db = dbHolder().get(opCtx, ns.db());
+ Database* db = DatabaseHolder::getDatabaseHolder().get(opCtx, ns.db());
if (db) {
DatabaseShardingState::get(db).checkDbVersion(opCtx);
}
diff --git a/src/mongo/db/commands/dbcommands.cpp b/src/mongo/db/commands/dbcommands.cpp
index 34e2ed22f5b..ed753c7392a 100644
--- a/src/mongo/db/commands/dbcommands.cpp
+++ b/src/mongo/db/commands/dbcommands.cpp
@@ -210,7 +210,7 @@ public:
// Closing a database requires a global lock.
Lock::GlobalWrite lk(opCtx);
- auto db = dbHolder().get(opCtx, dbname);
+ auto db = DatabaseHolder::getDatabaseHolder().get(opCtx, dbname);
if (db) {
if (db->isDropPending(opCtx)) {
return CommandHelpers::appendCommandStatus(
@@ -221,7 +221,8 @@ public:
}
} else {
// If the name doesn't make an exact match, check for a case insensitive match.
- std::set<std::string> otherCasing = dbHolder().getNamesWithConflictingCasing(dbname);
+ std::set<std::string> otherCasing =
+ DatabaseHolder::getDatabaseHolder().getNamesWithConflictingCasing(dbname);
if (otherCasing.empty()) {
// Database doesn't exist. Treat this as a success (historical behavior).
return true;
@@ -255,7 +256,7 @@ public:
opCtx, engine, dbname, preserveClonedFilesOnFailure, backupOriginalFiles);
// Open database before returning
- dbHolder().openDb(opCtx, dbname);
+ DatabaseHolder::getDatabaseHolder().openDb(opCtx, dbname);
return CommandHelpers::appendCommandStatus(result, status);
}
} cmdRepairDatabase;
diff --git a/src/mongo/db/commands/dbcommands_d.cpp b/src/mongo/db/commands/dbcommands_d.cpp
index a0b4be7ebd1..90ab6c70bfa 100644
--- a/src/mongo/db/commands/dbcommands_d.cpp
+++ b/src/mongo/db/commands/dbcommands_d.cpp
@@ -128,7 +128,7 @@ protected:
if (!db) {
// When setting the profiling level, create the database if it didn't already exist.
// When just reading the profiling level, we do not create the database.
- db = dbHolder().openDb(opCtx, dbName);
+ db = DatabaseHolder::getDatabaseHolder().openDb(opCtx, dbName);
}
uassertStatusOK(db->setProfilingLevel(opCtx, profilingLevel));
}
diff --git a/src/mongo/db/commands/find_and_modify.cpp b/src/mongo/db/commands/find_and_modify.cpp
index 5190d97bf1f..3a36c306626 100644
--- a/src/mongo/db/commands/find_and_modify.cpp
+++ b/src/mongo/db/commands/find_and_modify.cpp
@@ -480,8 +480,8 @@ public:
if (!collection) {
uassertStatusOK(userAllowedCreateNS(nsString.db(), nsString.coll()));
WriteUnitOfWork wuow(opCtx);
- uassertStatusOK(
- userCreateNS(opCtx, autoDb->getDb(), nsString.ns(), BSONObj()));
+ uassertStatusOK(Database::userCreateNS(
+ opCtx, autoDb->getDb(), nsString.ns(), BSONObj()));
wuow.commit();
collection = autoDb->getDb()->getCollection(opCtx, nsString);
diff --git a/src/mongo/db/commands/mr.cpp b/src/mongo/db/commands/mr.cpp
index 476fd6b5d3e..c743a951ba5 100644
--- a/src/mongo/db/commands/mr.cpp
+++ b/src/mongo/db/commands/mr.cpp
@@ -393,7 +393,8 @@ void State::dropTempCollections() {
writeConflictRetry(_opCtx, "M/R dropTempCollections", _config.incLong.ns(), [this] {
Lock::DBLock lk(_opCtx, _config.incLong.db(), MODE_X);
- if (Database* db = dbHolder().get(_opCtx, _config.incLong.ns())) {
+ if (Database* db =
+ DatabaseHolder::getDatabaseHolder().get(_opCtx, _config.incLong.ns())) {
WriteUnitOfWork wunit(_opCtx);
uassertStatusOK(db->dropCollection(_opCtx, _config.incLong.ns()));
wunit.commit();
@@ -653,7 +654,7 @@ unsigned long long _collectionCount(OperationContext* opCtx,
// If the global write lock is held, we must avoid using AutoGetCollectionForReadCommand as it
// may lead to deadlock when waiting for a majority snapshot to be committed. See SERVER-24596.
if (callerHoldsGlobalLock) {
- Database* db = dbHolder().get(opCtx, nss.ns());
+ Database* db = DatabaseHolder::getDatabaseHolder().get(opCtx, nss.ns());
if (db) {
coll = db->getCollection(opCtx, nss);
}
diff --git a/src/mongo/db/commands/resize_oplog.cpp b/src/mongo/db/commands/resize_oplog.cpp
index d82c4321695..726cf043b5d 100644
--- a/src/mongo/db/commands/resize_oplog.cpp
+++ b/src/mongo/db/commands/resize_oplog.cpp
@@ -87,7 +87,7 @@ public:
BSONObjBuilder& result) {
const NamespaceString nss("local", "oplog.rs");
Lock::GlobalWrite global(opCtx);
- Database* database = dbHolder().get(opCtx, nss.db());
+ Database* database = DatabaseHolder::getDatabaseHolder().get(opCtx, nss.db());
if (!database) {
return CommandHelpers::appendCommandStatus(
result, Status(ErrorCodes::NamespaceNotFound, "database local does not exist"));
diff --git a/src/mongo/db/commands/restart_catalog_command.cpp b/src/mongo/db/commands/restart_catalog_command.cpp
index a3aefcd3168..f840f7954bc 100644
--- a/src/mongo/db/commands/restart_catalog_command.cpp
+++ b/src/mongo/db/commands/restart_catalog_command.cpp
@@ -95,7 +95,7 @@ public:
std::vector<std::string> allDbs;
getGlobalServiceContext()->getGlobalStorageEngine()->listDatabases(&allDbs);
for (auto&& dbName : allDbs) {
- const auto db = dbHolder().get(opCtx, dbName);
+ const auto db = DatabaseHolder::getDatabaseHolder().get(opCtx, dbName);
if (db->isDropPending(opCtx)) {
return CommandHelpers::appendCommandStatus(
result,