![]() |
Storage Engine API
|
This reads and write the storage engine metadata file 'storage.bson' in the data directory (See –dbpath). More...
#include <storage_engine_metadata.h>
This reads and write the storage engine metadata file 'storage.bson' in the data directory (See –dbpath).
'storage.engine' is the only mandatory field in the BSON metadata file. Fields other than 'storage.engine' are ignored.
Public Member Functions | |
StorageEngineMetadata (const std::string &dbpath) | |
Sets fields to defaults. More... | |
virtual | ~StorageEngineMetadata () |
const std::string & | getStorageEngine () const |
Returns name of storage engine in metadata. More... | |
const BSONObj & | getStorageEngineOptions () const |
Returns storage engine options in metadata. More... | |
void | setStorageEngine (const std::string &storageEngine) |
Sets name of storage engine in metadata. More... | |
void | setStorageEngineOptions (const BSONObj &storageEngineOptions) |
Sets storage engine options in metadata. More... | |
void | reset () |
Resets fields to default values. More... | |
Status | read () |
Reads metadata from 'storage.bson' in 'dbpath' directory. More... | |
Status | write () const |
Writes metadata to file. More... | |
template<typename T > | |
Status | validateStorageEngineOption (StringData fieldName, T expectedValue, boost::optional< T > defaultValue=boost::none) const |
Validates a single field in the storage engine options. More... | |
template<> | |
Status | validateStorageEngineOption (StringData fieldName, bool expectedValue, boost::optional< bool > defaultValue) const |
Static Public Member Functions | |
static std::unique_ptr< StorageEngineMetadata > | forPath (const std::string &dbpath) |
Returns a metadata object describing the storage engine that backs the data files contained in 'dbpath', and nullptr otherwise. More... | |
static boost::optional< std::string > | getStorageEngineForPath (const std::string &dbpath) |
Returns the name of the storage engine that backs the data files contained in 'dbpath', and none otherwise. More... | |
Private Member Functions | |
MONGO_DISALLOW_COPYING (StorageEngineMetadata) | |
Private Attributes | |
std::string | _dbpath |
std::string | _storageEngine |
BSONObj | _storageEngineOptions |
mongo::StorageEngineMetadata::StorageEngineMetadata | ( | const std::string & | dbpath | ) |
Sets fields to defaults.
Use read() load metadata from file.
|
virtual |
|
static |
Returns a metadata object describing the storage engine that backs the data files contained in 'dbpath', and nullptr otherwise.
const std::string & mongo::StorageEngineMetadata::getStorageEngine | ( | ) | const |
Returns name of storage engine in metadata.
|
static |
Returns the name of the storage engine that backs the data files contained in 'dbpath', and none otherwise.
const BSONObj & mongo::StorageEngineMetadata::getStorageEngineOptions | ( | ) | const |
Returns storage engine options in metadata.
|
private |
Status mongo::StorageEngineMetadata::read | ( | ) |
Reads metadata from 'storage.bson' in 'dbpath' directory.
void mongo::StorageEngineMetadata::reset | ( | ) |
Resets fields to default values.
void mongo::StorageEngineMetadata::setStorageEngine | ( | const std::string & | storageEngine | ) |
Sets name of storage engine in metadata.
void mongo::StorageEngineMetadata::setStorageEngineOptions | ( | const BSONObj & | storageEngineOptions | ) |
Sets storage engine options in metadata.
Status mongo::StorageEngineMetadata::validateStorageEngineOption | ( | StringData | fieldName, |
T | expectedValue, | ||
boost::optional< T > | defaultValue = boost::none |
||
) | const |
Validates a single field in the storage engine options.
Currently, only boolean fields are supported. If the 'fieldName' does not exist in the 'storage.bson' file and a 'defaultValue' is passed in, the 'expectedValue' must match the 'defaultValue'.
Status mongo::StorageEngineMetadata::validateStorageEngineOption | ( | StringData | fieldName, |
bool | expectedValue, | ||
boost::optional< bool > | defaultValue | ||
) | const |
Status mongo::StorageEngineMetadata::write | ( | ) | const |
Writes metadata to file.
|
private |
|
private |
|
private |