Storage Engine API
mongo::StorageEngineMetadata Class Reference

This reads and write the storage engine metadata file 'storage.bson' in the data directory (See –dbpath). More...

#include <storage_engine_metadata.h>

Detailed Description

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< StorageEngineMetadataforPath (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
 

Constructor & Destructor Documentation

◆ StorageEngineMetadata()

mongo::StorageEngineMetadata::StorageEngineMetadata ( const std::string &  dbpath)

Sets fields to defaults.

Use read() load metadata from file.

◆ ~StorageEngineMetadata()

mongo::StorageEngineMetadata::~StorageEngineMetadata ( )
virtual

Member Function Documentation

◆ forPath()

std::unique_ptr< StorageEngineMetadata > mongo::StorageEngineMetadata::forPath ( const std::string &  dbpath)
static

Returns a metadata object describing the storage engine that backs the data files contained in 'dbpath', and nullptr otherwise.

◆ getStorageEngine()

const std::string & mongo::StorageEngineMetadata::getStorageEngine ( ) const

Returns name of storage engine in metadata.

◆ getStorageEngineForPath()

boost::optional< std::string > mongo::StorageEngineMetadata::getStorageEngineForPath ( const std::string &  dbpath)
static

Returns the name of the storage engine that backs the data files contained in 'dbpath', and none otherwise.

◆ getStorageEngineOptions()

const BSONObj & mongo::StorageEngineMetadata::getStorageEngineOptions ( ) const

Returns storage engine options in metadata.

◆ MONGO_DISALLOW_COPYING()

mongo::StorageEngineMetadata::MONGO_DISALLOW_COPYING ( StorageEngineMetadata  )
private

◆ read()

Status mongo::StorageEngineMetadata::read ( )

Reads metadata from 'storage.bson' in 'dbpath' directory.

◆ reset()

void mongo::StorageEngineMetadata::reset ( )

Resets fields to default values.

◆ setStorageEngine()

void mongo::StorageEngineMetadata::setStorageEngine ( const std::string &  storageEngine)

Sets name of storage engine in metadata.

◆ setStorageEngineOptions()

void mongo::StorageEngineMetadata::setStorageEngineOptions ( const BSONObj &  storageEngineOptions)

Sets storage engine options in metadata.

◆ validateStorageEngineOption() [1/2]

template<typename T >
Status mongo::StorageEngineMetadata::validateStorageEngineOption ( StringData  fieldName,
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'.

◆ validateStorageEngineOption() [2/2]

template<>
Status mongo::StorageEngineMetadata::validateStorageEngineOption ( StringData  fieldName,
bool  expectedValue,
boost::optional< bool >  defaultValue 
) const

◆ write()

Status mongo::StorageEngineMetadata::write ( ) const

Writes metadata to file.

Member Data Documentation

◆ _dbpath

std::string mongo::StorageEngineMetadata::_dbpath
private

◆ _storageEngine

std::string mongo::StorageEngineMetadata::_storageEngine
private

◆ _storageEngineOptions

BSONObj mongo::StorageEngineMetadata::_storageEngineOptions
private

The documentation for this class was generated from the following files: