summaryrefslogtreecommitdiff
path: root/src/mongo/db/storage/kv
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2018-12-22 17:07:52 -0500
committerBenety Goh <benety@mongodb.com>2018-12-22 17:08:23 -0500
commitc7124bb488ac67ed53db7e827d6da34242305b55 (patch)
treee6e1e4f4dbefb6d6f8672f6eb73b9289e6654b99 /src/mongo/db/storage/kv
parentb30c434c313dde1ded0bc0d73d264d27b1eafaa6 (diff)
downloadmongo-c7124bb488ac67ed53db7e827d6da34242305b55.tar.gz
SERVER-38603 add KVStorageEngineInterface.hbdefg
This helps to break the curcular dependency between KVDatabaseCatalogEntryBase and KVStorageEngine.
Diffstat (limited to 'src/mongo/db/storage/kv')
-rw-r--r--src/mongo/db/storage/kv/kv_database_catalog_entry.cpp3
-rw-r--r--src/mongo/db/storage/kv/kv_database_catalog_entry_base.cpp3
-rw-r--r--src/mongo/db/storage/kv/kv_database_catalog_entry_base.h6
-rw-r--r--src/mongo/db/storage/kv/kv_database_catalog_entry_mock.cpp2
-rw-r--r--src/mongo/db/storage/kv/kv_database_catalog_entry_mock.h2
-rw-r--r--src/mongo/db/storage/kv/kv_storage_engine.cpp6
-rw-r--r--src/mongo/db/storage/kv/kv_storage_engine.h27
7 files changed, 40 insertions, 9 deletions
diff --git a/src/mongo/db/storage/kv/kv_database_catalog_entry.cpp b/src/mongo/db/storage/kv/kv_database_catalog_entry.cpp
index d240dc0786f..32d3c533a72 100644
--- a/src/mongo/db/storage/kv/kv_database_catalog_entry.cpp
+++ b/src/mongo/db/storage/kv/kv_database_catalog_entry.cpp
@@ -49,7 +49,8 @@
#include "mongo/util/assert_util.h"
#include "mongo/util/log.h"
-auto mongo::defaultDatabaseCatalogEntryFactory(const StringData name, KVStorageEngine* const engine)
+auto mongo::defaultDatabaseCatalogEntryFactory(const StringData name,
+ KVStorageEngineInterface* const engine)
-> std::unique_ptr<KVDatabaseCatalogEntryBase> {
return stdx::make_unique<KVDatabaseCatalogEntry>(name, engine);
}
diff --git a/src/mongo/db/storage/kv/kv_database_catalog_entry_base.cpp b/src/mongo/db/storage/kv/kv_database_catalog_entry_base.cpp
index 8fac194a5de..c044da17af4 100644
--- a/src/mongo/db/storage/kv/kv_database_catalog_entry_base.cpp
+++ b/src/mongo/db/storage/kv/kv_database_catalog_entry_base.cpp
@@ -143,7 +143,8 @@ private:
const NamespaceString _toNs;
};
-KVDatabaseCatalogEntryBase::KVDatabaseCatalogEntryBase(StringData db, KVStorageEngine* engine)
+KVDatabaseCatalogEntryBase::KVDatabaseCatalogEntryBase(StringData db,
+ KVStorageEngineInterface* engine)
: DatabaseCatalogEntry(db), _engine(engine) {}
KVDatabaseCatalogEntryBase::~KVDatabaseCatalogEntryBase() {
diff --git a/src/mongo/db/storage/kv/kv_database_catalog_entry_base.h b/src/mongo/db/storage/kv/kv_database_catalog_entry_base.h
index 2a14e8e0e84..6871da3af36 100644
--- a/src/mongo/db/storage/kv/kv_database_catalog_entry_base.h
+++ b/src/mongo/db/storage/kv/kv_database_catalog_entry_base.h
@@ -38,12 +38,12 @@
namespace mongo {
-class KVStorageEngine;
+class KVStorageEngineInterface;
class KVCollectionCatalogEntry;
class KVDatabaseCatalogEntryBase : public DatabaseCatalogEntry {
public:
- KVDatabaseCatalogEntryBase(StringData db, KVStorageEngine* engine);
+ KVDatabaseCatalogEntryBase(StringData db, KVStorageEngineInterface* engine);
~KVDatabaseCatalogEntryBase() override;
bool exists() const override;
@@ -94,7 +94,7 @@ protected:
typedef std::map<std::string, KVCollectionCatalogEntry*> CollectionMap;
- KVStorageEngine* const _engine; // not owned here
+ KVStorageEngineInterface* const _engine; // not owned here
CollectionMap _collections;
};
} // namespace mongo
diff --git a/src/mongo/db/storage/kv/kv_database_catalog_entry_mock.cpp b/src/mongo/db/storage/kv/kv_database_catalog_entry_mock.cpp
index e2671e22116..20f725cf7f3 100644
--- a/src/mongo/db/storage/kv/kv_database_catalog_entry_mock.cpp
+++ b/src/mongo/db/storage/kv/kv_database_catalog_entry_mock.cpp
@@ -38,7 +38,7 @@
#include "mongo/util/assert_util.h"
std::unique_ptr<mongo::KVDatabaseCatalogEntryMock> mongo::kvDatabaseCatalogEntryMockFactory(
- const StringData name, KVStorageEngine* const engine) {
+ const StringData name, KVStorageEngineInterface* const engine) {
return stdx::make_unique<KVDatabaseCatalogEntryMock>(name, engine);
}
diff --git a/src/mongo/db/storage/kv/kv_database_catalog_entry_mock.h b/src/mongo/db/storage/kv/kv_database_catalog_entry_mock.h
index 2611e4c3ae8..9473669cfdd 100644
--- a/src/mongo/db/storage/kv/kv_database_catalog_entry_mock.h
+++ b/src/mongo/db/storage/kv/kv_database_catalog_entry_mock.h
@@ -47,5 +47,5 @@ public:
};
std::unique_ptr<KVDatabaseCatalogEntryMock> kvDatabaseCatalogEntryMockFactory(
- StringData name, KVStorageEngine* engine);
+ StringData name, KVStorageEngineInterface* engine);
} // namespace mongo
diff --git a/src/mongo/db/storage/kv/kv_storage_engine.cpp b/src/mongo/db/storage/kv/kv_storage_engine.cpp
index 80290716266..130bf563fe2 100644
--- a/src/mongo/db/storage/kv/kv_storage_engine.cpp
+++ b/src/mongo/db/storage/kv/kv_storage_engine.cpp
@@ -789,6 +789,12 @@ void KVStorageEngine::_dumpCatalog(OperationContext* opCtx) {
opCtx->recoveryUnit()->abandonSnapshot();
}
+void KVStorageEngine::addDropPendingIdent(const Timestamp& dropTimestamp,
+ const NamespaceString& nss,
+ StringData ident) {
+ _dropPendingIdentReaper.addDropPendingIdent(dropTimestamp, nss, ident);
+}
+
void KVStorageEngine::_onOldestTimestampChanged(const Timestamp& oldestTimestamp) {
if (oldestTimestamp.isNull()) {
return;
diff --git a/src/mongo/db/storage/kv/kv_storage_engine.h b/src/mongo/db/storage/kv/kv_storage_engine.h
index d04d8d41679..a200c10106b 100644
--- a/src/mongo/db/storage/kv/kv_storage_engine.h
+++ b/src/mongo/db/storage/kv/kv_storage_engine.h
@@ -60,6 +60,21 @@ struct KVStorageEngineOptions {
bool forRepair = false;
};
+/**
+ * Minimal interface for KVDatabaseCatalogEntryBase to access KVStorageEngine.
+ */
+class KVStorageEngineInterface {
+public:
+ KVStorageEngineInterface() = default;
+ virtual ~KVStorageEngineInterface() = default;
+ virtual StorageEngine* getStorageEngine() = 0;
+ virtual KVEngine* getEngine() = 0;
+ virtual void addDropPendingIdent(const Timestamp& dropTimestamp,
+ const NamespaceString& nss,
+ StringData ident) = 0;
+ virtual KVCatalog* getCatalog() = 0;
+};
+
/*
* The actual definition for this function is in
* `src/mongo/db/storage/kv/kv_database_catalog_entry.cpp` This unusual forward declaration is to
@@ -68,11 +83,11 @@ struct KVStorageEngineOptions {
* `KVDatabaseCatalogEntry` code.
*/
std::unique_ptr<KVDatabaseCatalogEntryBase> defaultDatabaseCatalogEntryFactory(
- const StringData name, KVStorageEngine* const engine);
+ const StringData name, KVStorageEngineInterface* const engine);
using KVDatabaseCatalogEntryFactory = decltype(defaultDatabaseCatalogEntryFactory);
-class KVStorageEngine final : public StorageEngine {
+class KVStorageEngine final : public KVStorageEngineInterface, public StorageEngine {
public:
/**
* @param engine - ownership passes to me
@@ -300,6 +315,10 @@ public:
std::vector<TimestampListener*> _listeners;
};
+ StorageEngine* getStorageEngine() override {
+ return this;
+ }
+
KVEngine* getEngine() {
return _engine.get();
}
@@ -307,6 +326,10 @@ public:
return _engine.get();
}
+ void addDropPendingIdent(const Timestamp& dropTimestamp,
+ const NamespaceString& nss,
+ StringData ident) override;
+
KVCatalog* getCatalog() {
return _catalog.get();
}