Storage Engine API
storage_engine_init.h
Go to the documentation of this file.
1 
29 #pragma once
30 
31 #include <memory>
32 
33 #include "mongo/base/string_data.h"
34 #include "mongo/db/service_context.h"
36 #include "mongo/platform/bitwise_enum_operators.h"
37 
38 namespace mongo {
39 
44  kNone = 0,
45  kAllowNoLockFile = 1 << 0,
46 };
47 
51 void initializeStorageEngine(ServiceContext* service, StorageEngineInitFlags initFlags);
52 
56 void shutdownGlobalStorageEngineCleanly(ServiceContext* service);
57 
62 void createLockFile(ServiceContext* service);
63 
67 void registerStorageEngine(ServiceContext* service,
68  std::unique_ptr<StorageEngine::Factory> factory);
69 
73 bool isRegisteredStorageEngine(ServiceContext* service, StringData name);
74 
80 StorageEngine::Factory* getFactoryForStorageEngine(ServiceContext* context, StringData name);
81 
82 /*
83  * Extracts the storageEngine bson from the CollectionOptions provided. Loops through each
84  * provided storageEngine and asks the matching registered storage engine if the
85  * collection/index options are valid. Returns an error if the collection/index options are
86  * invalid.
87  * If no matching registered storage engine is found, return an error.
88  * Validation function 'func' must be either:
89  * - &StorageEngine::Factory::validateCollectionStorageOptions; or
90  * - &StorageEngine::Factory::validateIndexStorageOptions
91  */
93  ServiceContext* service,
94  const BSONObj& storageEngineOptions,
95  stdx::function<Status(const StorageEngine::Factory* const, const BSONObj&)> validateFunc);
96 
97 /*
98  * Appends a the list of available storage engines to a BSONObjBuilder for reporting purposes.
99  */
100 void appendStorageEngineList(ServiceContext* service, BSONObjBuilder* result);
101 
102 ENABLE_BITMASK_OPERATORS(StorageEngineInitFlags)
103 
104 } // namespace mongo
Definition: storage_engine_init.h:45
Copyright (C) 2014 MongoDB Inc.
Definition: bson_collection_catalog_entry.cpp:38
StorageEngine::Factory * getFactoryForStorageEngine(ServiceContext *service, StringData name)
Returns an unowned pointer to the factory for the named storage engine, or nullptr.
Definition: storage_engine_init.cpp:253
Status validateStorageOptions(ServiceContext *service, const BSONObj &storageEngineOptions, stdx::function< Status(const StorageEngine::Factory *const, const BSONObj &)> validateFunc)
Definition: storage_engine_init.cpp:261
Definition: storage_engine_init.h:44
void initializeStorageEngine(ServiceContext *service, StorageEngineInitFlags initFlags)
Initializes the storage engine on "service".
Definition: storage_engine_init.cpp:50
ServiceContextNoop service
Definition: kv_engine_test_timestamps.cpp:203
OperationContext Database StringData CollectionOptions bool const BSONObj &idIndex Status
Definition: database_impl.cpp:955
StorageEngineInitFlags
Valid flags to pass to initializeStorageEngine.
Definition: storage_engine_init.h:43
InitializerContext * context
Definition: devnull_init.cpp:69
void registerStorageEngine(ServiceContext *service, std::unique_ptr< StorageEngine::Factory > factory)
Registers a storage engine onto the given "service".
Definition: storage_engine_init.cpp:234
void createLockFile(ServiceContext *service)
Creates the lock file used to prevent concurrent processes from accessing the data files,...
Definition: storage_engine_init.cpp:195
bool isRegisteredStorageEngine(ServiceContext *service, StringData name)
Returns true if "name" refers to a registered storage engine.
Definition: storage_engine_init.cpp:249
Database *const OperationContext *const const StringData name
Definition: database_impl.cpp:82
void shutdownGlobalStorageEngineCleanly(ServiceContext *service)
Shuts down storage engine cleanly and releases any locks on mongod.lock.
Definition: storage_engine_init.cpp:186
void appendStorageEngineList(ServiceContext *service, BSONObjBuilder *result)
Definition: storage_engine_init.cpp:305