diff options
author | Mathias Stearn <mathias@10gen.com> | 2014-07-01 13:31:17 -0400 |
---|---|---|
committer | Mathias Stearn <mathias@10gen.com> | 2014-07-09 12:57:12 -0400 |
commit | 46a25fdd1470fb08876c229e77be4986fd12082b (patch) | |
tree | 5db072e07fb6c0ee3f2c573b9abc1083f68aca08 /src/mongo/db/storage/storage_engine.h | |
parent | 4939ccc6ebb0f7a61121e77ceeebd75d8841606a (diff) | |
download | mongo-46a25fdd1470fb08876c229e77be4986fd12082b.tar.gz |
SERVER-14395 Clean up StorageEngine initialization and shutdown
* Added StorageEngine::cleanShutdown() and commented that the destructor will
never be called.
* MMapV1StorageEngine specific operations were pulled into its constructor
and cleanShutdown implementation.
* StorageEngines are now constructed at a point where it is safe to spawn
threads.
Diffstat (limited to 'src/mongo/db/storage/storage_engine.h')
-rw-r--r-- | src/mongo/db/storage/storage_engine.h | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/mongo/db/storage/storage_engine.h b/src/mongo/db/storage/storage_engine.h index f75fde343e4..66fa954d8fa 100644 --- a/src/mongo/db/storage/storage_engine.h +++ b/src/mongo/db/storage/storage_engine.h @@ -44,7 +44,6 @@ namespace mongo { class StorageEngine { public: - virtual ~StorageEngine() {} virtual RecoveryUnit* newRecoveryUnit( OperationContext* opCtx ) = 0; @@ -61,11 +60,18 @@ namespace mongo { */ virtual int flushAllFiles( bool sync ) = 0; - virtual Status repairDatabase( OperationContext* tnx, + virtual Status repairDatabase( OperationContext* txn, const std::string& dbName, bool preserveClonedFilesOnFailure = false, bool backupOriginalFiles = false ) = 0; + /** + * Will be called before a clean shutdown. + * Override if you have clean-up to do that is different from unclean shutdown. + * There is intentionally no uncleanShutdown(). + */ + virtual void cleanShutdown(OperationContext* txn) {} + class Factory { public: virtual ~Factory(){} @@ -73,8 +79,20 @@ namespace mongo { }; static void registerFactory( const std::string& name, const Factory* factory ); + + protected: + /** + * The destructor will never be called. See cleanShutdown instead. + */ + 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; } |